Skip to content

Commit

Permalink
Make LED references board-independent
Browse files Browse the repository at this point in the history
  • Loading branch information
lains committed Feb 7, 2024
1 parent af4b66c commit e3b3aa3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
19 changes: 19 additions & 0 deletions inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@
#include "stm32469i_discovery_qspi.h"
#endif

#ifdef USE_STM32469I_DISCOVERY
#define LED_GREEN LED1
#define LED_ORANGE LED2
#define LED_RED LED3
#define LED_BLUE LED4
#endif
#ifdef LED_BLUE
#define LED_LCD_REFRESH LED_BLUE
#endif
#ifdef LED_RED
#define LED_ERROR LED_RED
#endif
#ifdef LED_ORANGE
#define LED_SERIAL_RX LED_ORANGE
#endif
#ifdef LED_GREEN
#define LED_TIC_FRAME_RX LED_GREEN
#endif

void Error_Handler(void);
void OnError_Handler(uint32_t condition);

Expand Down
8 changes: 6 additions & 2 deletions src/hal/Stm32LcdDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,16 @@ void HAL_DSI_EndOfRefreshCallback(DSI_HandleTypeDef *hdsi) {
if (Stm32LcdDriver::get().displayState == Stm32LcdDriver::SwitchToDraftIsPending) {
set_active_fb(Stm32LcdDriver::get().draftFramebuffer);
Stm32LcdDriver::get().displayState = Stm32LcdDriver::DisplayingDraft;
BSP_LED_Off(LED4);
#ifdef LED_LCD_REFRESH
BSP_LED_Off(LED_LCD_REFRESH);
#endif
}
else if (Stm32LcdDriver::get().displayState == Stm32LcdDriver::SwitchToFinalIsPending) {
set_active_fb(Stm32LcdDriver::get().finalFramebuffer);
Stm32LcdDriver::get().displayState = Stm32LcdDriver::DisplayingFinal;
BSP_LED_On(LED4);
#ifdef LED_LCD_REFRESH
BSP_LED_On(LED_LCD_REFRESH);
#endif
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/hal/Stm32SerialDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef* huart)
if (huart->Instance==USART6) {
unsigned char Received_Data = UART6_rxBuffer[0];
onTicUartRx((uint8_t)Received_Data);
BSP_LED_Toggle(LED3); // Toggle the orange LED when new serial data is received on the TIC UART
#ifdef LED_SERIAL_RX
BSP_LED_Toggle(LED_SERIAL_RX); // Toggle the orange LED when new serial data is received on the TIC UART
#endif
UART6_Enable_interrupt_callback(huart);
}
}
Expand Down
22 changes: 13 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ const unsigned int BytesPerPixel = 4; /* For ARGB8888 mode */
void OnError_Handler(uint32_t condition)
{
if(condition) {
BSP_LED_On(LED2);
#ifdef LED_ERROR
BSP_LED_On(LED_ERROR);
#endif
while(1) { ; } /* Blocking on error */
}
}
Expand Down Expand Up @@ -111,16 +113,16 @@ int main(void) {
/* Configure the system clock to 180 MHz */
SystemClock_Config();

/* Configure LED1, LED2, LED3 and LED4 on USE_STM32469I_DISCOVERY */
/* Configure the 4 available LEDs on USE_STM32469I_DISCOVERY */
#ifdef USE_STM32469I_DISCOVERY
BSP_LED_Init(LED1);
BSP_LED_Init(LED2);
BSP_LED_Init(LED3);
BSP_LED_Init(LED4);
BSP_LED_Init(LED_GREEN);
BSP_LED_Init(LED_RED);
BSP_LED_Init(LED_ORANGE);
BSP_LED_Init(LED_BLUE);
#endif
BSP_LED_On(LED2);
BSP_LED_On(LED_ORANGE);
waitDelay(250);
BSP_LED_Off(LED2);
BSP_LED_Off(LED_ORANGE);

/* Initialize the SDRAM */
BSP_SDRAM_Init();
Expand All @@ -143,7 +145,9 @@ int main(void) {
TicFrameParser ticParser(PowerHistory::unWrapOnNewPowerData, (void *)(&powerHistory));

auto onFrameCompleteBlinkGreenLedAndInvokeHandler = [](void* context) {
BSP_LED_Toggle(LED1); // Toggle the green LED when a frame has been completely received
#ifdef LED_TIC_FRAME_RX
BSP_LED_Toggle(LED_TIC_FRAME_RX); // Toggle the green LED when a frame has been completely received
#endif
TicFrameParser::unwrapInvokeOnFrameComplete(context); /* Invoke the frameparser's onFrameComplete handler */
};

Expand Down

0 comments on commit e3b3aa3

Please sign in to comment.