Comments to source code

This commit is contained in:
Andreas Mieke 2018-04-03 17:18:28 +02:00
parent d109bae8d7
commit 9a18bd88f0
22 changed files with 286 additions and 122 deletions

View file

@ -5,12 +5,15 @@ uint8_t running = 0;
void USART3_IRQHandler(void)
{
// HAndle only USART3 RXNE interrupt
if (USART_GetITStatus(USART3, USART_IT_RXNE) == SET) {
// Get display state
state = (disp_state_t)((USART_ReceiveData(USART3) & 0x00FF) - '0');
if (state > 4) {
state = DISP_STATE_NONE;
}
}
// Set running according to pressed button
if (state == DISP_STATE_START) {
running = 1;
} else if (state == DISP_STATE_PAUSE) {
@ -20,8 +23,10 @@ void USART3_IRQHandler(void)
void disp_init(void)
{
// Init USART3
usart3_init();
// Init USART3 interrupt
NVIC_InitTypeDef nvic;
nvic.NVIC_IRQChannel = USART3_IRQn;
nvic.NVIC_IRQChannelCmd = ENABLE;
@ -30,11 +35,13 @@ void disp_init(void)
NVIC_Init(&nvic);
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
// Disable display till startup is complete
disp_disable();
}
disp_state_t disp_get_last_state(void)
{
// Returns the last state (which we got form the interrupt)
disp_state_t tmp = state;
state = DISP_STATE_NONE;
return tmp;
@ -44,16 +51,19 @@ void disp_send_gyro_data(uint8_t X, uint8_t Y, uint8_t Z)
{
char __str[128] = {0};
char *str = __str;
// Print gyro data to the display
sprintf(str, "add 1,0,%d\xFF\xFF\xFF" "add 1,1,%d\xFF\xFF\xFF" "add 1,2,%d\xFF\xFF\xFF", X, Y, Z);
USART_SendString(USART3, str);
}
void disp_disable(void)
{
// Disable (dim to 0%) display
USART_SendString(USART3, "dim=0\xFF\xFF\xFF");
}
void disp_enable(void)
{
// Enable display again (dim to 100%)
USART_SendString(USART3, "dim=100\xFF\xFF\xFF");
}