14 #include "../../../src/ISUtilities.h" 15 #include "../../../src/ISLogger.h" 16 #include "../../../hw-libs/misc/bootloaderApp.h" 17 #include "../drivers/d_quadEnc.h" 24 #include "../hw-libs/communications/CAN_comm.h" 25 #include "../src/protocol_nmea.h" 38 #define COM_RX_PORT_COUNT (EVB2_PORT_COUNT-1) // exclude CAN port 46 int comWrite(
int serialNum,
const unsigned char *buf,
int size, uint32_t ledPin )
55 len =
serWrite(serialNum, buf, size);
65 int comRead(
int serialNum,
unsigned char *buf,
int bufSize, uint32_t ledPin)
75 #if 0 // Wait for end of data. Check Rx buffer has data and hasn't change over 1ms. 78 if(used!=0 && used==usedLast[serialNum])
80 len =
serRead(serialNum, buf, bufSize, 0);
82 usedLast[serialNum] =
used;
85 len =
serRead(serialNum, buf, bufSize);
100 uint32_t stopbits, parity, databits;
341 logger.
LogData(0, &dataHdr, data);
379 bool initCbPreset =
false;
380 bool initIOconfig =
false;
381 bool reinitXBee =
false;
382 bool reinitWiFi =
false;
523 switch (messageIdUInt)
540 switch (messageIdUInt)
545 strncmp((
const char*)(&(comm->
buf.
start[6])),
"!!SAM-BA!!", 6) == 0)
564 #define CAN_COM_PORT 1 565 #define CAN_HDR 0xFC; 566 #define CAN_FTR 0xFE; 581 for(uint8_t *ptr=data; dataSize>0; )
735 if(dstCbf == 0 || len==0)
760 if(sendXbee || sendXradio)
762 sendRadio(buf, len, sendXbee, sendXradio);
780 #if 0 // Disabled when forwarding data directly in wifi task 800 #ifdef CONF_BOARD_SERIAL_XBEE // XBee Rx ======================================================= 804 #ifdef CONF_BOARD_SERIAL_EXT_RADIO // External Radio Rx ======================================================= 808 #ifdef CONF_BOARD_SERIAL_ATWINC_BLE // ATWINC BLE Rx ======================================================= 812 #ifdef CONF_BOARD_SERIAL_SP330 // SP330 RS232/RS422 converter Rx ======================================================= 816 #ifdef CONF_BOARD_SERIAL_GPIO_H8 // H8 Header GPIO TTL Rx ======================================================= 820 #ifdef CONF_BOARD_SPI_ATWINC_WIFI // WiFi Rx ======================================================= 824 #ifdef CONF_BOARD_CAN1 847 const size_t xTriggerLevel = 1;
StreamBufferHandle_t g_xStreamBufferWiFiTx
void uINS_stream_stop_all(is_comm_instance_t &comm)
StreamBufferHandle_t g_xStreamBufferWiFiRx
static uint8_t s_rxDecodeBuffer[PKT_BUF_SIZE]
void enable_bootloader(int pHandle)
#define DID_EVB_DEBUG_ARRAY
int serSetBaudRate(int serialNum, int baudrate)
Change USART baudrate. 0 on success, -1 on failure.
uint32_t cbf[EVB2_PORT_COUNT]
#define UNUSED(v)
Marking v as a unused parameter or value.
int comManagerValidateBaudRate(unsigned int baudRate)
void com_bridge_smart_forward(uint32_t srcPort, uint32_t ledPin)
static void ioport_set_pin_level(ioport_pin_t pin, bool level)
Set an IOPORT pin to a specified logical value.
#define xStreamBufferCreate(xBufferSizeBytes, xTriggerLevelBytes)
int comWrite(int serialNum, const unsigned char *buf, int size, uint32_t ledPin)
#define US_MR_PAR_EVEN
(US_MR) Even parity
#define US_MR_NBSTOP_1_BIT
(US_MR) 1 stop bit
int xbee_runtime_mode(void)
#define UART_XBEE_N_DTR_PIN
uint8_t ssid[WIFI_SSID_PSK_SIZE]
void xbee_step(is_comm_instance_t *comm)
size_t xStreamBufferReceive(StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait) PRIVILEGED_FUNCTION
bool d_usartDMA_callback_cdc_enable(void)
void com_bridge_forward(uint32_t srcPort, uint8_t *buf, int len)
void board_IO_config(void)
int is_comm_get_data(is_comm_instance_t *instance, uint32_t dataId, uint32_t offset, uint32_t size, uint32_t periodMultiple)
StreamBufferHandle_t g_xStreamBufferUINS
uint32_t h4xRadioBaudRate
int serRead(int serialNum, unsigned char *buf, int size)
Read data on USART. Returns number of bytes read. With use of the PDCA ring buffer, buffer overrun may occur if bytes are received is greater than bytes read plus buffer size.
char is_comm_copy_to_struct(void *sptr, const is_comm_instance_t *instance, const unsigned int maxsize)
void d_usartDMA_callback_cdc_disable(void)
#define WIFI_SSID_PSK_SIZE
void sendRadio(uint8_t *data, int dataSize, bool sendXbee, bool sendXrad)
int error_check_config(evb_flash_cfg_t *cfg)
#define US_MR_PAR_NO
(US_MR) No parity
void communications_init(void)
uint8_t psk[WIFI_SSID_PSK_SIZE]
uint32_t flash_write_needed
#define CONF_MCAN_ELEMENT_DATA_SIZE
Parity forced to 1 (mark)
comm_rx_port_t g_comRxPort[COM_RX_PORT_COUNT]
void com_bridge_apply_preset(evb_flash_cfg_t *cfg)
void callback_cdc_set_config(uint8_t port, usb_cdc_line_coding_t *cfg)
#define US_MR_NBSTOP_2_BIT
(US_MR) 2 stop bits
bool LogData(unsigned int device, p_data_hdr_t *dataHdr, const uint8_t *dataBuf)
int spiTouINS_serWrite(const unsigned char *buf, int size)
int is_comm_set_data(is_comm_instance_t *instance, uint32_t dataId, uint32_t offset, uint32_t size, void *data)
void handle_data_from_host(is_comm_instance_t *comm, protocol_type_t ptype)
#define UART_XBEE_N_RTS_PIN
#define STREAM_BUFFER_SIZE
#define US_MR_PAR_MARK
(US_MR) Parity forced to 1 (Mark)
int is_comm_free(is_comm_instance_t *instance)
void refresh_CFG_LED(void)
#define US_MR_CHRL_8_BIT
(US_MR) Character length is 8 bits
#define US_MR_PAR_ODD
(US_MR) Odd parity
uint32_t g_uInsBootloaderEnableTimeMs
void uINS_stream_enable_PPD(is_comm_instance_t &comm)
#define DATA_CHUNK_MARKER
void callback_cdc_set_dtr(uint8_t port, bool b_enable)
int comRead(int serialNum, unsigned char *buf, int bufSize, uint32_t ledPin)
USBInterfaceDescriptor data
evb_server_t server[NUM_WIFI_PRESETS]
void is_comm_init(is_comm_instance_t *instance, uint8_t *buffer, int bufferSize)
#define DID_EVB_FLASH_CFG
void update_flash_cfg(evb_flash_cfg_t &newCfg)
#define EVB_CFG_BITS_IDX_SERVER(bits)
evb_flash_cfg_t * g_flashCfg
void enable_bootloader_assistant(void)
uint32_t flash_write_enable
#define ASCII_MESSAGEID_TO_UINT(c4)
size_t xStreamBufferSend(StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait) PRIVILEGED_FUNCTION
uint8_t mcan_receive_message(uint32_t *id_value, uint8_t *data)
void step_com_bridge(is_comm_instance_t &comm)
void * StreamBufferHandle_t
protocol_type_t is_comm_parse(is_comm_instance_t *instance)
int is_comm_data(is_comm_instance_t *instance, uint32_t dataId, uint32_t offset, uint32_t size, void *data)
Autogenerated API include file for the Atmel Software Framework (ASF)
#define RMC_PRESET_PPD_BITS
Parity forced to 0 (space)
nvr_manage_t g_nvr_manage_config
int spiTouINS_serRead(unsigned char *buf, int size)
void log_ublox_raw_to_SD(cISLogger &logger, uint8_t *dataPtr, uint32_t dataSize)
#define US_MR_PAR_SPACE
(US_MR) Parity forced to 0 (Space)
#define COM_RX_PORT_COUNT
void handle_data_from_uINS(p_data_hdr_t &dataHdr, uint8_t *data)
int is_comm_stop_broadcasts_current_port(is_comm_instance_t *instance)
int serRxUsed(int serialNum)
Returns number of bytes used in Rx buffer.
uint32_t can_receive_address
#define EVB_CFG_BITS_IDX_WIFI(bits)
evb_wifi_t wifi[NUM_WIFI_PRESETS]
#define US_MR_NBSTOP_1_5_BIT
(US_MR) 1.5 stop bit (SYNC = 0) or reserved (SYNC = 1)
void log_uINS_data(cISLogger &logger, is_comm_instance_t &comm)
void uINS_stream_enable_std(is_comm_instance_t &comm)
char copyDataPToStructP2(void *sptr, const p_data_hdr_t *dataHdr, const uint8_t *dataBuf, const unsigned int maxsize)
#define DID_EVB_RTOS_INFO
void com_bridge_smart_forward_xstream(uint32_t srcPort, StreamBufferHandle_t xStreamBuffer)
int serWrite(int serialNum, const unsigned char *buf, int size)
Write data on USART. Returns number of bytes written.