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