FreeCalypso > hg > fc-tourmaline
changeset 260:34b7059b9337
drv_app/spi/*: code readability fixes
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 14 May 2021 02:13:47 +0000 |
parents | 365833d1d186 |
children | 841a848ba762 |
files | src/cs/drivers/drv_app/spi/spi_api.c src/cs/drivers/drv_app/spi/spi_api.h src/cs/drivers/drv_app/spi/spi_env.c src/cs/drivers/drv_app/spi/spi_env.h src/cs/drivers/drv_app/spi/spi_pool_size.h src/cs/drivers/drv_app/spi/spi_process.c src/cs/drivers/drv_app/spi/spi_process.h src/cs/drivers/drv_app/spi/spi_task.c src/cs/drivers/drv_app/spi/spi_task.h |
diffstat | 9 files changed, 196 insertions(+), 252 deletions(-) [+] |
line wrap: on
line diff
--- a/src/cs/drivers/drv_app/spi/spi_api.c Fri May 14 01:30:13 2021 +0000 +++ b/src/cs/drivers/drv_app/spi/spi_api.c Fri May 14 02:13:47 2021 +0000 @@ -21,12 +21,11 @@ #include "rvm/rvm_use_id_list.h" - -/********************************************************************************/ -/* */ -/* Function Name: spi_abb_read */ -/* */ -/********************************************************************************/ +/******************************************************************************/ +/* */ +/* Function Name: spi_abb_read */ +/* */ +/******************************************************************************/ T_RV_RET spi_abb_read(UINT16 page, UINT16 address, CALLBACK_FUNC_U16 CallBack) { T_SPI_READ *msgPtr; @@ -73,13 +72,11 @@ } - - -/********************************************************************************/ -/* */ -/* Function Name: spi_abb_write */ -/* */ -/********************************************************************************/ +/******************************************************************************/ +/* */ +/* Function Name: spi_abb_write */ +/* */ +/******************************************************************************/ T_RV_RET spi_abb_write(UINT16 page, UINT16 address, UINT16 data) { T_SPI_WRITE *msgPtr; @@ -123,13 +120,11 @@ } - - -/********************************************************************************/ -/* */ -/* Function Name: spi_abb_conf_ADC */ -/* */ -/********************************************************************************/ +/******************************************************************************/ +/* */ +/* Function Name: spi_abb_conf_ADC */ +/* */ +/******************************************************************************/ T_RV_RET spi_abb_conf_ADC(UINT16 channels, UINT16 itval) { T_SPI_ABB_CONF_ADC *msgPtr; @@ -175,12 +170,11 @@ } - -/********************************************************************************/ -/* */ -/* Function Name: spi_abb_read_ADC */ -/* */ -/********************************************************************************/ +/******************************************************************************/ +/* */ +/* Function Name: spi_abb_read_ADC */ +/* */ +/******************************************************************************/ T_RV_RET spi_abb_read_ADC(UINT16 *Buff, CALLBACK_FUNC_NO_PARAM CallBack) { T_SPI_ABB_READ_ADC *msgPtr; @@ -224,4 +218,3 @@ return (RV_OK); } -
--- a/src/cs/drivers/drv_app/spi/spi_api.h Fri May 14 01:30:13 2021 +0000 +++ b/src/cs/drivers/drv_app/spi/spi_api.h Fri May 14 02:13:47 2021 +0000 @@ -40,30 +40,29 @@ typedef void (*CALLBACK_FUNC_U16)(UINT16 *); - /*****************************************/ /* structures of messages send to SPI */ /*****************************************/ typedef struct { T_RV_HDR os_hdr; - UINT16 page; - UINT16 address; + UINT16 page; + UINT16 address; UINT16 data; } T_SPI_WRITE; typedef struct { T_RV_HDR os_hdr; - UINT16 page; - UINT16 address; + UINT16 page; + UINT16 address; } T_SPI_READ; typedef struct { T_RV_HDR os_hdr; - UINT16 channels; - UINT16 itval; + UINT16 channels; + UINT16 itval; } T_SPI_ABB_CONF_ADC; @@ -74,7 +73,6 @@ } T_SPI_ABB_READ_ADC; - #ifdef __cplusplus } #endif @@ -82,97 +80,96 @@ /* Prototypes */ -/********************************************************************************/ -/* */ -/* Function Name: spi_abb_write */ -/* */ -/* Purpose: This function is used to send to the SPI mailbox a */ -/* WRITE REGISTER rqst msg. */ -/* */ -/* Input Parameters: */ -/* - page : ABB Page where to read the register. */ -/* - address : address of the ABB register to read. */ -/* - data : data to write in the ABB register */ -/* */ -/* Return : */ -/* - RVM_NOT_READY : the SPI task is not ready */ -/* - RV_MEMORY_ERR : the SPI task has not enough memory */ -/* - RV_OK : normal processing */ -/* */ -/* Note: */ -/* None. */ -/* */ -/********************************************************************************/ +/******************************************************************************/ +/* */ +/* Function Name: spi_abb_write */ +/* */ +/* Purpose: This function is used to send to the SPI mailbox a */ +/* WRITE REGISTER rqst msg. */ +/* */ +/* Input Parameters: */ +/* - page : ABB Page where to read the register. */ +/* - address : address of the ABB register to read. */ +/* - data : data to write in the ABB register */ +/* */ +/* Return : */ +/* - RVM_NOT_READY : the SPI task is not ready */ +/* - RV_MEMORY_ERR : the SPI task has not enough memory */ +/* - RV_OK : normal processing */ +/* */ +/* Note: */ +/* None. */ +/* */ +/******************************************************************************/ T_RV_RET spi_abb_write(UINT16 page, UINT16 address, UINT16 data); -/********************************************************************************/ -/* */ -/* Function Name: spi_abb_read */ -/* */ -/* Purpose: This function is used to send a READ REGISTER rqst msg */ -/* to the SPI mailbox. */ -/* */ -/* Input Parameters: */ -/* - page : ABB Page where to read the register. */ -/* - address : address of the ABB register to read. */ -/* - CallBack : callback function called by the spi task */ -/* at the end of the read process. */ -/* */ -/* Return : */ -/* - RVM_NOT_READY : the SPI task is not ready */ -/* - RV_MEMORY_ERR : the SPI task has not enough memory */ -/* - RV_OK : normal processing */ -/* */ -/* Note: */ -/* None. */ -/* */ -/********************************************************************************/ +/******************************************************************************/ +/* */ +/* Function Name: spi_abb_read */ +/* */ +/* Purpose: This function is used to send a READ REGISTER rqst msg */ +/* to the SPI mailbox. */ +/* */ +/* Input Parameters: */ +/* - page : ABB Page where to read the register. */ +/* - address : address of the ABB register to read. */ +/* - CallBack : callback function called by the spi task */ +/* at the end of the read process. */ +/* */ +/* Return : */ +/* - RVM_NOT_READY : the SPI task is not ready */ +/* - RV_MEMORY_ERR : the SPI task has not enough memory */ +/* - RV_OK : normal processing */ +/* */ +/* Note: */ +/* None. */ +/* */ +/******************************************************************************/ T_RV_RET spi_abb_read(UINT16 page, UINT16 address, CALLBACK_FUNC_U16 CallBack); -/********************************************************************************/ -/* */ -/* Function Name: spi_abb_conf_ADC */ -/* */ -/* Purpose: This function is used to send to the SPI mailbox a rqst msg */ -/* for configuring ABB MADC for conversions. */ -/* */ -/* Input Parameters: */ -/* - channels : ABB channels to be converted. */ -/* - itval : configure the End Of Conversion IT. */ -/* */ -/* Return : */ -/* - RVM_NOT_READY : the SPI task is not ready */ -/* - RV_MEMORY_ERR : the SPI task has not enough memory */ -/* - RV_OK : normal processing */ -/* */ -/* Note: */ -/* None. */ -/* */ -/********************************************************************************/ +/******************************************************************************/ +/* */ +/* Function Name: spi_abb_conf_ADC */ +/* */ +/* Purpose: This function is used to send to the SPI mailbox a rqst msg*/ +/* for configuring ABB MADC for conversions. */ +/* */ +/* Input Parameters: */ +/* - channels : ABB channels to be converted. */ +/* - itval : configure the End Of Conversion IT. */ +/* */ +/* Return : */ +/* - RVM_NOT_READY : the SPI task is not ready */ +/* - RV_MEMORY_ERR : the SPI task has not enough memory */ +/* - RV_OK : normal processing */ +/* */ +/* Note: */ +/* None. */ +/* */ +/******************************************************************************/ T_RV_RET spi_abb_conf_ADC(UINT16 channels, UINT16 itval); -/********************************************************************************/ -/* */ -/* Function Name: spi_abb_read_ADC */ -/* */ -/* Purpose: This function is used to send to the SPI mailbox a rqst msg */ -/* for reading the ABB ADC results. */ -/* */ -/* Input Parameters: */ -/* - Buff : pointer to the buffer filled with ADC results. */ -/* - CallBack : callback function called by the spi task */ -/* at the end of the read process. */ -/* */ -/* Return : */ -/* - RVM_NOT_READY : the SPI task is not ready */ -/* - RV_MEMORY_ERR : the SPI task has not enough memory */ -/* - RV_OK : normal processing */ -/* */ -/* Note: */ -/* None. */ -/* */ -/********************************************************************************/ +/******************************************************************************/ +/* */ +/* Function Name: spi_abb_read_ADC */ +/* */ +/* Purpose: This function is used to send to the SPI mailbox a rqst msg*/ +/* for reading the ABB ADC results. */ +/* */ +/* Input Parameters: */ +/* - Buff : pointer to the buffer filled with ADC results.*/ +/* - CallBack : callback function called by the spi task */ +/* at the end of the read process. */ +/* */ +/* Return : */ +/* - RVM_NOT_READY : the SPI task is not ready */ +/* - RV_MEMORY_ERR : the SPI task has not enough memory */ +/* - RV_OK : normal processing */ +/* */ +/* Note: */ +/* None. */ +/* */ +/******************************************************************************/ T_RV_RET spi_abb_read_ADC(UINT16 *Buff, CALLBACK_FUNC_NO_PARAM CallBack); #endif /* __SPI_API_H_ */ -
--- a/src/cs/drivers/drv_app/spi/spi_env.c Fri May 14 01:30:13 2021 +0000 +++ b/src/cs/drivers/drv_app/spi/spi_env.c Fri May 14 02:13:47 2021 +0000 @@ -35,9 +35,8 @@ T_SPI_GBL_INFO *SPI_GBL_INFO_PTR = NULL; - /****************************************************************************** -* Function : spi_get_info +* Function : spi_get_info * * Description : This function is called by the RV manager to learn * spi requirements in terms of memory, SWEs... @@ -53,7 +52,6 @@ ******************************************************************************/ T_RVM_RETURN spi_get_info(T_RVM_INFO_SWE * infoSWE) { - /* SWE info */ infoSWE->swe_type = RVM_SWE_TYPE_4; @@ -63,7 +61,6 @@ infoSWE->type_info.type4.stack_size = SPI_STACK_SIZE; infoSWE->type_info.type4.priority = RVM_SPI_TASK_PRIORITY; - /* memory bank info */ infoSWE->type_info.type4.nb_mem_bank = 1; @@ -71,11 +68,9 @@ infoSWE->type_info.type4.mem_bank[0].initial_params.size = SPI_MB_PRIM_SIZE; infoSWE->type_info.type4.mem_bank[0].initial_params.watermark = SPI_MB_PRIM_WATERMARK; - /* linked SWE info */ infoSWE->type_info.type4.nb_linked_swe = 0; - /* generic functions */ infoSWE->type_info.type4.set_info = spi_set_info; infoSWE->type_info.type4.init = spi_init; @@ -92,7 +87,7 @@ /****************************************************************************** -* Function : spi_set_info +* Function : spi_set_info * * Description : This function is called by the RV manager to inform * the spi SWE about task_id, mb_id and error function. @@ -136,7 +131,6 @@ return (RVM_MEMORY_ERR); } - /* store the pointer to the error function */ spi_error_ft = callBackFct ; @@ -162,7 +156,7 @@ /****************************************************************************** -* Function : spi_init +* Function : spi_init * * Description : This function is called by the RV manager to initialize the * spi SWE before creating the task and calling spi_start. @@ -171,20 +165,18 @@ * * Return : T_RVM_RETURN * -* History : 0.1 (20-August-2000) +* History : 0.1 (20-August-2000) * * ******************************************************************************/ T_RVM_RETURN spi_init(void) { - return RV_OK; } - /****************************************************************************** -* Function : spi_stop +* Function : spi_stop * * Description : This function is called by the RV manager to stop the spi SWE. * @@ -192,7 +184,7 @@ * * Return : T_RVM_RETURN * -* History : 0.1 (20-August-2000) +* History : 0.1 (20-August-2000) * * ******************************************************************************/ @@ -205,7 +197,7 @@ /****************************************************************************** -* Function : spi_kill +* Function : spi_kill * * Description : This function is called by the RV manager to kill the spi * SWE, after the spi_stop function has been called. @@ -223,6 +215,3 @@ /* free all memory buffer previously allocated */ return RV_OK; } - - -
--- a/src/cs/drivers/drv_app/spi/spi_env.h Fri May 14 01:30:13 2021 +0000 +++ b/src/cs/drivers/drv_app/spi/spi_env.h Fri May 14 02:13:47 2021 +0000 @@ -35,7 +35,6 @@ #define SPI_MB_PRIM_INC_WATERMARK 0 - typedef struct SPI_GBL_INFO { T_RVF_MB_ID prim_id; @@ -69,4 +68,3 @@ T_RVM_RETURN spi_kill (void); #endif /*__SPI_ENV_H_*/ -
--- a/src/cs/drivers/drv_app/spi/spi_pool_size.h Fri May 14 01:30:13 2021 +0000 +++ b/src/cs/drivers/drv_app/spi/spi_pool_size.h Fri May 14 02:13:47 2021 +0000 @@ -13,9 +13,9 @@ /* * History: * - * Date Author Modification - * ------------------------------------------------------------------- - * 07/08/2003 Vincent Oberle Extracted from rvf_pool_size.h + * Date Author Modification + * ------------------------------------------------------------------- + * 07/08/2003 Vincent Oberle Extracted from rvf_pool_size.h * * (C) Copyright 2003 by Texas Instruments Incorporated, All Rights Reserved */
--- a/src/cs/drivers/drv_app/spi/spi_process.c Fri May 14 01:30:13 2021 +0000 +++ b/src/cs/drivers/drv_app/spi/spi_process.c Fri May 14 02:13:47 2021 +0000 @@ -3,7 +3,7 @@ /* Name spi_process.c */ /* */ /* Function this file contains the spi_process function, used to */ -/* handle messages received in the SPI mailbox, and used to */ +/* handle messages received in the SPI mailbox, and used to */ /* access the ABB. It is called by the spi task core. */ /* */ /* Version 0.1 */ @@ -24,11 +24,6 @@ #include "rv/rv_defined_swe.h" // for RVM_PWR_SWE - -//#ifndef _WINDOWS -//#include "iq.h" -//#endif - /******************************************************************************* ** Function spi_process ** @@ -36,53 +31,29 @@ UINT8 spi_process(T_RV_HDR * msg_ptr) { UINT16 data ; -// static UINT8 int_nb = 0; if(msg_ptr != NULL) { switch (msg_ptr->msg_id) { case ABB_EXT_IRQ_EVT: - { + { /* Call to the low-level driver function : interrupt status register reading */ data = ABB_Read_Register_on_page(PAGE0, ITSTATREG); -//#ifndef _WINDOWS - // SW workaround to avoid an ABB interrupt occuring to early after the application start. - // The first ABB interrupt is skipped. - -// if((int_nb == 0) && (data == ADCEND_IT_STS)) -// { -// int_nb++; - - /* Unmask keypad interrupt */ -// IQ_Unmask(IQ_EXT); -// } -// else -// { - - /* Callback function */ -// if(msg_ptr->callback_func != NULL) -// { -// msg_ptr->callback_func(&data); -// } -// } -//#else - /* Callback function */ if(msg_ptr->callback_func != NULL) { msg_ptr->callback_func(&data); } -//#endif rvf_free_buf ((void *) msg_ptr); - break; - } + break; + } case SPI_ABB_READ_EVT: - { + { rvf_send_trace("SPI_task: SPI_READ_ABB_EVT received", 35, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); /* Call to the low-level driver function */ @@ -97,10 +68,10 @@ rvf_free_buf ((void *) msg_ptr); return 0; - } + } case SPI_ABB_WRITE_EVT: - { + { rvf_send_trace("SPI_task: SPI_WRITE_ABB_EVT received", 36, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); /* Call to the low-level driver function */ @@ -109,10 +80,10 @@ rvf_free_buf ((void *) msg_ptr); return 0; - } + } case SPI_ABB_CONF_ADC_EVT: - { + { rvf_send_trace("SPI_task: SPI_ABB_CONF_ADC_EVT received", 39, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); /* Call to the low-level driver function */ @@ -121,10 +92,10 @@ rvf_free_buf ((void *) msg_ptr); return 0; - } + } case SPI_ABB_READ_ADC_EVT: - { + { rvf_send_trace("SPI_task: SPI_ABB_READ_ADC_EVT received", 39, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); /* Call to the low-level driver function */ @@ -139,10 +110,10 @@ rvf_free_buf ((void *) msg_ptr); return 0; - } + } default: - { + { /* Unknown message has been received */ #ifdef RVM_PWR_SWE rvf_send_trace("SPI_task : Received an unknown or a PWR message",47, NULL_PARAM , @@ -155,10 +126,8 @@ #endif return 1; - } + } } // end of switch } // end of if (msg_ptr != NULL) return 0; } - -
--- a/src/cs/drivers/drv_app/spi/spi_process.h Fri May 14 01:30:13 2021 +0000 +++ b/src/cs/drivers/drv_app/spi/spi_process.h Fri May 14 02:13:47 2021 +0000 @@ -3,7 +3,7 @@ /* Name spi_process.h */ /* */ /* Function this file contains the spi_process function prototype, */ -/* used to handle messages received in the SPI task mailbox. */ +/* used to handle messages received in the SPI task mailbox. */ /* */ /* Version 0.1 */ /* */
--- a/src/cs/drivers/drv_app/spi/spi_task.c Fri May 14 01:30:13 2021 +0000 +++ b/src/cs/drivers/drv_app/spi/spi_task.c Fri May 14 02:13:47 2021 +0000 @@ -1,21 +1,21 @@ /*****************************************************************************/ /* */ -/* Name spi_task.c */ +/* Name spi_task.c */ /* */ -/* Function this file contains the main SPI function: spi_core. */ -/* It contains the body of the SPI task. */ -/* It will initialize the SPI and then wait for messages */ -/* or functions calls. */ +/* Function this file contains the main SPI function: spi_core. */ +/* It contains the body of the SPI task. */ +/* It will initialize the SPI and then wait for messages */ +/* or functions calls. */ /* */ -/* Version 0.1 */ -/* Author Candice Bazanegue */ -/* */ -/* Date Modification */ -/* ------------------------------------ */ -/* 20/08/2000 Create */ -/* 01/09/2003 Modfication */ -/* Author Pascal Puel */ -/* */ +/* Version 0.1 */ +/* Author Candice Bazanegue */ +/* */ +/* Date Modification */ +/* ------------------------------------ */ +/* 20/08/2000 Create */ +/* 01/09/2003 Modfication */ +/* Author Pascal Puel */ +/* */ /* (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved */ /*****************************************************************************/ @@ -43,20 +43,19 @@ #endif - /******************************************************************************* ** Function spi_core ** ** Description Core of the spi task, which initiliazes the spi SWE and -** waits for messages. +** waits for messages. ** *******************************************************************************/ T_RV_RET spi_core(void) { - BOOLEAN error_occured = FALSE; - T_RV_HDR * msg_ptr; + BOOLEAN error_occured = FALSE; + T_RV_HDR * msg_ptr; - rvf_send_trace("SPI_task: Initialization", 24, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); + rvf_send_trace("SPI_task: Initialization", 24, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); SPI_GBL_INFO_PTR->SpiTaskReady = TRUE; #ifndef _WINDOWS @@ -68,68 +67,67 @@ // Unmask external (ABB) interrupt IQ_Unmask(IQ_EXT); #endif - // Get the switch on cause from ABB. - Set_Switch_ON_Cause(); + // Get the switch on cause from ABB. + Set_Switch_ON_Cause(); #endif - /* loop to process messages */ - while (error_occured == FALSE) - { - /* Wait for the necessary events (infinite wait for a msg in the mailbox 0). */ - UINT16 received_event = rvf_wait (0xffff, 0); + /* loop to process messages */ + while (error_occured == FALSE) + { + /* Wait for the necessary events (infinite wait for a msg in the mailbox 0). */ + UINT16 received_event = rvf_wait (0xffff, 0); - /* If an event related to mailbox 0 is received, then */ - if (received_event & RVF_TASK_MBOX_0_EVT_MASK) - { - /* Read the message in the driver mailbox and delegate action..*/ - msg_ptr = (T_RV_HDR *) rvf_read_mbox(SPI_MAILBOX); + /* If an event related to mailbox 0 is received, then */ + if (received_event & RVF_TASK_MBOX_0_EVT_MASK) + { + /* Read the message in the driver mailbox and delegate action..*/ + msg_ptr = (T_RV_HDR *) rvf_read_mbox(SPI_MAILBOX); #ifdef RVM_PWR_SWE - if(spi_process(msg_ptr)) - { - pwr_process(msg_ptr); - } + if(spi_process(msg_ptr)) + { + pwr_process(msg_ptr); + } #else - spi_process(msg_ptr); - #endif - } + spi_process(msg_ptr); + #endif + } #ifdef RVM_PWR_SWE - /* Timers */ + /* Timers */ if (received_event & SPI_TIMER0_WAIT_EVENT) { pwr_bat_test_timer_process(); } - if (received_event & SPI_TIMER1_WAIT_EVENT) - /* timer used to detect the end of the CI charge */ + if (received_event & SPI_TIMER1_WAIT_EVENT) + /* timer used to detect the end of the CI charge */ { pwr_CI_charge_timer_process(); } if (received_event & SPI_TIMER2_WAIT_EVENT) - /* timer used to detect the end of the CV charge */ - { + /* timer used to detect the end of the CV charge */ + { pwr_CV_charge_timer_process(); } - if (received_event & SPI_TIMER3_WAIT_EVENT) - /* timer used to check the battery discharge level */ - { + if (received_event & SPI_TIMER3_WAIT_EVENT) + /* timer used to check the battery discharge level */ + { pwr_discharge_timer_process(); } - #endif - } // end of while - return RV_OK; + #endif + } // end of while + return RV_OK; } - /********************************************************************************** -* Function : spi_adc_on +* Function : spi_adc_on * * Description : Put the variable is_adc_on of the T_SPI_GBL_INFO structure to TRUE. -* This variable is used for the battery management. +* This variable is used for the battery management. * This function is called by the CST entity. * * Parameters : None
--- a/src/cs/drivers/drv_app/spi/spi_task.h Fri May 14 01:30:13 2021 +0000 +++ b/src/cs/drivers/drv_app/spi/spi_task.h Fri May 14 02:13:47 2021 +0000 @@ -1,19 +1,19 @@ /*****************************************************************************/ /* */ -/* Name spi_task.h */ +/* Name spi_task.h */ /* */ /* Function this file contains timers definitions used by spi_core, */ -/* in case the PWR SWE is defined. */ +/* in case the PWR SWE is defined. */ /* */ -/* Version 0.1 */ -/* Author Candice Bazanegue */ -/* */ -/* Date Modification */ -/* ------------------------------------ */ -/* 20/08/2000 Create */ -/* 01/09/2003 Modfication */ -/* Author Pascal Puel */ -/* */ +/* Version 0.1 */ +/* Author Candice Bazanegue */ +/* */ +/* Date Modification */ +/* ------------------------------------ */ +/* 20/08/2000 Create */ +/* 01/09/2003 Modfication */ +/* Author Pascal Puel */ +/* */ /* (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved */ /*****************************************************************************/