Add debug LED status light
This commit is contained in:
parent
7868d2f7b7
commit
05611c0697
@ -3,6 +3,7 @@
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
#include "gpio.h"
|
||||
#include "usbd_cdc.h"
|
||||
#include "usbd_def.h"
|
||||
|
||||
@ -82,6 +83,11 @@ class VirtualComPort {
|
||||
return hcdc->TxState != 0;
|
||||
};
|
||||
|
||||
#ifndef NDEBUG
|
||||
HAL_GPIO_WritePin(GREEN_LED_GPIO_Port, GREEN_LED_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(BLUE_LED_GPIO_Port, BLUE_LED_Pin, GPIO_PIN_RESET);
|
||||
#endif
|
||||
|
||||
while(usbReady())
|
||||
;
|
||||
|
||||
@ -91,6 +97,10 @@ class VirtualComPort {
|
||||
|
||||
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, const_cast<uint8_t*>(m_usbAsyncTxBuffer.data), m_usbAsyncTxBuffer.size);
|
||||
USBD_CDC_TransmitPacket(&hUsbDeviceFS);
|
||||
|
||||
#ifndef NDEBUG
|
||||
HAL_GPIO_WritePin(BLUE_LED_GPIO_Port, BLUE_LED_Pin, GPIO_PIN_SET);
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
@ -107,6 +117,12 @@ class VirtualComPort {
|
||||
|
||||
static int8_t CdcInit()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
HAL_GPIO_WritePin(RED_LED_GPIO_Port, RED_LED_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(GREEN_LED_GPIO_Port, GREEN_LED_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(BLUE_LED_GPIO_Port, BLUE_LED_Pin, GPIO_PIN_SET);
|
||||
#endif
|
||||
|
||||
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, const_cast<uint8_t*>(m_txBuffer.data), 0);
|
||||
USBD_CDC_SetRxBuffer(&hUsbDeviceFS, const_cast<uint8_t*>(m_usbAsyncRxBuffer.data));
|
||||
return USBD_OK;
|
||||
@ -114,6 +130,12 @@ class VirtualComPort {
|
||||
|
||||
static int8_t CdcDeInit()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
HAL_GPIO_WritePin(RED_LED_GPIO_Port, RED_LED_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GREEN_LED_GPIO_Port, GREEN_LED_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(BLUE_LED_GPIO_Port, BLUE_LED_Pin, GPIO_PIN_SET);
|
||||
#endif
|
||||
|
||||
m_txBuffer.size = 0;
|
||||
m_usbAsyncTxBuffer.size = 0;
|
||||
m_rxBuffer.head = 0;
|
||||
@ -176,6 +198,11 @@ class VirtualComPort {
|
||||
|
||||
static int8_t CdcReceive([[maybe_unused]] uint8_t* buf, uint32_t* length)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
HAL_GPIO_WritePin(GREEN_LED_GPIO_Port, GREEN_LED_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(RED_LED_GPIO_Port, RED_LED_Pin, GPIO_PIN_RESET);
|
||||
#endif
|
||||
|
||||
if(USBD_CDC_ReceivePacket(&hUsbDeviceFS) != USBD_OK)
|
||||
return USBD_FAIL;
|
||||
|
||||
@ -187,6 +214,10 @@ class VirtualComPort {
|
||||
rxHandler(m_usbAsyncRxBuffer.data[i]);
|
||||
}
|
||||
m_receiving = false;
|
||||
|
||||
#ifndef NDEBUG
|
||||
HAL_GPIO_WritePin(RED_LED_GPIO_Port, RED_LED_Pin, GPIO_PIN_SET);
|
||||
#endif
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
|
@ -22,20 +22,18 @@ static inline void initializeHardware()
|
||||
terminal.init();
|
||||
HAL_GPIO_WritePin(RED_LED_GPIO_Port, RED_LED_Pin, g_error ? GPIO_PIN_RESET : GPIO_PIN_SET);
|
||||
} while(g_error);
|
||||
|
||||
HAL_Delay(1000);
|
||||
|
||||
HAL_GPIO_WritePin(RED_LED_GPIO_Port, RED_LED_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(GREEN_LED_GPIO_Port, GREEN_LED_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(BLUE_LED_GPIO_Port, BLUE_LED_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
initializeHardware();
|
||||
|
||||
HAL_GPIO_WritePin(RED_LED_GPIO_Port, RED_LED_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(GREEN_LED_GPIO_Port, GREEN_LED_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(BLUE_LED_GPIO_Port, BLUE_LED_Pin, GPIO_PIN_SET);
|
||||
HAL_Delay(1000);
|
||||
HAL_GPIO_WritePin(RED_LED_GPIO_Port, RED_LED_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(GREEN_LED_GPIO_Port, GREEN_LED_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(BLUE_LED_GPIO_Port, BLUE_LED_Pin, GPIO_PIN_SET);
|
||||
|
||||
terminal_t terminal;
|
||||
|
||||
while(true) {
|
||||
|
Loading…
Reference in New Issue
Block a user