mirror of
https://github.com/EFeru/hoverboard-sideboard-hack-GD.git
synced 2025-07-27 09:39:33 +00:00
Minor visual arrangements
This commit is contained in:
parent
1e7bf7cd90
commit
19aee79e57
@ -69,8 +69,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#define USART_MAIN_BAUD 38400 // [bit/s] MAIN Serial Tx/Rx baud rate
|
#define USART_MAIN_BAUD 38400 // [bit/s] MAIN Serial Tx/Rx baud rate
|
||||||
#define SERIAL_START_FRAME 0xABCD // [-] Start frame definition for reliable serial communication
|
#define SERIAL_START_FRAME 0xABCD // [-] Start frame definition for reliable serial communication
|
||||||
#define SERIAL_TIMEOUT 500 // [-] Number of wrong received data for Serial timeout detection. Depends on DELAY_IN_MAIN_LOOP
|
|
||||||
#define SERIAL_BUFFER_SIZE 64 // [bytes] Size of Serial Rx buffer. Make sure it is always larger than the 'Feedback' structure size
|
#define SERIAL_BUFFER_SIZE 64 // [bytes] Size of Serial Rx buffer. Make sure it is always larger than the 'Feedback' structure size
|
||||||
|
#define SERIAL_TIMEOUT 600 // [-] Number of wrong received data for Serial timeout detection. Depends on DELAY_IN_MAIN_LOOP
|
||||||
|
|
||||||
|
|
||||||
/* ==================================== SETTINGS AUX ==================================== */
|
/* ==================================== SETTINGS AUX ==================================== */
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
// Includes
|
// Includes
|
||||||
#include "gd32f1x0.h"
|
#include "gd32f1x0.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
#if defined(PRINTF_FLOAT_SUPPORT) && defined(SERIAL_DEBUG) && defined(__GNUC__)
|
#if defined(PRINTF_FLOAT_SUPPORT) && defined(SERIAL_DEBUG) && defined(__GNUC__)
|
||||||
asm(".global _printf_float"); // this is the magic trick for printf to support float. Warning: It will increase code considerably! Better to avoid!
|
asm(".global _printf_float"); // this is the magic trick for printf to support float. Warning: It will increase code considerably! Better to avoid!
|
||||||
@ -179,4 +180,4 @@ typedef struct {
|
|||||||
int16_t temp;
|
int16_t temp;
|
||||||
} MPU_Data;
|
} MPU_Data;
|
||||||
|
|
||||||
#endif
|
#endif // DEFINES_H
|
||||||
|
54
Inc/util.h
54
Inc/util.h
@ -22,45 +22,9 @@
|
|||||||
#define UTIL_H
|
#define UTIL_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "gd32f1x0.h"
|
|
||||||
#include "defines.h"
|
|
||||||
|
|
||||||
|
|
||||||
extern volatile int8_t i2c_status;
|
/* Rx Structures USART */
|
||||||
extern volatile i2c_cmd i2c_ReadWriteCmd;
|
|
||||||
extern volatile uint8_t i2c_slaveAddress;
|
|
||||||
extern volatile uint8_t i2c_regAddress;
|
|
||||||
extern volatile uint8_t* i2c_txbuffer;
|
|
||||||
extern volatile uint8_t* i2c_rxbuffer;
|
|
||||||
extern volatile uint8_t i2c_nDABytes;
|
|
||||||
extern volatile int8_t i2c_nRABytes;
|
|
||||||
|
|
||||||
#ifdef AUX45_USE_I2C
|
|
||||||
extern volatile int8_t i2c_aux_status;
|
|
||||||
extern volatile i2c_cmd i2c_aux_ReadWriteCmd;
|
|
||||||
extern volatile uint8_t i2c_aux_slaveAddress;
|
|
||||||
extern volatile uint8_t i2c_aux_regAddress;
|
|
||||||
extern volatile uint8_t* i2c_aux_txbuffer;
|
|
||||||
extern volatile uint8_t* i2c_aux_rxbuffer;
|
|
||||||
extern volatile uint8_t i2c_aux_nDABytes;
|
|
||||||
extern volatile int8_t i2c_aux_nRABytes;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* general functions */
|
|
||||||
void consoleLog(char *message);
|
|
||||||
void toggle_led(uint32_t gpio_periph, uint32_t pin);
|
|
||||||
void intro_demo_led(uint32_t tDelay);
|
|
||||||
|
|
||||||
/* input initialization function */
|
|
||||||
void input_init(void);
|
|
||||||
|
|
||||||
/* usart read functions */
|
|
||||||
void usart_rx_check(void);
|
|
||||||
|
|
||||||
#ifdef SERIAL_DEBUG
|
|
||||||
void usart_process_debug(uint8_t *userCommand, uint32_t len);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SERIAL_CONTROL
|
#ifdef SERIAL_CONTROL
|
||||||
typedef struct{
|
typedef struct{
|
||||||
uint16_t start;
|
uint16_t start;
|
||||||
@ -83,6 +47,22 @@ typedef struct{
|
|||||||
uint16_t cmdLed;
|
uint16_t cmdLed;
|
||||||
uint16_t checksum;
|
uint16_t checksum;
|
||||||
} SerialFeedback;
|
} SerialFeedback;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* general functions */
|
||||||
|
void consoleLog(char *message);
|
||||||
|
void toggle_led(uint32_t gpio_periph, uint32_t pin);
|
||||||
|
void intro_demo_led(uint32_t tDelay);
|
||||||
|
|
||||||
|
/* input initialization function */
|
||||||
|
void input_init(void);
|
||||||
|
|
||||||
|
/* usart read functions */
|
||||||
|
void usart_rx_check(void);
|
||||||
|
#ifdef SERIAL_DEBUG
|
||||||
|
void usart_process_debug(uint8_t *userCommand, uint32_t len);
|
||||||
|
#endif
|
||||||
|
#ifdef SERIAL_FEEDBACK
|
||||||
void usart_process_data(SerialFeedback *Feedback_in, SerialFeedback *Feedback_out);
|
void usart_process_data(SerialFeedback *Feedback_in, SerialFeedback *Feedback_out);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
22
Src/i2c_it.c
22
Src/i2c_it.c
@ -20,9 +20,29 @@
|
|||||||
|
|
||||||
#include "gd32f1x0_i2c.h"
|
#include "gd32f1x0_i2c.h"
|
||||||
#include "i2c_it.h"
|
#include "i2c_it.h"
|
||||||
#include "util.h"
|
|
||||||
#include "systick.h"
|
#include "systick.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "defines.h"
|
||||||
|
|
||||||
|
extern volatile int8_t i2c_status;
|
||||||
|
extern volatile i2c_cmd i2c_ReadWriteCmd;
|
||||||
|
extern volatile uint8_t i2c_slaveAddress;
|
||||||
|
extern volatile uint8_t i2c_regAddress;
|
||||||
|
extern volatile uint8_t* i2c_txbuffer;
|
||||||
|
extern volatile uint8_t* i2c_rxbuffer;
|
||||||
|
extern volatile uint8_t i2c_nDABytes;
|
||||||
|
extern volatile int8_t i2c_nRABytes;
|
||||||
|
|
||||||
|
#ifdef AUX45_USE_I2C
|
||||||
|
extern volatile int8_t i2c_aux_status;
|
||||||
|
extern volatile i2c_cmd i2c_aux_ReadWriteCmd;
|
||||||
|
extern volatile uint8_t i2c_aux_slaveAddress;
|
||||||
|
extern volatile uint8_t i2c_aux_regAddress;
|
||||||
|
extern volatile uint8_t* i2c_aux_txbuffer;
|
||||||
|
extern volatile uint8_t* i2c_aux_rxbuffer;
|
||||||
|
extern volatile uint8_t i2c_aux_nDABytes;
|
||||||
|
extern volatile int8_t i2c_aux_nRABytes;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void I2C0_EventIRQ_Handler(void)
|
void I2C0_EventIRQ_Handler(void)
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
// Global variables
|
// Global variables
|
||||||
extern volatile ErrStatus status;
|
|
||||||
|
|
||||||
// Private variables
|
// Private variables
|
||||||
static rcu_periph_enum USART_CLK[USARTn] = { USART_AUX_CLK,
|
static rcu_periph_enum USART_CLK[USARTn] = { USART_AUX_CLK,
|
||||||
|
@ -36,6 +36,7 @@ SerialSideboard Sideboard;
|
|||||||
#if defined(SERIAL_DEBUG) || defined(SERIAL_FEEDBACK)
|
#if defined(SERIAL_DEBUG) || defined(SERIAL_FEEDBACK)
|
||||||
static uint8_t rx_buffer[SERIAL_BUFFER_SIZE]; // USART Rx DMA circular buffer
|
static uint8_t rx_buffer[SERIAL_BUFFER_SIZE]; // USART Rx DMA circular buffer
|
||||||
static uint32_t rx_buffer_len = ARRAY_LEN(rx_buffer);
|
static uint32_t rx_buffer_len = ARRAY_LEN(rx_buffer);
|
||||||
|
static uint32_t old_pos;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SERIAL_FEEDBACK
|
#ifdef SERIAL_FEEDBACK
|
||||||
@ -178,7 +179,6 @@ void input_init(void) {
|
|||||||
void usart_rx_check(void)
|
void usart_rx_check(void)
|
||||||
{
|
{
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
static uint32_t old_pos;
|
|
||||||
uint32_t pos;
|
uint32_t pos;
|
||||||
|
|
||||||
pos = rx_buffer_len - dma_transfer_number_get(DMA_CH4); // Calculate current position in buffer
|
pos = rx_buffer_len - dma_transfer_number_get(DMA_CH4); // Calculate current position in buffer
|
||||||
@ -199,7 +199,6 @@ void usart_rx_check(void)
|
|||||||
#endif // SERIAL_DEBUG
|
#endif // SERIAL_DEBUG
|
||||||
|
|
||||||
#ifdef SERIAL_FEEDBACK
|
#ifdef SERIAL_FEEDBACK
|
||||||
static uint32_t old_pos;
|
|
||||||
uint32_t pos;
|
uint32_t pos;
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user