mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Poking IRQ
This commit is contained in:
@@ -43,7 +43,7 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address, uint8_t *p_b
|
|||||||
i2cCfg.subAddrSize = 1; // one byte address
|
i2cCfg.subAddrSize = 1; // one byte address
|
||||||
|
|
||||||
err = I2C_MasterReceiveBlocking(I2C0_ID, &i2cCfg);
|
err = I2C_MasterReceiveBlocking(I2C0_ID, &i2cCfg);
|
||||||
// MSG((char *)"I2C Mem_Read %02X - %d - %d\r\n", DevAddress >> 1, err, number_of_byte);
|
MSG((char *)"I2C Mem_Read %02X - %d - %d\r\n", DevAddress >> 1, err, number_of_byte);
|
||||||
bool res = err == SUCCESS;
|
bool res = err == SUCCESS;
|
||||||
if (!res) {
|
if (!res) {
|
||||||
I2C_Unstick();
|
I2C_Unstick();
|
||||||
@@ -66,7 +66,7 @@ bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *p_bu
|
|||||||
i2cCfg.subAddrSize = 1; // one byte address
|
i2cCfg.subAddrSize = 1; // one byte address
|
||||||
|
|
||||||
err = I2C_MasterSendBlocking(I2C0_ID, &i2cCfg);
|
err = I2C_MasterSendBlocking(I2C0_ID, &i2cCfg);
|
||||||
// MSG((char *)"I2C Mem_Write %02X - %d\r\n", DevAddress >> 1, err);
|
MSG((char *)"I2C Mem_Write %02X - %d\r\n", DevAddress >> 1, err);
|
||||||
bool res = err == SUCCESS;
|
bool res = err == SUCCESS;
|
||||||
if (!res) {
|
if (!res) {
|
||||||
I2C_Unstick();
|
I2C_Unstick();
|
||||||
@@ -107,17 +107,20 @@ bool FRToSI2C::writeRegistersBulk(const uint8_t address, const I2C_REG *register
|
|||||||
|
|
||||||
bool FRToSI2C::wakePart(uint16_t DevAddress) {
|
bool FRToSI2C::wakePart(uint16_t DevAddress) {
|
||||||
// wakepart is a special case where only the device address is sent
|
// wakepart is a special case where only the device address is sent
|
||||||
if (!lock())
|
return false; // TODO
|
||||||
return false;
|
|
||||||
|
|
||||||
|
if (!lock()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
uint8_t temp[1] = {0};
|
||||||
I2C_Transfer_Cfg i2cCfg = {0, DISABLE, 0, 0, 0, 0};
|
I2C_Transfer_Cfg i2cCfg = {0, DISABLE, 0, 0, 0, 0};
|
||||||
BL_Err_Type err = ERROR;
|
BL_Err_Type err = ERROR;
|
||||||
i2cCfg.slaveAddr = DevAddress >> 1;
|
i2cCfg.slaveAddr = DevAddress >> 1;
|
||||||
i2cCfg.stopEveryByte = DISABLE;
|
i2cCfg.stopEveryByte = DISABLE;
|
||||||
i2cCfg.subAddr = 0;
|
i2cCfg.subAddr = 0;
|
||||||
i2cCfg.dataSize = 0;
|
i2cCfg.dataSize = 1;
|
||||||
i2cCfg.data = 0;
|
i2cCfg.data = temp;
|
||||||
i2cCfg.subAddrSize = 0; // one byte address
|
i2cCfg.subAddrSize = 0;
|
||||||
|
|
||||||
err = I2C_MasterReceiveBlocking(I2C0_ID, &i2cCfg);
|
err = I2C_MasterReceiveBlocking(I2C0_ID, &i2cCfg);
|
||||||
MSG((char *)"I2C wakePart %02X - %d\r\n", DevAddress >> 1, err);
|
MSG((char *)"I2C wakePart %02X - %d\r\n", DevAddress >> 1, err);
|
||||||
@@ -126,5 +129,6 @@ bool FRToSI2C::wakePart(uint16_t DevAddress) {
|
|||||||
I2C_Unstick();
|
I2C_Unstick();
|
||||||
}
|
}
|
||||||
unlock();
|
unlock();
|
||||||
|
MSG((char *)"I2C probe done \r\n");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,22 +177,36 @@ void setTipPWM(const uint8_t pulse, const bool shouldUseFastModePWM) {
|
|||||||
}
|
}
|
||||||
extern osThreadId POWTaskHandle;
|
extern osThreadId POWTaskHandle;
|
||||||
|
|
||||||
// void EXTI5_9_IRQHandler(void) {
|
void GPIO_IRQHandler(void) {
|
||||||
// // #if POW_PD
|
if (SET == GLB_Get_GPIO_IntStatus(FUSB302_IRQ_GLB_Pin)) {
|
||||||
// // if (RESET != exti_interrupt_flag_get(EXTI_5)) {
|
GLB_GPIO_IntClear(FUSB302_IRQ_GLB_Pin, SET);
|
||||||
// // exti_interrupt_flag_clear(EXTI_5);
|
MSG((char *)"GPIO IRQ FUSB\r\n");
|
||||||
|
#if POW_PD
|
||||||
|
if (POWTaskHandle != nullptr) {
|
||||||
|
MSG((char *)"Wake FUSB\r\n");
|
||||||
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
xTaskNotifyFromISR(POWTaskHandle, 1, eSetBits, &xHigherPriorityTaskWoken);
|
||||||
|
/* Force a context switch if xHigherPriorityTaskWoken is now set to pdTRUE.
|
||||||
|
The macro used to do this is dependent on the port and may be called
|
||||||
|
portEND_SWITCHING_ISR. */
|
||||||
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// // if (POWTaskHandle != nullptr) {
|
/* timeout check */
|
||||||
// // BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
uint32_t timeOut = 32;
|
||||||
// // xTaskNotifyFromISR(POWTaskHandle, 1, eSetBits, &xHigherPriorityTaskWoken);
|
|
||||||
// // /* Force a context switch if xHigherPriorityTaskWoken is now set to pdTRUE.
|
do {
|
||||||
// // The macro used to do this is dependent on the port and may be called
|
timeOut--;
|
||||||
// // portEND_SWITCHING_ISR. */
|
} while ((SET == GLB_Get_GPIO_IntStatus(FUSB302_IRQ_GLB_Pin)) && timeOut);
|
||||||
// // portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
|
||||||
// // }
|
if (!timeOut) {
|
||||||
// // }
|
// MSG("WARNING: Clear GPIO interrupt status fail.\r\n");
|
||||||
// // #endif
|
}
|
||||||
// }
|
|
||||||
|
GLB_GPIO_IntClear(FUSB302_IRQ_GLB_Pin, RESET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool getFUS302IRQLow() {
|
bool getFUS302IRQLow() {
|
||||||
// Return true if the IRQ line is still held low
|
// Return true if the IRQ line is still held low
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ extern "C" {
|
|||||||
void timer0_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state);
|
void timer0_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state);
|
||||||
void adc_fifo_irq(void);
|
void adc_fifo_irq(void);
|
||||||
void start_adc_misc(void);
|
void start_adc_misc(void);
|
||||||
|
void GPIO_IRQHandler(void);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#define QC_DM_HIGH_Pin GPIO_PIN_6
|
#define QC_DM_HIGH_Pin GPIO_PIN_6
|
||||||
|
|
||||||
#define FUSB302_IRQ_Pin GPIO_PIN_16
|
#define FUSB302_IRQ_Pin GPIO_PIN_16
|
||||||
|
#define FUSB302_IRQ_GLB_Pin GLB_GPIO_PIN_16
|
||||||
|
|
||||||
// uart
|
// uart
|
||||||
#define UART_TX_Pin GPIO_PIN_22
|
#define UART_TX_Pin GPIO_PIN_22
|
||||||
|
|||||||
@@ -98,7 +98,19 @@ void setup_slow_PWM() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setupFUSBIRQ() {
|
void setupFUSBIRQ() {
|
||||||
// #TODO
|
return; // TODO
|
||||||
|
|
||||||
|
MSG((char *)"Setting up FUSB IRQ\r\n");
|
||||||
|
gpio_set_mode(FUSB302_IRQ_Pin, GPIO_SYNC_FALLING_TRIGER_INT_MODE);
|
||||||
|
MSG((char *)"Setting up FUSB IRQ1r\n");
|
||||||
|
CPU_Interrupt_Disable(GPIO_INT0_IRQn);
|
||||||
|
MSG((char *)"Setting up FUSB IRQ2\r\n");
|
||||||
|
Interrupt_Handler_Register(GPIO_INT0_IRQn, GPIO_IRQHandler);
|
||||||
|
MSG((char *)"Setting up FUSB IRQ3\r\n");
|
||||||
|
CPU_Interrupt_Enable(GPIO_INT0_IRQn);
|
||||||
|
|
||||||
|
MSG((char *)"Setting up FUSB IRQ4\r\n");
|
||||||
|
gpio_irq_enable(FUSB302_IRQ_Pin, ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vAssertCalled(void) {
|
void vAssertCalled(void) {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
void preRToSInit() {
|
void preRToSInit() {
|
||||||
// Normal system bringup -- GPIO etc
|
// Normal system bringup -- GPIO etc
|
||||||
// #TODO
|
|
||||||
bflb_platform_init(0);
|
bflb_platform_init(0);
|
||||||
|
|
||||||
hardware_init();
|
hardware_init();
|
||||||
|
|||||||
@@ -800,15 +800,15 @@ void showDebugMenu(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showWarnings() {
|
void showWarnings() {
|
||||||
// MSG((char *)"showWarningsshowWarnings\r\n");
|
MSG((char *)"showWarningsshowWarnings\r\n");
|
||||||
return;
|
return;
|
||||||
// Display alert if settings were reset
|
// Display alert if settings were reset
|
||||||
if (settingsWereReset) {
|
if (settingsWereReset) {
|
||||||
// MSG((char *)"WarnUser - %ld\r\n\r\n", (uint64_t)Tr);
|
MSG((char *)"WarnUser - %ld\r\n\r\n", (uint64_t)Tr);
|
||||||
// MSG((char *)"WarnUser - %ld\r\n\r\n", (uint64_t)Tr);
|
MSG((char *)"WarnUser - %ld\r\n\r\n", (uint64_t)Tr);
|
||||||
// MSG((char *)"WarnUser - %ld\r\n\r\n", (uint64_t)Tr);
|
MSG((char *)"WarnUser - %ld\r\n\r\n", (uint64_t)Tr);
|
||||||
// MSG((char *)"WarnUser - %ld\r\n\r\n", (uint64_t)Tr);
|
MSG((char *)"WarnUser - %ld\r\n\r\n", (uint64_t)Tr);
|
||||||
// MSG((char *)"WarnUser - %ld\r\n\r\n", (uint64_t)Tr);
|
MSG((char *)"WarnUser - %ld\r\n\r\n", (uint64_t)Tr);
|
||||||
|
|
||||||
warnUser(translatedString(Tr->SettingsResetMessage), 10 * TICKS_SECOND);
|
warnUser(translatedString(Tr->SettingsResetMessage), 10 * TICKS_SECOND);
|
||||||
}
|
}
|
||||||
@@ -817,7 +817,7 @@ void showWarnings() {
|
|||||||
// In this case though, we dont want to nag the user _too_ much
|
// In this case though, we dont want to nag the user _too_ much
|
||||||
// So only show first 2 times
|
// So only show first 2 times
|
||||||
while (DetectedAccelerometerVersion == AccelType::Scanning) {
|
while (DetectedAccelerometerVersion == AccelType::Scanning) {
|
||||||
// MSG((char *)"Accel Detect");
|
MSG((char *)"Accel Detect");
|
||||||
osDelay(5);
|
osDelay(5);
|
||||||
}
|
}
|
||||||
// Display alert if accelerometer is not detected
|
// Display alert if accelerometer is not detected
|
||||||
@@ -847,14 +847,14 @@ uint8_t disconnectedTipF[sizeof(disconnectedTip)];
|
|||||||
/* StartGUITask function */
|
/* StartGUITask function */
|
||||||
void startGUITask(void const *argument) {
|
void startGUITask(void const *argument) {
|
||||||
(void)argument;
|
(void)argument;
|
||||||
// MSG((char *)"startGUITask\r\n");
|
MSG((char *)"startGUITask\r\n");
|
||||||
prepareTranslations();
|
prepareTranslations();
|
||||||
// MSG((char *)"OLEDInit\r\n");
|
MSG((char *)"OLEDInit\r\n");
|
||||||
|
|
||||||
OLED::initialize(); // start up the LCD
|
OLED::initialize(); // start up the LCD
|
||||||
// MSG((char *)"setBrightness\r\n");
|
MSG((char *)"setBrightness\r\n");
|
||||||
OLED::setBrightness(getSettingValue(SettingsOptions::OLEDBrightness));
|
OLED::setBrightness(getSettingValue(SettingsOptions::OLEDBrightness));
|
||||||
// MSG((char *)"setInverseDisplay\r\n");
|
MSG((char *)"setInverseDisplay\r\n");
|
||||||
OLED::setInverseDisplay(getSettingValue(SettingsOptions::OLEDInversion));
|
OLED::setInverseDisplay(getSettingValue(SettingsOptions::OLEDInversion));
|
||||||
|
|
||||||
uint8_t tempWarningState = 0;
|
uint8_t tempWarningState = 0;
|
||||||
@@ -862,7 +862,7 @@ void startGUITask(void const *argument) {
|
|||||||
bool tempOnDisplay = false;
|
bool tempOnDisplay = false;
|
||||||
bool tipDisconnectedDisplay = false;
|
bool tipDisconnectedDisplay = false;
|
||||||
bool showExitMenuTransition = false;
|
bool showExitMenuTransition = false;
|
||||||
// MSG((char *)"flip\r\n");
|
MSG((char *)"flip\r\n");
|
||||||
|
|
||||||
{
|
{
|
||||||
// Generate the flipped screen into ram for later use
|
// Generate the flipped screen into ram for later use
|
||||||
@@ -875,24 +875,24 @@ void startGUITask(void const *argument) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// MSG((char *)"tipTemp\r\n");
|
MSG((char *)"tipTemp\r\n");
|
||||||
|
|
||||||
getTipRawTemp(1); // reset filter
|
getTipRawTemp(1); // reset filter
|
||||||
// MSG((char *)"setRotation\r\n");
|
MSG((char *)"setRotation\r\n");
|
||||||
|
|
||||||
OLED::setRotation(getSettingValue(SettingsOptions::OrientationMode) & 1);
|
OLED::setRotation(getSettingValue(SettingsOptions::OrientationMode) & 1);
|
||||||
// MSG((char *)"Bootlogo\r\n");
|
MSG((char *)"Bootlogo\r\n");
|
||||||
|
|
||||||
// BootLogo::handleShowingLogo((uint8_t *)FLASH_LOGOADDR);
|
// BootLogo::handleShowingLogo((uint8_t *)FLASH_LOGOADDR);
|
||||||
// MSG((char *)"showWarnings\r\n");
|
MSG((char *)"showWarnings\r\n");
|
||||||
showWarnings();
|
showWarnings();
|
||||||
// MSG((char *)"AutoStartMode\r\n");
|
MSG((char *)"AutoStartMode\r\n");
|
||||||
if (getSettingValue(SettingsOptions::AutoStartMode)) {
|
if (getSettingValue(SettingsOptions::AutoStartMode)) {
|
||||||
// jump directly to the autostart mode
|
// jump directly to the autostart mode
|
||||||
gui_solderingMode(getSettingValue(SettingsOptions::AutoStartMode) - 1);
|
gui_solderingMode(getSettingValue(SettingsOptions::AutoStartMode) - 1);
|
||||||
buttonLockout = true;
|
buttonLockout = true;
|
||||||
}
|
}
|
||||||
// MSG((char *)"GUI Thread Start\r\n");
|
MSG((char *)"GUI Thread Start\r\n");
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ButtonState buttons = getButtonState();
|
ButtonState buttons = getButtonState();
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ void startPOWTask(void const *argument __unused) {
|
|||||||
#endif
|
#endif
|
||||||
BaseType_t res;
|
BaseType_t res;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
MSG((char *)"POW Spin\r\n");
|
||||||
res = pdFALSE;
|
res = pdFALSE;
|
||||||
// While the interrupt is low, dont delay
|
// While the interrupt is low, dont delay
|
||||||
/*This is due to a possible race condition, where:
|
/*This is due to a possible race condition, where:
|
||||||
|
|||||||
Reference in New Issue
Block a user