mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
IRQ int
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
#define SDA_LOW() HAL_GPIO_WritePin(SDA2_GPIO_Port, SDA2_Pin, GPIO_PIN_RESET)
|
#define SDA_LOW() HAL_GPIO_WritePin(SDA2_GPIO_Port, SDA2_Pin, GPIO_PIN_RESET)
|
||||||
#define SDA_READ() (HAL_GPIO_ReadPin(SDA2_GPIO_Port,SDA2_Pin)==GPIO_PIN_SET?1:0)
|
#define SDA_READ() (HAL_GPIO_ReadPin(SDA2_GPIO_Port,SDA2_Pin)==GPIO_PIN_SET?1:0)
|
||||||
#define SCL_READ() (HAL_GPIO_ReadPin(SCL2_GPIO_Port,SCL2_Pin)==GPIO_PIN_SET?1:0)
|
#define SCL_READ() (HAL_GPIO_ReadPin(SCL2_GPIO_Port,SCL2_Pin)==GPIO_PIN_SET?1:0)
|
||||||
#define I2C_DELAY() {for(int xx=0;xx<700;xx++){asm("nop");}}
|
#define I2C_DELAY() {for(int xx=0;xx<100;xx++){asm("nop");}}
|
||||||
SemaphoreHandle_t I2CBB::I2CSemaphore = NULL;
|
SemaphoreHandle_t I2CBB::I2CSemaphore = NULL;
|
||||||
StaticSemaphore_t I2CBB::xSemaphoreBuffer;
|
StaticSemaphore_t I2CBB::xSemaphoreBuffer;
|
||||||
void I2CBB::init() {
|
void I2CBB::init() {
|
||||||
@@ -269,7 +269,11 @@ bool I2CBB::lock() {
|
|||||||
if (I2CSemaphore == NULL) {
|
if (I2CSemaphore == NULL) {
|
||||||
asm("bkpt");
|
asm("bkpt");
|
||||||
}
|
}
|
||||||
return xSemaphoreTake(I2CSemaphore, (TickType_t) 50) == pdTRUE;
|
bool a = xSemaphoreTake(I2CSemaphore, (TickType_t) 50) == pdTRUE;
|
||||||
|
if (!a) {
|
||||||
|
asm("bkpt");
|
||||||
|
}
|
||||||
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2CBB::write_bit(uint8_t val) {
|
void I2CBB::write_bit(uint8_t val) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "IRQ.h"
|
#include "IRQ.h"
|
||||||
|
#include "int_n.h"
|
||||||
/*
|
/*
|
||||||
* Catch the IRQ that says that the conversion is done on the temperature
|
* Catch the IRQ that says that the conversion is done on the temperature
|
||||||
* readings coming in Once these have come in we can unblock the PID so that it
|
* readings coming in Once these have come in we can unblock the PID so that it
|
||||||
@@ -41,3 +42,7 @@ void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
|
|||||||
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
|
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
|
||||||
FRToSI2C::CpltCallback();
|
FRToSI2C::CpltCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
|
||||||
|
InterruptHandler::irqCallback();
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|||||||
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||||
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||||
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||||
|
void HAL_GPIO_EXTI_Callback(uint16_t);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,59 +41,56 @@ void InterruptHandler::Thread(const void *arg) {
|
|||||||
(void) arg;
|
(void) arg;
|
||||||
union fusb_status status;
|
union fusb_status status;
|
||||||
eventmask_t events;
|
eventmask_t events;
|
||||||
//TODO use IRQ task notification to unblock this thread to stop it spinning
|
|
||||||
while (true) {
|
while (true) {
|
||||||
/* If the INT_N line is low */
|
/* If the INT_N line is low */
|
||||||
if (pd_irq_read() == 0) {
|
xTaskNotifyWait(0x00, 0x0F, NULL, 5);
|
||||||
/* Read the FUSB302B status and interrupt registers */
|
/* Read the FUSB302B status and interrupt registers */
|
||||||
fusb_get_status(&status);
|
fusb_get_status(&status);
|
||||||
//Check for rx alerts
|
//Check for rx alerts
|
||||||
{
|
|
||||||
/* If the I_GCRCSENT flag is set, tell the Protocol RX thread */
|
|
||||||
if (status.interruptb & FUSB_INTERRUPTB_I_GCRCSENT) {
|
|
||||||
ProtocolReceive::notify(PDB_EVT_PRLRX_I_GCRCSENT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* If the I_TXSENT or I_RETRYFAIL flag is set, tell the Protocol TX
|
|
||||||
* thread */
|
|
||||||
{
|
|
||||||
events = 0;
|
|
||||||
if (status.interrupta & FUSB_INTERRUPTA_I_RETRYFAIL) {
|
|
||||||
events |= PDB_EVT_PRLTX_I_RETRYFAIL;
|
|
||||||
}
|
|
||||||
if (status.interrupta & FUSB_INTERRUPTA_I_TXSENT) {
|
|
||||||
events |= PDB_EVT_PRLTX_I_TXSENT;
|
|
||||||
}
|
|
||||||
if (events) {
|
|
||||||
ProtocolTransmit::notify(events);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* If the I_HARDRST or I_HARDSENT flag is set, tell the Hard Reset
|
|
||||||
* thread */
|
|
||||||
{
|
|
||||||
events = 0;
|
|
||||||
if (status.interrupta & FUSB_INTERRUPTA_I_HARDRST) {
|
|
||||||
events |= PDB_EVT_HARDRST_I_HARDRST;
|
|
||||||
}
|
|
||||||
if (status.interrupta & FUSB_INTERRUPTA_I_HARDSENT) {
|
|
||||||
events |= PDB_EVT_HARDRST_I_HARDSENT;
|
|
||||||
}
|
|
||||||
if (events) {
|
|
||||||
ResetHandler::notify(events);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
/* If the I_OCP_TEMP and OVRTEMP flags are set, tell the Policy
|
|
||||||
* Engine thread */
|
|
||||||
if (status.interrupta & FUSB_INTERRUPTA_I_OCP_TEMP
|
|
||||||
&& status.status1 & FUSB_STATUS1_OVRTEMP) {
|
|
||||||
PolicyEngine::notify(PDB_EVT_PE_I_OVRTEMP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
/* If the I_GCRCSENT flag is set, tell the Protocol RX thread */
|
||||||
osDelay(1);
|
if (status.interruptb & FUSB_INTERRUPTB_I_GCRCSENT) {
|
||||||
|
ProtocolReceive::notify(PDB_EVT_PRLRX_I_GCRCSENT);
|
||||||
}
|
}
|
||||||
osDelay(1);
|
|
||||||
|
/* If the I_TXSENT or I_RETRYFAIL flag is set, tell the Protocol TX
|
||||||
|
* thread */
|
||||||
|
|
||||||
|
events = 0;
|
||||||
|
if (status.interrupta & FUSB_INTERRUPTA_I_RETRYFAIL) {
|
||||||
|
events |= PDB_EVT_PRLTX_I_RETRYFAIL;
|
||||||
|
}
|
||||||
|
if (status.interrupta & FUSB_INTERRUPTA_I_TXSENT) {
|
||||||
|
events |= PDB_EVT_PRLTX_I_TXSENT;
|
||||||
|
}
|
||||||
|
if (events) {
|
||||||
|
ProtocolTransmit::notify(events);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the I_HARDRST or I_HARDSENT flag is set, tell the Hard Reset
|
||||||
|
* thread */
|
||||||
|
|
||||||
|
events = 0;
|
||||||
|
if (status.interrupta & FUSB_INTERRUPTA_I_HARDRST) {
|
||||||
|
events |= PDB_EVT_HARDRST_I_HARDRST;
|
||||||
|
}
|
||||||
|
if (status.interrupta & FUSB_INTERRUPTA_I_HARDSENT) {
|
||||||
|
events |= PDB_EVT_HARDRST_I_HARDSENT;
|
||||||
|
}
|
||||||
|
if (events) {
|
||||||
|
ResetHandler::notify(events);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the I_OCP_TEMP and OVRTEMP flags are set, tell the Policy
|
||||||
|
* Engine thread */
|
||||||
|
if (status.interrupta & FUSB_INTERRUPTA_I_OCP_TEMP
|
||||||
|
&& status.status1 & FUSB_STATUS1_OVRTEMP) {
|
||||||
|
PolicyEngine::notify(PDB_EVT_PE_I_OVRTEMP);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InterruptHandler::irqCallback() {
|
||||||
|
xTaskNotify(TaskHandle, 0x0F, eNotifyAction::eSetBits);
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,8 +24,9 @@ class InterruptHandler {
|
|||||||
public:
|
public:
|
||||||
//Creates the thread to handle the Interrupt pin
|
//Creates the thread to handle the Interrupt pin
|
||||||
static void init();
|
static void init();
|
||||||
//TODO handle irq callbacks instead of polling the pin
|
|
||||||
|
|
||||||
|
|
||||||
|
static void irqCallback();
|
||||||
private:
|
private:
|
||||||
static void Thread(const void *arg);
|
static void Thread(const void *arg);
|
||||||
static osThreadId TaskHandle;
|
static osThreadId TaskHandle;
|
||||||
|
|||||||
Reference in New Issue
Block a user