Skip to content

Commit

Permalink
externals/eltres: Add configurations for printf
Browse files Browse the repository at this point in the history
Add configurations to enable or disable printf function
- CONFIG_EXTERNALS_ELTRES_DEBUG_ERROR for error printf
- CONFIG_EXTERNALS_ELTRES_DEBUG_INFO for info printf
  • Loading branch information
SPRESENSE committed Nov 7, 2022
1 parent bba4b0e commit cbc27d2
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static uint32_t check_ack(uint8_t *recv_buf){

// Send message format check (whether the first byte starts with 0x68)
if(recv_buf[CXM150x_CTRL_FW_UPDATE_API_POS_SD0] != CXM150x_CTRL_FW_UPDATE_API_SD){
printf("str:%s\r\n",recv_buf);
printf_info("str:%s\r\n",recv_buf);
return CXM150x_RESPONSE_NG;
}

Expand Down Expand Up @@ -797,7 +797,7 @@ CXM150x_return_code set_CXM150x_ctrl_fw_update_power (CXM150xFWUpdateSetPower *p
}

if(param->m_on_off == CXM150x_POWER_ON){
printf("CXM150x control fw update power on\r\n");
printf_info("CXM150x control fw update power on\r\n");

// The CXM150x doesn't transit to CONTROL FW UPDATE mode correctly if LOW state duration of ENABLE pin is too short, so wait for a while after ENABLE pin state is set as LOW.
wrapper_CXM150x_set_power(CXM150x_POWER_OFF);
Expand All @@ -812,11 +812,11 @@ CXM150x_return_code set_CXM150x_ctrl_fw_update_power (CXM150xFWUpdateSetPower *p
} else {
if(param->m_update_type == CXM150x_CTRL_FW_UPDATE_END_REQUEST_TYPE_A){
// Do not change the WAKEUP pin to start transfer of side B after side A update
printf("CXM150x control fw update power off type A\r\n");
printf_info("CXM150x control fw update power off type A\r\n");

wrapper_CXM150x_set_power(CXM150x_POWER_OFF);
} else {
printf("CXM150x control fw update power off type B\r\n");
printf_info("CXM150x control fw update power off type B\r\n");

wrapper_CXM150x_set_Wakeup_pin(CXM150x_POWER_ON);
wrapper_CXM150x_set_power(CXM150x_POWER_OFF);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ CXM150x_return_code get_CXM150x_GNSS_fw_update_mode_check(void *param, CmdResGet

// Time out if "H>" could not be received.
if(timeout_flag == CXM150x_GNSS_FW_UPDATE_API_FLAG_ON){
printf("rx_message timeout .\r\n");
printf_err("rx_message timeout .\r\n");
return RETURN_TIMEOUT;
}

Expand Down Expand Up @@ -147,7 +147,7 @@ CXM150x_return_code get_CXM150x_GNSS_fw_update_mode_check(void *param, CmdResGet

// Time out if "H>" could not be received.
if(timeout_flag == CXM150x_GNSS_FW_UPDATE_API_FLAG_ON){
printf("rx_message timeout .\r\n");
printf_err("rx_message timeout .\r\n");
return RETURN_TIMEOUT;
}

Expand Down Expand Up @@ -250,7 +250,7 @@ CXM150x_return_code set_CXM150x_GNSS_fw_update_header_data(uint8_t* param, CmdRe

// Timeout if "LOADH" could not be received
if(timeout_flag == CXM150x_GNSS_FW_UPDATE_API_FLAG_ON){
printf("rx_message timeout .\r\n");
printf_err("rx_message timeout .\r\n");
return RETURN_TIMEOUT;
}

Expand Down Expand Up @@ -287,7 +287,7 @@ CXM150x_return_code set_CXM150x_GNSS_fw_update_header_data(uint8_t* param, CmdRe

// time out if OK was not received
if(timeout_flag == CXM150x_GNSS_FW_UPDATE_API_FLAG_ON){
printf("rx_message timeout .\r\n");
printf_err("rx_message timeout .\r\n");
return RETURN_TIMEOUT;
}

Expand Down Expand Up @@ -376,7 +376,7 @@ CXM150x_return_code set_CXM150x_GNSS_fw_update_code_data(CXM150xGNSSFWUpdateCode

// Time out if "LOADC" could not be received
if(timeout_flag == CXM150x_GNSS_FW_UPDATE_API_FLAG_ON){
printf("rx_message timeout .\r\n");
printf_err("rx_message timeout .\r\n");
return RETURN_TIMEOUT;
}

Expand Down Expand Up @@ -439,7 +439,7 @@ CXM150x_return_code set_CXM150x_GNSS_fw_update_code_data(CXM150xGNSSFWUpdateCode

// time out if OK was not received
if(timeout_flag == CXM150x_GNSS_FW_UPDATE_API_FLAG_ON){
printf("rx_message timeout .\r\n");
printf_err("rx_message timeout .\r\n");
return RETURN_TIMEOUT;
}
}else{
Expand Down Expand Up @@ -524,7 +524,7 @@ CXM150x_return_code get_CXM150x_GNSS_fw_update_result(void* param, CmdResGetGNSS

// time out if no success was received
if(timeout_flag == CXM150x_GNSS_FW_UPDATE_API_FLAG_ON){
printf("rx_message timeout .\r\n");
printf_err("rx_message timeout .\r\n");
return RETURN_TIMEOUT;
}

Expand Down
34 changes: 17 additions & 17 deletions externals/eltres/CXM150x_SDK/CXM150x_core/CXM150x_LIB.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ uint32_t CXM150x_init_uart_driver(void){
// ===========================================================================
static void add_response_message_buf(uint8_t *msg,uint8_t msg_len){
if(msg_len > CXM150x_RECEIVE_BUF_SIZE || msg_len == 0){
printf("add_response_message_buf length error[%dbyte]\r\n",msg_len);
printf_err("add_response_message_buf length error[%dbyte]\r\n",msg_len);
return;
}
strncpy((char*)g_response_buf,(char*)msg,msg_len);
Expand All @@ -206,7 +206,7 @@ static void add_response_message_buf(uint8_t *msg,uint8_t msg_len){
// ===========================================================================
static void add_event_message_buf(uint8_t *msg,uint8_t msg_len){
if(msg_len > CXM150x_RECEIVE_BUF_SIZE || msg_len == 0){
printf("add_event_message_buf length error[%dbyte]\r\n",msg_len);
printf_err("add_event_message_buf length error[%dbyte]\r\n",msg_len);
return;
}

Expand Down Expand Up @@ -256,7 +256,7 @@ static void add_rx_buffer(uint8_t *rx_message,uint8_t rcv_cnt){
add_response_message_buf(rx_message,rcv_cnt);
g_analyse_wait_message_cnt_res++;
} else {
printf("rcv message error:%s",rx_message);
printf_err("rcv message error:%s",rx_message);
}
}

Expand Down Expand Up @@ -302,7 +302,7 @@ static CXM150x_return_code send_command(uint8_t *command){

// Check if there is a command that has been sent and is waiting for a response (if any, end with BUSY)
if(g_command_response_wait_flag == CXM150x_UART_DRIVER_FLAG_ON){
printf("BUSY:%s",command);
printf_err("BUSY:%s",command);
g_command_response_info.m_result_code = COMMAND_SEND_RESULT_BUSY;
return RETURN_BUSY;
}
Expand All @@ -316,7 +316,7 @@ static CXM150x_return_code send_command(uint8_t *command){

// Send processing
CXM150x_return_code ret = wrapper_CXM150x_uart_transmit(command,strlen((char*)command),MAX_TIME_OUT_TICK_COUNT);
printf("snd:%s",command);
printf_info("snd:%s",command);
if(ret != RETURN_OK){
// Cancel command response wait
g_command_response_wait_flag = CXM150x_UART_DRIVER_FLAG_OFF;
Expand Down Expand Up @@ -368,7 +368,7 @@ static void check_command_response(void){
// Check if there is an unprocessed response
if(g_response_buf[0] != '\0'){
g_command_response_wait_flag = CXM150x_UART_DRIVER_FLAG_OFF;
printf("rcv:%s",g_response_buf);
printf_info("rcv:%s",g_response_buf);
set_command_response_data(&g_command_response_info,g_response_buf);
g_response_buf[0] = '\0';
g_analyse_wait_message_cnt_res--;
Expand Down Expand Up @@ -409,7 +409,7 @@ static void check_command_response(void){
uint32_t current_tick = wrapper_CXM150x_get_tick();
if(current_tick - g_command_send_tick_count > g_max_time_out_tick_count){
// timed out
printf("timeout command.(%ldmsec)\r\n",g_max_time_out_tick_count);
printf_err("timeout command.(%ldmsec)\r\n",g_max_time_out_tick_count);
g_command_response_info.m_result_code = COMMAND_RESULT_TIME_OUT;
g_command_response_wait_flag = CXM150x_UART_DRIVER_FLAG_OFF;
if(g_rcv_power_on_message_wait == CXM150x_UART_DRIVER_FLAG_ON){
Expand Down Expand Up @@ -482,13 +482,13 @@ static void check_command_response(void){
static void check_event(void){

if(g_rcv_event_buf_proc_index >= CXM150x_RECEIVE_EVENT_BUF_SIZE){
printf("check_event g_rcv_event_buf_proc_index count over error\r\n");
printf_err("check_event g_rcv_event_buf_proc_index count over error\r\n");
return;
}

uint8_t *proc_event_msg = g_event_buf[g_rcv_event_buf_proc_index];
if(proc_event_msg == NULL){
printf("check_event proc_event_msg is null\r\n");
printf_err("check_event proc_event_msg is null\r\n");
return;
}

Expand All @@ -501,7 +501,7 @@ static void check_event(void){
}
g_event_buffer_overflow_func_p(g_eventbuffer_overflow_info,CXM150x_EVENT_CALLBACK_ID_EVENT_BUFFER_OVERFLOW);
} else {
printf("check_event event buffer overflow\r\n");
printf_err("check_event event buffer overflow\r\n");
}
}

Expand All @@ -511,13 +511,13 @@ static void check_event(void){
if(proc_event_msg[0] != '|' || proc_event_msg[1] != ' '){
// Mark the event message as processed
//uint32_t len = strlen((char*)proc_event_msg);
printf("error evt[%ld]:%s\r\n",g_rcv_event_buf_proc_index,(char*)proc_event_msg);
printf_err("error evt[%ld]:%s\r\n",g_rcv_event_buf_proc_index,(char*)proc_event_msg);
memset(&g_event_buf[g_rcv_event_buf_proc_index],'\0',CXM150x_RECEIVE_BUF_SIZE);

return;
}

printf("evt:%s",(char*)proc_event_msg);
printf_info("evt:%s",(char*)proc_event_msg);
if(strstr((char*)proc_event_msg,"| SYS RESET DSLP") != NULL){

// When resuming from deep sleep, set WAKEUP to "L" to save power.
Expand Down Expand Up @@ -652,7 +652,7 @@ static void check_event(void){
}
}
} else {
printf("check_event err:%s",proc_event_msg);
printf_err("check_event err:%s",proc_event_msg);
}
} else if(strstr((char*)proc_event_msg,"| TIME ALARM")){
if(g_time_alarm_info != NULL){
Expand Down Expand Up @@ -763,7 +763,7 @@ static void check_event(void){
void CXM150x_trigger_analyse(void){
// Perform recovery processing if a UART error has occurred
if(g_uart_error_flg == CXM150x_UART_DRIVER_FLAG_ON){
printf("uart1 error recovery\r\n");
printf_err("uart1 error recovery\r\n");
CXM150x_init_uart_driver();
g_uart_error_flg = CXM150x_UART_DRIVER_FLAG_OFF;
}
Expand Down Expand Up @@ -939,7 +939,7 @@ CXM150x_return_code CXM150x_wait_power_on_message(void){
CXM150x_trigger_analyse();
// Check for timeout
if(wrapper_CXM150x_get_tick() - start_tm > MAX_POWER_ON_TIME_OUT_TICK_COUNT){
printf("CXM150x_wait_power_on_message timeout\r\n");
printf_err("CXM150x_wait_power_on_message timeout\r\n");
return RETURN_TIMEOUT;
}
}
Expand Down Expand Up @@ -968,7 +968,7 @@ CXM150x_return_code CXM150x_wait_power_on_message(void){
// ===========================================================================
CXM150x_return_code CXM150x_prep_wait_power_on_message(CXM150x_CALLBACK_RESPONSE_FUNC_POINTER res_func,CXM150x_RES_PARSE_CALLBACK_FUNC_POINTER parse_func,void *ret_struct){
if(g_command_response_wait_flag == CXM150x_UART_DRIVER_FLAG_ON){
printf("BUSY:POWER ON\r\n");
printf_err("BUSY:POWER ON\r\n");
return RETURN_BUSY;
}

Expand Down Expand Up @@ -1020,7 +1020,7 @@ uint32_t get_CXM150x_Rx_message_count(void){

// Perform recovery processing if a UART error has occurred
if(g_uart_error_flg == CXM150x_UART_DRIVER_FLAG_ON){
printf("uart1 error recovery\r\n");
printf_err("uart1 error recovery\r\n");
CXM150x_init_uart_driver();
g_uart_error_flg = CXM150x_UART_DRIVER_FLAG_OFF;
}
Expand Down
15 changes: 15 additions & 0 deletions externals/eltres/CXM150x_SDK/CXM150x_core/CXM150x_Port.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,25 @@
#define __CXM150x_PORT_H

#include <nuttx/config.h>
#include <debug.h>
#include <arch/board/board.h>
#include <arch/chip/pin.h>
#include "CXM150x_APITypeDef.h"

/* Debug print */

#ifdef CONFIG_EXTERNALS_ELTRES_DEBUG_ERROR
# define printf_err(format, ...) printf(format, ##__VA_ARGS__)
#else
# define printf_err(format, ...)
#endif

#ifdef CONFIG_EXTERNALS_ELTRES_DEBUG_INFO
# define printf_info(format, ...) printf(format, ##__VA_ARGS__)
#else
# define printf_info(format, ...)
#endif

/* Board-specific pin assignment */

#if defined(CONFIG_EXTERNALS_ELTRES_SPEXEL)
Expand Down
12 changes: 6 additions & 6 deletions externals/eltres/CXM150x_SDK/CXM150x_core/CXM150x_SYS.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static void res_check_set_CXM150x_power(uint8_t *response,void *res_buf){
CXM150x_return_code set_CXM150x_power(uint32_t param, CmdResSetCXM150xPower *res, CXM150x_CALLBACK_RESPONSE_FUNC_POINTER func){
if(param == CXM150x_POWER_ON){
// CXM150x normal power ON
printf("CXM150x power on\r\n");
printf_info("CXM150x power on\r\n");
CXM150x_init_uart_driver();

wrapper_CXM150x_set_Wakeup_pin(CXM150x_POWER_ON);
Expand All @@ -127,7 +127,7 @@ CXM150x_return_code set_CXM150x_power(uint32_t param, CmdResSetCXM150xPower *res
wrapper_CXM150x_set_power(CXM150x_POWER_OFF);
wrapper_CXM150x_set_Wakeup_pin(CXM150x_POWER_OFF);

printf("CXM150x power off\r\n");
printf_info("CXM150x power off\r\n");

if(res != NULL){
res->m_result = CXM150x_RESPONSE_OK;
Expand All @@ -139,7 +139,7 @@ CXM150x_return_code set_CXM150x_power(uint32_t param, CmdResSetCXM150xPower *res

} else if(param == CXM150x_POWER_CONTROL_FW_UPDATE){
// CONTROL_FW update mode
printf("CXM150x power CONTROL_FW_UPDATE mode\r\n");
printf_info("CXM150x power CONTROL_FW_UPDATE mode\r\n");

wrapper_CXM150x_set_Wakeup_pin(CXM150x_POWER_OFF);
wrapper_CXM150x_set_power(CXM150x_POWER_ON);
Expand All @@ -155,7 +155,7 @@ CXM150x_return_code set_CXM150x_power(uint32_t param, CmdResSetCXM150xPower *res
}
} else if(param == CXM150x_POWER_GNSS_FW_UPDATE){
// GNSS block FW update mode
printf("CXM150x power GNSS_FW_UPDATE mode\r\n");
printf_info("CXM150x power GNSS_FW_UPDATE mode\r\n");

wrapper_CXM150x_set_Wakeup_pin(CXM150x_POWER_ON);
wrapper_CXM150x_set_power(CXM150x_POWER_ON);
Expand All @@ -170,7 +170,7 @@ CXM150x_return_code set_CXM150x_power(uint32_t param, CmdResSetCXM150xPower *res
func(RETURN_OK,res);
}
} else {
printf("set_CXM150x_power param invalid\r\n");
printf_err("set_CXM150x_power param invalid\r\n");
}


Expand Down Expand Up @@ -590,7 +590,7 @@ CXM150xSysState conv_sys_stt_message_to_code(uint8_t *msg){
return SYS_STT_GNSS_BACKUP;
} else {
// Error if none of the above
printf("conv_sys_stt_message_to_code decode error:%s\r\n",msg);
printf_err("conv_sys_stt_message_to_code decode error:%s\r\n",msg);
}

return SYS_STT_PARSE_ERROR;
Expand Down

0 comments on commit cbc27d2

Please sign in to comment.