You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
47 lines
1.3 KiB
#include "r_cg_macrodriver.h"
|
|
#include "r_cg_serial.h"
|
|
#include "r_cg_adc.h"
|
|
|
|
|
|
|
|
|
|
#define ADC_RESOLUTION 1023.0f // 10-bit ADC
|
|
#define VREF 5.06f // V
|
|
#define RAM_BYTES 13
|
|
#define UART_RX_BUF_SIZE 256
|
|
|
|
// PC(USB, UART1) 출력 전용
|
|
#define PC_PRINT(s) uart1_send_string((s))
|
|
#define PC_PRINT_HEX(v) uart1_send_hex((v))
|
|
|
|
// RS485(UART0) 출력/송신 전용
|
|
#define RS485_PRINT(s) uart_send_string((s))
|
|
#define RS485_PRINT_HEX(v) uart_send_hex((v))
|
|
|
|
extern volatile uint8_t uart_rx_done;
|
|
extern volatile uint8_t uart_rx_index;
|
|
extern volatile uint8_t uart_rx_buffer[UART_RX_BUF_SIZE];
|
|
extern volatile uint16_t uart_rx_length;
|
|
|
|
extern uint8_t g_fixed_addr;
|
|
|
|
#define HOST_PRINT(s) do { \
|
|
if (g_fixed_addr == 0) PC_PRINT(s); \
|
|
else RS485_PRINT(s); \
|
|
} while(0)
|
|
|
|
void uart_send_string(const char *str); // UART0(RS485)
|
|
void uart_send_hex(uint8_t val); // UART0(RS485)
|
|
|
|
void uart1_send_string(const char *str); // UART1(PC)
|
|
void uart1_send_hex(uint8_t val); // UART1(PC)
|
|
|
|
//void UART0_ReceiveHandler(void);
|
|
void ADC_ReadAndSend_UART(void);
|
|
void cmd_enter_command_mode(const unsigned char *d, unsigned int len);
|
|
void cmd_unknown(const unsigned char *d, unsigned int len);
|
|
|
|
// RS485 EN(P45)
|
|
void rs485_init(void);
|
|
void rs485_set_tx(uint8_t on);
|
|
|
|
|