FreeCalypso > hg > freecalypso-sw
changeset 159:3c42e6e5fc04
gsm-fw/bsp/rtc: initial import from Leonardo TCS211 semi-src
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 17 Nov 2013 22:10:10 +0000 |
parents | 97b671efff9c |
children | dbfc9ff4e8d2 |
files | gsm-fw/bsp/rtc/rtc_api.h gsm-fw/bsp/rtc/rtc_config.h gsm-fw/bsp/rtc/rtc_env.c gsm-fw/bsp/rtc/rtc_env.h gsm-fw/bsp/rtc/rtc_functions.c gsm-fw/bsp/rtc/rtc_handle_message.c gsm-fw/bsp/rtc/rtc_i.h gsm-fw/bsp/rtc/rtc_messages_i.h gsm-fw/bsp/rtc/rtc_pool_size.h gsm-fw/bsp/rtc/rtc_process.c gsm-fw/bsp/rtc/rtc_task.c |
diffstat | 11 files changed, 1783 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/bsp/rtc/rtc_api.h Sun Nov 17 22:10:10 2013 +0000 @@ -0,0 +1,222 @@ +/********************************************************************************/ +/* */ +/* File Name: rtc_functions.h */ +/* */ +/* Purpose: This file contains prototypes of RTC's internal functions. */ +/* */ +/* Note: None. */ +/* */ +/* Revision History: */ +/* 03/20/01 Laurent Sollier Create. */ +/* */ +/* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved */ +/* */ +/********************************************************************************/ + +#ifndef _RTC_FUNCTIONS_H_ +#define _RTC_FUNCTIONS_H_ + +#include "rvf/rvf_api.h" + + +/********************************************************************************/ +/* */ +/* Generic functions declarations. */ +/* */ +/********************************************************************************/ + + + +/* Structure containing date and time */ +typedef struct { UINT8 second; /* seconds after the minute - [0,59] */ + UINT8 minute; /* minutes after the hour - [0,59] */ + UINT8 hour; /* hours after the midnight - [0,23] */ + UINT8 day; /* day of the month - [1,31] */ + UINT8 month; /* months - [01,12] */ + UINT8 year; /* years - [00,99] */ + UINT8 wday; /* days in a week - [0,6] */ + BOOL mode_12_hour; /* TRUE->12 hour mode ; FALSE-> 24 hour mode */ + BOOL PM_flag; /* if 12 hour flag = TRUE + TRUE->PM ; FALSE->AM */ + } T_RTC_DATE_TIME; + + +/******************************************************************************* + * + * RTC_RtcReset + * + * Purpose : Indicate if aRTC reset occured. + * + * Arguments: In : none + * Out: none + * + * Returns: TRUE if a RTC reset occurred + * FALSE if RTC didn't reset. + * + * + ******************************************************************************/ + +BOOL RTC_RtcReset(void); + + +/******************************************************************************* + * + * RTC_GetDateTime + * + * Purpose : Get date and time information. + * + * Arguments: In : none. + * Out: date_time : contain date and time data if return value is + * RVF_OK + * + * Returns: RVF_OK if date and time available in date_time variable + * RVF_NOT_READY if date and time is temporary not accessible for + * 30 micro seconds + * RVF_INTERNAL_ERROR else + * + ******************************************************************************/ + +T_RVF_RET RTC_GetDateTime(T_RTC_DATE_TIME* date_time); + + +/******************************************************************************* + * + * RTC_SetDateTime + * + * Purpose : Set date and time in RTC module. + * + * Arguments: In : date_time : date and time to set in RTC module + * Out: none + * + * Returns: RVF_OK if date and time have been set in RTC module + * RVF_NOT_READY if date and time cannot be saved before + * 30 micro seconds max + * RVF_INVALID_PARAMETER if date or/and timeformat is incorrect + * RVF_INTERNAL_ERROR else + * + * + ******************************************************************************/ + +T_RVF_RET RTC_SetDateTime(T_RTC_DATE_TIME date_time); + + +/******************************************************************************* + * + * RTC_GetAlarm + * + * Purpose : Get date and time alarm. + * + * Arguments: In : none + * Out: date_time : contain date and time data if return value is + * RVF_OK + * + * Returns: RVF_OK if date and time is available in date_time data + * RVF_INTERNAL_ERROR else + * + * + ******************************************************************************/ + +T_RVF_RET RTC_GetAlarm(T_RTC_DATE_TIME* date_time); + + +/******************************************************************************* + * + * RTC_SetAlarm + * + * Purpose : Set date and time alarmin RTC module. + * + * Arguments: In : date_time : Date and time alarm to set in RTC module + * return_path : return path used when date and time alarm is + * reached. This path can be a callback function or both + * task id and mailbox number + * Out: none + * + * Returns: RVF_OK if date and time alarm have been set in RTC module + * RVF_NOT_READY if date and time cannot be saved before + * 30 micro seconds max + * RVF_INVALID_PARAMETER if date or/and time format is incorrect + * RVF_INTERNAL_ERROR else + * + * + ******************************************************************************/ + +T_RVF_RET RTC_SetAlarm(T_RTC_DATE_TIME date_time, T_RV_RETURN return_path); + + +/******************************************************************************* + * + * RTC_UnsetAlarm + * + * Purpose : Unset alarm function. + * + * Arguments: In : none + * Out: none + * + * Returns: RVF_OK if date and time alarm have been set in RTC module + * RVF_NOT_READY if date and time cannot be saved before + * 30 micro seconds max + * RVF_INVALID_PARAMETER if date or/and time format is incorrect + * RVF_INTERNAL_ERROR else + * + * + ******************************************************************************/ + +T_RVF_RET RTC_UnsetAlarm(void); + + +/******************************************************************************* + * + * RTC_Rounding30s + * + * Purpose : Round time to the closest minute. + * + * Arguments: In : none + * Out: none + * + * Returns: none + * + * + ******************************************************************************/ + +void RTC_Rounding30s(void); + + +/******************************************************************************* + * + * RTC_Set12HourMode + * + * Purpose : Set the 12 or 24 hour mode for time get by RTC_GetDateTime and + * RTC_GetAlarm. + * + * Arguments: In : 12HourMode : TRUE if current time is on 12 hour mode + * FALSE if current time is on 24 hour mode + * Out: none + * + * Returns: none + * + * + ******************************************************************************/ + +void RTC_Set12HourMode(BOOL Mode12Hour); + + +/******************************************************************************* + * + * RTC_Is12HourMode + * + * Purpose : Define if the time given by RTC_GetAlarm and RTC_GetDateTime is in + * the 12 or 24 hour mode + * + * Arguments: In : none + * Out: none + * + * Returns: TRUE if current time is on 12 hour mode + * FALSE if current time is on 24 hour mode + * + * + ******************************************************************************/ + +BOOL RTC_Is12HourMode(void); + + +#endif /* #ifndef _RTC_FUNCTIONS_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/bsp/rtc/rtc_config.h Sun Nov 17 22:10:10 2013 +0000 @@ -0,0 +1,100 @@ +/********************************************************************************/ +/* */ +/* File Name: rtc_config.h */ +/* */ +/* Purpose: This file contains adresses for RTC register access. */ +/* and defined value */ +/* */ +/* Note: None. */ +/* */ +/* Revision History: */ +/* 05/31/01 Laurent Sollier Create. */ +/* */ +/* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved */ +/* */ +/********************************************************************************/ + +#ifndef _RTC_CONFIG_H_ +#define _RTC_CONFIG_H_ + +#ifndef _WINDOWS + #include "chipset.cfg" +#endif + + +#include "memif/mem.h" +#include "rv/general.h" + + + +/* FOR ULYSSE AND CALYPSO CHIP */ +#define RTC_SECONDS_REG (UINT8 *)(RTC_XIO_START) /* Seconds register */ +#define RTC_MINUTES_REG ((UINT8 *)(RTC_XIO_START) + 0x01) /* Minutes register */ +#define RTC_HOURS_REG ((UINT8 *)(RTC_XIO_START) + 0x02) /* Hours register */ +#define RTC_DAYS_REG ((UINT8 *)(RTC_XIO_START) + 0x03) /* Days register */ +#define RTC_MONTHS_REG ((UINT8 *)(RTC_XIO_START) + 0x04) /* Months register */ +#define RTC_YEARS_REG ((UINT8 *)(RTC_XIO_START) + 0x05) /* Years register */ +#define RTC_WEEK_REG ((UINT8 *)(RTC_XIO_START) + 0x06) /* Week register */ +#define RTC_ALARM_SECONDS_REG ((UINT8 *)(RTC_XIO_START) + 0x08) /* Alarms seconds register */ +#define RTC_ALARM_MINUTES_REG ((UINT8 *)(RTC_XIO_START) + 0x09) /* Alarms minutes register */ +#define RTC_ALARM_HOURS_REG ((UINT8 *)(RTC_XIO_START) + 0x0A) /* Alarms hours register */ +#define RTC_ALARM_DAYS_REG ((UINT8 *)(RTC_XIO_START) + 0x0B) /* Alarms days register */ +#define RTC_ALARM_MONTHS_REG ((UINT8 *)(RTC_XIO_START) + 0x0C) /* Alarms months register */ +#define RTC_ALARM_YEARS_REG ((UINT8 *)(RTC_XIO_START) + 0x0D) /* Alarms years register */ +#define RTC_CTRL_REG ((UINT8 *)(RTC_XIO_START) + 0x10) /* Control register */ +#define RTC_STATUS_REG ((UINT8 *)(RTC_XIO_START) + 0x11) /* Status register */ +#define RTC_INTERRUPTS_REG ((UINT8 *)(RTC_XIO_START) + 0x12) /* Interrupts register */ +#define RTC_COMP_LSB_REG ((UINT8 *)(RTC_XIO_START) + 0x13) /* LSB compensation register */ +#define RTC_COMP_MSB_REG ((UINT8 *)(RTC_XIO_START) + 0x14) /* MSB compensation register */ + +/* RTC Control register description */ + +#define RTC_START_RTC 0x0001 /* 1 => RTC is running */ +#define RTC_ROUND_30S 0x0002 /* Time rounded to the closest minute */ +#define RTC_AUTO_COMP 0x0004 /* Auto compensation enabled or not */ +#define RTC_MODE_12_24 0x0008 /* 12 hours mode*/ +#define RTC_TEST_MODE 0x0010 /* Test mode */ +#define RTC_SET_32_COUNTER 0x0020 /* set 32 KHz counter with comp_reg */ +#if ((CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11)) + #define RTC_nDELTA_OMEGA 0x0040 /* Analog Baseband Type */ +#endif + + +/* RTC Interrupt register description */ + +#define RTC_EVERY 0x0003 /* Define period of periodic interrupt + (second, minute, hour, day) */ +#define RTC_IT_TIMER 0x0004 /* Enable periodic interrupt */ +#define RTC_IT_ALARM 0x0008 /* Alarm interrupt enabled or not */ + +/* RTC Status register description */ + +#define RTC_BUSY 0x0001 +#define RTC_RUN 0x0002 /* RTC is running */ +#define RTC_1S_EVENT 0x0004 /* One second has occured */ +#define RTC_1M_EVENT 0x0008 /* One minute has occured */ +#define RTC_1H_EVENT 0x0010 /* One hour has occured */ +#define RTC_1D_EVENT 0x0020 /* One day has occrued */ +#define RTC_ALARM 0x0040 /* Alarm interrupt has been generated */ +#define RTC_POWER_UP 0x0080 /* Indicates that a reset occured */ + +#define RTC_EVERY_SEC 0x0000 +#define RTC_EVERY_MIN 0x0001 +#define RTC_EVERY_HR 0x0002 +#define RTC_EVERY_DAY 0x0003 + +/* 32 Khz and HF clock definition */ +#define RTC_CLOCK_32K 32768.0 + + /* HF clock definition */ +#if ((CHIPSET == 3) || (CHIPSET == 5) || (CHIPSET == 6)) + #define RTC_CLOCK_HF 65000000.0 +#elif ((CHIPSET == 4) || (CHIPSET == 7) || (CHIPSET == 8)) + #define RTC_CLOCK_HF 78000000.0 +#elif ((CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) + #define RTC_CLOCK_HF 104000000.0 +#endif + + + +#endif /* #ifndef _RTC_CONFIG_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/bsp/rtc/rtc_env.c Sun Nov 17 22:10:10 2013 +0000 @@ -0,0 +1,212 @@ +/********************************************************************************/ +/* */ +/* File Name: rtc_env.c */ +/* */ +/* Purpose: This file contains routines that will be called in order */ +/* to: */ +/* - notify the Riviera manager of the RTC's Memory */ +/* Banks requirements, */ +/* - initialize all the RTC's data structures, */ +/* */ +/* Note: None. */ +/* */ +/* Revision History: */ +/* 03/22/01 Laurent Sollier Create. */ +/* */ +/* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved */ +/* */ +/********************************************************************************/ + +#include "rvm/rvm_priorities.h" +#include "rvm/rvm_use_id_list.h" +#include "rtc/rtc_env.h" +#include "rtc/rtc_i.h" +#include "rtc/rtc_api.h" +#include <string.h> + + +/* Define a pointer to the RTC environment control block */ +T_RTC_ENV_CTRL_BLK *rtc_env_ctrl_blk = NULL; + +/* External declaration */ +extern T_RV_RET rtc_core(void); + +/* Define global pointer to the error function */ + +static T_RVM_RETURN (*rtc_error_ft) (T_RVM_NAME swe_name, + T_RVM_RETURN error_cause, + T_RVM_ERROR_TYPE error_type, + T_RVM_STRING error_msg); + + +/****************************************************************************** +* Function : rtc_get_info +* +* Description : This function is called by the RV manager to learn +* rtc requirements in terms of memory, SWEs... +* +* Parameters : T_RVM_INFO_SWE * swe_info: pointer to the structure to fill +* containing infos related to the rtc SWE. +* +* Return : T_RVM_RETURN +* +* History : 0.1 (22-March-2001) +* +* +******************************************************************************/ +T_RVM_RETURN rtc_get_info(T_RVM_INFO_SWE* swe_info) +{ + /* SWE info */ + swe_info->swe_type = RVM_SWE_TYPE_4; + swe_info->type_info.type4.swe_use_id = RTC_USE_ID; + memcpy( swe_info->type_info.type4.swe_name, "RTC", sizeof("RTC") ); + + swe_info->type_info.type4.stack_size = RTC_STACK_SIZE; + swe_info->type_info.type4.priority = RVM_RTC_TASK_PRIORITY; + + /* Set the return path */ + swe_info->type_info.type4.return_path.callback_func = NULL; + swe_info->type_info.type4.return_path.addr_id = 0; + + + /* memory bank info */ + swe_info->type_info.type4.nb_mem_bank = 1; + + memcpy ((UINT8 *) swe_info->type_info.type4.mem_bank[0].bank_name, "RTC_PRIM", 9); + swe_info->type_info.type4.mem_bank[0].initial_params.size = RTC_MB_PRIM_SIZE; + swe_info->type_info.type4.mem_bank[0].initial_params.watermark = RTC_MB_PRIM_WATERMARK; + + /* linked SWE info */ + /* this SWE does not require any SWE to run */ + swe_info->type_info.type4.nb_linked_swe = 0; + + /* generic functions */ + swe_info->type_info.type4.set_info = rtc_set_info; + swe_info->type_info.type4.init = rtc_init; + swe_info->type_info.type4.core = rtc_core; + swe_info->type_info.type4.stop = rtc_stop; + swe_info->type_info.type4.kill = rtc_kill; + + return RV_OK; +} + + +/****************************************************************************** +* Function : rtc_set_info +* +* Description : This function is called by the RV manager to inform +* the rtc SWE about task_id, mb_id and error function. +* +* Parameters : - T_RVF_ADDR_ID addrId: Address id. +* - T_RVF_MB_ID mbId[]: array of memory bank ids. +* - callback function to call in case of unrecoverable error. +* +* Return : T_RVM_RETURN +* +* History : 0.1 (22-March-2001) +* +* +******************************************************************************/ +T_RVM_RETURN rtc_set_info(T_RVF_ADDR_ID addrId, + T_RV_RETURN return_path[], + T_RVF_MB_ID mbId[], + T_RVM_RETURN (*callBackFct) (T_RVM_NAME SWEntName, + T_RVM_RETURN errorCause, + T_RVM_ERROR_TYPE errorType, + T_RVM_STRING errorMsg) ) +{ + T_RVF_MB_STATUS mb_status; + + + rvf_send_trace("RTC : rtc_set_info: try to init GLOBAL INFO RTC structure ... ",62, + NULL_PARAM, + RV_TRACE_LEVEL_DEBUG_HIGH, + RTC_USE_ID); + + mb_status = rvf_get_buf(mbId[0],sizeof(T_RTC_ENV_CTRL_BLK),(void **) &rtc_env_ctrl_blk); + + if (mb_status == RVF_RED) + { + rvf_send_trace("RTC : rtc_set_info: Not enough memory to initiate GLOBAL INFO RTC structure ... ",86, + NULL_PARAM, + RV_TRACE_LEVEL_ERROR, + RTC_USE_ID); + + return (RVM_MEMORY_ERR); + } + + + /* store the pointer to the error function */ + rtc_error_ft = callBackFct ; + + rtc_env_ctrl_blk->prim_id = mbId[0]; + rtc_env_ctrl_blk->addr_id = addrId; + + + return RV_OK; +} + + +/****************************************************************************** +* Function : rtc_init +* +* Description : This function is called by the RV manager to initialize the +* rtc SWE before creating the task and calling rtc_start. +* +* Parameters : None +* +* Return : T_RVM_RETURN +* +* History : 0.1 (22-March-2001) +* +* +******************************************************************************/ +T_RVM_RETURN rtc_init(void) +{ + return RTC_Initialize(); +} + + +/****************************************************************************** +* Function : rtc_stop +* +* Description : This function is called by the RV manager to stop the rtc SWE. +* +* Parameters : None +* +* Return : T_RVM_RETURN +* +* History : 0.1 (22-March-2001) +* +* +******************************************************************************/ +T_RVM_RETURN rtc_stop(void) +{ + /* other SWEs have not been killed yet, rtc can send messages to other SWEs */ + + return RV_OK; +} + + +/****************************************************************************** +* Function : rtc_kill +* +* Description : This function is called by the RV manager to kill the rtc +* SWE, after the rtc_stop function has been called. +* +* Parameters : None +* +* Return : T_RVM_RETURN +* +* History : 0.1 (22-March-2001) +* +* +******************************************************************************/ +T_RVM_RETURN rtc_kill (void) +{ + /* free all memory buffer previously allocated */ + rvf_free_buf ((void *) rtc_env_ctrl_blk->msg_alarm_event); + rvf_free_buf ((void *) rtc_env_ctrl_blk); + + return RV_OK; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/bsp/rtc/rtc_env.h Sun Nov 17 22:10:10 2013 +0000 @@ -0,0 +1,50 @@ +/****************************************************************************/ +/* */ +/* File Name: rtc_env.h */ +/* */ +/* Purpose: This file contains prototypes for RV Environment related */ +/* functions used to get info, start and stop the rtc block. */ +/* */ +/* Version 0.1 */ +/* */ +/* Date Modification */ +/* ------------------------------------ */ +/* 03/20/1 Create */ +/* */ +/* Author Laurent Sollier */ +/* */ +/* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/ +/****************************************************************************/ +#ifndef __RTC_ENV_H_ +#define __RTC_ENV_H_ + + +#include "rvm/rvm_gen.h" + +#include "rtc/rtc_pool_size.h" /* Stack & Memory Bank sizes definitions */ + + +/* memory bank size and watermark */ +#define RTC_MB_PRIM_SIZE RTC_MB1_SIZE +#define RTC_MB_PRIM_WATERMARK (RTC_MB_PRIM_SIZE - 20) + +/* generic functions declarations */ +T_RVM_RETURN rtc_get_info (T_RVM_INFO_SWE *infoSWE); + +T_RVM_RETURN rtc_set_info(T_RVF_ADDR_ID addrId, + T_RV_RETURN return_path[], + T_RVF_MB_ID mbId[], + T_RVM_RETURN (*callBackFct) ( T_RVM_NAME SWEntName, + T_RVM_RETURN errorCause, + T_RVM_ERROR_TYPE errorType, + T_RVM_STRING errorMsg) ); + +T_RVM_RETURN rtc_init (void); + +T_RVM_RETURN rtc_stop (void); + +T_RVM_RETURN rtc_kill (void); + + +#endif /*__RTC_ENV_H_*/ +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/bsp/rtc/rtc_functions.c Sun Nov 17 22:10:10 2013 +0000 @@ -0,0 +1,813 @@ +/************************************************************************************/ +/* rtc_functions.c : contains low level function for the rtc */ +/* */ +/* */ +/* Author: Laurent Sollier */ +/* */ +/* version: 1.0 */ +/* */ +/* Date: 03/20/01 */ +/* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved */ +/************************************************************************************/ + +#ifndef _WINDOWS + #include "l1sw.cfg" + #include "chipset.cfg" +#endif + +#include <string.h> /* needed for memset */ +#include "nucleus.h" + +#include "rtc/rtc_messages_i.h" +#include "rtc/rtc_api.h" +#include "rtc/rtc_i.h" +#include "rtc/board/rtc_config.h" + +#include "rvm/rvm_use_id_list.h" + +#include "memif/mem.h" +#include "inth/iq.h" +#include "ulpd/ulpd.h" + +#if (CHIPSET == 12) + #include "inth/sys_inth.h" +#else + #include "inth/inth.h" +#endif + +/* ----- Macro ----- */ +/*-------------------------------------------------------------*/ +/* RTC_STOP */ +/*-------------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : Stop the RTC (STOP_RTC is cleared) */ +/*-------------------------------------------------------------*/ +#define RTC_STOP (* (volatile UINT8 *) RTC_CTRL_REG &= ~RTC_START_RTC) + +/*-------------------------------------------------------------*/ +/* RTC_START */ +/*-------------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : Start the RTC */ +/*-------------------------------------------------------------*/ +#define RTC_START (* (volatile UINT8 *) RTC_CTRL_REG |= RTC_START_RTC) + +/*-------------------------------------------------------------*/ +/* RTC_SET_32_CNT */ +/*-------------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : Set the SET_32_COUNTER bit */ +/*-------------------------------------------------------------*/ +#define RTC_SET_32_CNT (* (volatile UINT8 *) RTC_CTRL_REG |= RTC_SET_32_COUNTER) + +/*-------------------------------------------------------------*/ +/* RTC_RESET_32_CNT */ +/*-------------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : Reset the SET_32_COUNTER bit */ +/*-------------------------------------------------------------*/ +#define RTC_RESET_32_CNT (* (volatile UINT8 *) RTC_CTRL_REG &= ~RTC_SET_32_COUNTER) + +/*-------------------------------------------------------------*/ +/* RTC_SET_TEST_MODE */ +/*-------------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : Set the TEST_MODE bit */ +/*-------------------------------------------------------------*/ +#define RTC_SET_TEST_MODE (* (volatile UINT8 *) RTC_CTRL_REG |= RTC_TEST_MODE) + +/*-------------------------------------------------------------*/ +/* RTC_ENABLE_IT_ALARM */ +/*-------------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : Enable the IT_ALARM */ +/*-------------------------------------------------------------*/ +#define RTC_ENABLE_IT_ALARM (* (volatile UINT8 *) RTC_INTERRUPTS_REG |= RTC_IT_ALARM) + +/*-------------------------------------------------------------*/ +/* RTC_DISABLE_IT_ALARM */ +/*-------------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : Disable the IT_ALARM */ +/*-------------------------------------------------------------*/ +#define RTC_DISABLE_IT_ALARM (* (volatile UINT8 *) RTC_INTERRUPTS_REG &= ~RTC_IT_ALARM) + +/*-------------------------------------------------------------*/ +/* RTC_ENABLE_IT_TIMER */ +/*-------------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : Enable the IT_TIMER */ +/*-------------------------------------------------------------*/ +#define RTC_ENABLE_IT_TIMER (* (volatile UINT8 *) RTC_INTERRUPTS_REG |= RTC_IT_TIMER) + +/*-------------------------------------------------------------*/ +/* RTC_DISABLE_IT_TIMER */ +/*-------------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : Disable the IT_TIMER */ +/*-------------------------------------------------------------*/ +#define RTC_DISABLE_IT_TIMER (* (volatile UINT8 *) RTC_INTERRUPTS_REG &= ~RTC_IT_TIMER) + +/*-------------------------------------------------------------*/ +/* RTC_SET_EVENT_TIMER */ +/*-------------------------------------------------------------*/ +/* Parameters : event to enable or disable */ +/* Return : none */ +/* Functionality : Set the event for the IT_TIMER */ +/* Enable or disable IT */ +/*-------------------------------------------------------------*/ +#define RTC_SET_EVENT_TIMER(x) (* (volatile UINT8 *) RTC_INTERRUPTS_REG = (* (volatile UINT8 *) RTC_INTERRUPTS_REG & 0xfffc) | (x)) + +/*-------------------------------------------------------------*/ +/* RTC_TEST_BUSY */ +/*-------------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : Return the RTC state busy signal */ +/*-------------------------------------------------------------*/ +#define RTC_TEST_BUSY ((* (volatile UINT8 *) RTC_STATUS_REG) & RTC_BUSY) + +/*-------------------------------------------------------------*/ +/* RTC_RUN_STATE */ +/*-------------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : Return the RTC run state */ +/*-------------------------------------------------------------*/ +#define RTC_RUN_STATE ((* (volatile UINT8 *) RTC_STATUS_REG) & RTC_RUN) + +/*-------------------------------------------------------------*/ +/* RTC_FREE_AL_ITLINE */ +/*-------------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : free it AL line */ +/*-------------------------------------------------------------*/ + +#define RTC_FREE_AL_ITLINE ((* (volatile UINT8 *) RTC_STATUS_REG) |= RTC_ALARM) + +/*-------------------------------------------------------------*/ +/* RTC_FREE_POWER_UP */ +/*-------------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : clear reset event */ +/*-------------------------------------------------------------*/ + +#define RTC_FREE_POWER_UP ((* (volatile UINT8 *) RTC_STATUS_REG) |= RTC_POWER_UP) + + +/*-------------------------------------------------------------*/ +/* RTC_GET_EVENT_TIMER */ +/*-------------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : Get the event status for the IT_TIMER */ +/*-------------------------------------------------------------*/ +#define RTC_GET_EVENT_TIMER ((* (volatile UINT8 *) RTC_STATUS_REG & 0x3c)) + + + + +/* ----- Global variables ----- */ +static T_RTC_DATE_TIME rtc_date_time_alarm = {0}; + +static T_RV_RETURN rtc_return_path = {RVF_INVALID_ADDR_ID, NULL}; +static T_RTC_ALARM* rtc_msg_alarm_event = NULL; + +extern T_RTC_ENV_CTRL_BLK* rtc_env_ctrl_blk; + +/* Number of 32 Khz clock */ +static UINT32 rtc_nb_32khz = 0; + +/* Number of high frequency clock */ +static UINT32 rtc_nb_hf = 0; + +static NU_HISR hisr; +char hisrStack[512]; + +// UINT16 toto = 0; tmp + +void HisrEntryFunc(void) +{ + if (rtc_msg_alarm_event) + rvf_send_msg(rtc_env_ctrl_blk->addr_id, rtc_msg_alarm_event); + //char comp[15]; +/* sprintf(comp,"%d",toto); + LCDG_WriteString( 4, 0, " "); + LCDG_WriteString( 3, 0, (char*) comp); //tmp */ +} + + +/*---------------------------------------------------------------*/ +/* conv_bin DCB => B */ +/*---------------------------------------------------------------*/ +/* Parameters : value to be convert */ +/* Return : none */ +/* Functionality : BCD et binary conversion function */ +/*---------------------------------------------------------------*/ + +static UINT8 conv_bin(UINT8 value) +{ + return (10*(value>>4) + ( value & 0x0f)); +} + +/*---------------------------------------------------------------*/ +/* conv_bcd B => DCB */ +/*---------------------------------------------------------------*/ +/* Parameters : value to be convert */ +/* Return : none */ +/* Functionality : Binary to BCD conversion function */ +/*---------------------------------------------------------------*/ + +static UINT8 conv_bcd(UINT8 value) +{ + return ((value%10) | ( (value/10) <<4)); +} + + + +/*---------------------------------------------------------------*/ +/* format_date_available */ +/*---------------------------------------------------------------*/ +/* Parameters : T_RTC_DATE_TIME structure */ +/* Return : TRUE if format is available */ +/* FALSE else */ +/* Functionality : test if date and time format is available */ +/*---------------------------------------------------------------*/ + +BOOL format_date_available(T_RTC_DATE_TIME date_time) +{ + UINT8 m; + + if (date_time.second < 0 || date_time.second > 59) + return FALSE; + if (date_time.minute < 0 || date_time.minute > 59) + return FALSE; + if (date_time.mode_12_hour == FALSE) + { + if (date_time.hour < 0 || date_time.hour > 23) + return FALSE; + } + else + if (date_time.hour < 1 || date_time.hour > 12) + return FALSE; + + if (date_time.month < 1 || date_time.month > 12) + return FALSE; + if (date_time.year < 0 || date_time.year > 99) + return FALSE; + if (date_time.wday < 0 || date_time.wday > 6) + return FALSE; + m = date_time.month; + if (m == 1||m == 3||m == 5||m == 7||m == 8||m == 10||m == 12) + { + if (date_time.day < 1 || date_time.day > 31) + return FALSE; + } + else + { + if (m == 4||m == 6||m == 9||m == 11) + { + if (date_time.day < 1 || date_time.day > 30) + return FALSE; + } + else + { + if (date_time.year%4) + { + if (date_time.day < 1 || date_time.day > 28) + return FALSE; + } + else + { + if (date_time.day < 1 || date_time.day > 29) + return FALSE; + } + } + } + return TRUE; +} + + + +/******************************************************************************* + * + * RTC_Initialize + * + ******************************************************************************/ + + + +T_RVF_RET RTC_Initialize(void) +{ + T_RVF_MB_STATUS mb_status; + + /* Reserve memory for alarm event */ + mb_status = rvf_get_buf (rtc_env_ctrl_blk->prim_id, sizeof (T_RTC_ALARM ), (void **) &rtc_msg_alarm_event); + + if ((mb_status == RVF_GREEN) || (mb_status == RVF_YELLOW)) /* Memory allocation success */ + { + rtc_msg_alarm_event->os_hdr.msg_id = RTC_ALARM_EVT; + } + else + { + rtc_msg_alarm_event = NULL; + return RVF_MEMORY_ERR; + } + + rtc_env_ctrl_blk->msg_alarm_event = rtc_msg_alarm_event; + + + /* Start RTC module */ + if (RTC_RUN_STATE == 0) + RTC_START; + + /* Enable auto compensation */ + //*(volatile UINT8*) RTC_CTRL_REG |= RTC_AUTO_COMP; + /* Disable auto compensation */ + *(volatile UINT8*) RTC_CTRL_REG &= ~RTC_AUTO_COMP; + + /* For CHIPSET = 7, 9, 10 or 11, set analog baseband type */ +#if (((CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11)) && (ANLG_FAM == 1)) + *(volatile UINT8*) RTC_CTRL_REG |= RTC_nDELTA_OMEGA; +#endif + + /* Activate periodic interrupt every minute*/ + /* Disable all IT before accessing register */ + rvf_disable(25); + + /* Enable IRQ9 and IRQ10 */ + #if (CHIPSET == 12) + F_INTH_ENABLE_ONE_IT(C_INTH_RTC_TIMER_IT); + F_INTH_ENABLE_ONE_IT(C_INTH_RTC_ALARM_IT); + #else + IQ_Unmask(IQ_RTC_TIMER); + IQ_Unmask(IQ_RTC_ALARM); + #endif + + while (RTC_TEST_BUSY); + RTC_SET_EVENT_TIMER(RTC_EVERY_MIN); /* Set timer every minute */ + RTC_ENABLE_IT_TIMER; + RTC_DISABLE_IT_ALARM; + + rvf_enable(); + + /* The stack is entirely filled with the pattern 0xFE. */ + memset (hisrStack, 0xFE, sizeof(hisrStack)); + + /* Temporary modification: create HISR to diplay compensation value */ + NU_Create_HISR(&hisr, "RTC_HISR", HisrEntryFunc, 2, hisrStack, sizeof(hisrStack)); // lowest prty + /* end temporary modification */ + + return RVF_OK; +} +/******************************************************************************* + * + * RTC_RtcReset + * + ******************************************************************************/ + +BOOL RTC_RtcReset(void) +{ + + /* Read POWER UP bit to inform MMI of a possible RTC reset */ + if ( ((* (volatile UINT8*) RTC_STATUS_REG) & RTC_POWER_UP) ) + { + RTC_FREE_POWER_UP; + return TRUE; + } + else + return FALSE; + +} + + +/******************************************************************************* + * + * RTC_GetDateTime + * + ******************************************************************************/ + +T_RVF_RET RTC_GetDateTime(T_RTC_DATE_TIME* date_time) +{ + UINT8 sec; + UINT8 min; + UINT8 hour; + UINT8 day; + UINT8 month; + UINT8 year; + UINT8 wday; + UINT8 hr_reg; + + /* Disable all IT before reading register */ + rvf_disable(25); + + if (RTC_TEST_BUSY) + { + rvf_enable(); + return RVF_NOT_READY; + } + else + { + day = * (volatile UINT8 *) RTC_DAYS_REG; + month = * (volatile UINT8 *) RTC_MONTHS_REG; + year = * (volatile UINT8 *) RTC_YEARS_REG; + wday = * (volatile UINT8 *) RTC_WEEK_REG; + sec = * (volatile UINT8 *) RTC_SECONDS_REG; + min = * (volatile UINT8 *) RTC_MINUTES_REG; + hr_reg = * (volatile UINT8 *) RTC_HOURS_REG; + rvf_enable(); + } + + hour = (0x7f & hr_reg); + + date_time->second = conv_bin(sec); + date_time->minute = conv_bin(min); + date_time->hour = conv_bin(hour); + + if ( (* (volatile UINT8 *)RTC_CTRL_REG & RTC_MODE_12_24 ) == 0) + { + /* 24 hour mode */ + date_time->mode_12_hour = FALSE; + date_time->PM_flag = FALSE; + } + else + { + /* 12 hour mode */ + date_time->mode_12_hour = TRUE; + if ((hr_reg & 0x80) == 0) + date_time->PM_flag = FALSE; + else + date_time->PM_flag = TRUE; + } + + date_time->day = conv_bin(day); + date_time->month = conv_bin(month); + date_time->year = conv_bin(year); + date_time->wday = conv_bin(wday); + + return RVF_OK; +} + + +/******************************************************************************* + * + * RTC_SetDateTime + * + ******************************************************************************/ + +T_RVF_RET RTC_SetDateTime(T_RTC_DATE_TIME date_time) +{ + UINT8 sec; + UINT8 min; + UINT8 hour; + UINT8 day; + UINT8 month; + UINT8 year; + UINT8 wday; + + /* testing parameter range validity */ + if (!format_date_available(date_time)) + return RVF_INVALID_PARAMETER; + + + sec = conv_bcd(date_time.second); + min = conv_bcd(date_time.minute); + if (date_time.mode_12_hour == FALSE) + { + * (volatile UINT8 *)RTC_CTRL_REG &= ~RTC_MODE_12_24; + hour = conv_bcd(date_time.hour); + } + else + { + * (volatile UINT8 *)RTC_CTRL_REG |= RTC_MODE_12_24; + hour = conv_bcd(date_time.hour); + if (date_time.PM_flag != FALSE) + hour |= (0x80); + } + + day = conv_bcd(date_time.day); + month = conv_bcd(date_time.month); + year = conv_bcd(date_time.year); + wday = conv_bcd(date_time.wday); + + /* Disable all IT before reading register */ + rvf_disable(25); + + if (RTC_TEST_BUSY) + { + rvf_enable(); + return RVF_NOT_READY; + } + else + { + * (volatile UINT8 *) RTC_DAYS_REG = day; + * (volatile UINT8 *) RTC_MONTHS_REG = month; + * (volatile UINT8 *) RTC_YEARS_REG = year; + * (volatile UINT8 *) RTC_WEEK_REG = wday; + * (volatile UINT8 *) RTC_SECONDS_REG = sec; + * (volatile UINT8 *) RTC_MINUTES_REG = min; + * (volatile UINT8 *) RTC_HOURS_REG = hour; + + rvf_enable(); + } + + return RVF_OK; +} + + +/******************************************************************************* + * + * RTC_GetAlarm + * + ******************************************************************************/ + +T_RVF_RET RTC_GetAlarm(T_RTC_DATE_TIME* date_time) +{ + date_time->second = rtc_date_time_alarm.second; + date_time->minute = rtc_date_time_alarm.minute; + date_time->hour = rtc_date_time_alarm.hour; + date_time->day = rtc_date_time_alarm.day; + date_time->month = rtc_date_time_alarm.month; + date_time->year = rtc_date_time_alarm.year; + date_time->wday = rtc_date_time_alarm.wday; + date_time->mode_12_hour = rtc_date_time_alarm.mode_12_hour; + date_time->PM_flag = rtc_date_time_alarm.PM_flag; + return RVF_OK; +} + + +/******************************************************************************* + * + * RTC_SetAlarm + * + ******************************************************************************/ + +T_RVF_RET RTC_SetAlarm(T_RTC_DATE_TIME date_time, T_RV_RETURN return_path) +{ + UINT8 sec; + UINT8 min; + UINT8 hour; + UINT8 day; + UINT8 month; + UINT8 year; + UINT8 wday; + + + /* testing parameter range validity */ + if (!format_date_available(date_time)) + return RVF_INVALID_PARAMETER; + + sec = conv_bcd(date_time.second); + min = conv_bcd(date_time.minute); + + if (date_time.mode_12_hour == FALSE) + hour = conv_bcd(date_time.hour); + else + hour = conv_bcd(date_time.hour) | (date_time.PM_flag << 7); + + day = conv_bcd(date_time.day); + month = conv_bcd(date_time.month); + year = conv_bcd(date_time.year); + wday = conv_bcd(date_time.wday); + + + /* Disable all IT before reading register */ + rvf_disable(25); + + if (RTC_TEST_BUSY) + { + rvf_enable(); + return RVF_NOT_READY; + } + else + { + *(volatile UINT8*) RTC_ALARM_DAYS_REG = day; + *(volatile UINT8*) RTC_ALARM_MONTHS_REG = month; + *(volatile UINT8*) RTC_ALARM_YEARS_REG = year; + *(volatile UINT8*) RTC_ALARM_SECONDS_REG = sec; + *(volatile UINT8*) RTC_ALARM_MINUTES_REG = min; + *(volatile UINT8*) RTC_ALARM_HOURS_REG = hour; + + /* Enable alarm*/ + RTC_ENABLE_IT_ALARM; + rvf_enable(); + + /* Save callback */ + rtc_return_path.callback_func = return_path.callback_func; + rtc_return_path.addr_id = return_path.addr_id; + } + return RVF_OK; +} + + +/******************************************************************************* + * + * RTC_UnsetAlarm + * + ******************************************************************************/ + +T_RVF_RET RTC_UnsetAlarm(void) +{ + /* Disable all IT before reading register */ + rvf_disable(25); + + if (RTC_TEST_BUSY) + { + rvf_enable(); + return RVF_NOT_READY; + } + else + { + /* Disable alarm*/ + RTC_DISABLE_IT_ALARM; + rvf_enable(); + } + return RVF_OK; +} + + +/******************************************************************************* + * + * RTC_Rounding30s + * + ******************************************************************************/ + +void RTC_Rounding30s(void) +{ + *(UINT8*) RTC_CTRL_REG |= RTC_ROUND_30S; +} + + +/******************************************************************************* + * + * RTC_Set12HourMode + * + ******************************************************************************/ + +void RTC_Set12HourMode(BOOL Mode12Hour) +{ + if ( Mode12Hour == FALSE) + * (volatile UINT8*) RTC_CTRL_REG &= 0xf7; + else + * (volatile UINT8*) RTC_CTRL_REG |= 0x08; + +} + + +/******************************************************************************* + * + * RTC_Is12HourMode + * + ******************************************************************************/ + +BOOL RTC_Is12HourMode(void) +{ + if ( (*(volatile UINT8*) RTC_CTRL_REG & RTC_MODE_12_24) ) + return TRUE; + else + return FALSE; +} + + +/******************************************************************************* + * + * RTC_ItTimerHandle + * + ******************************************************************************/ + +void RTC_ItTimerHandle(void) +{ + static double compensation = 0; + static UINT8 nb_sample = 0; + double delta; + UINT16 value = 0; + INT16 tmp_value = 0; + UINT8 cmp[15]; + + /* Evaluate average on one hour max */ + if ( nb_sample < 60) + nb_sample++; + + /* perform calculation of auto compensation each minute and evaluate an + average on one hour */ + /* Number of 32 kHz clock lost in one second */ + /* Accurate operation is : delta = CLK_32 - rtc_nb_32khz*CLK_PLL/g_nb_hf */ + /* with CLK_32 = 32768 Hz and CLK_PLL depend on chipset */ + delta = RTC_CLOCK_32K - rtc_nb_32khz*RTC_CLOCK_HF/rtc_nb_hf; + + /* Number of 32 kHz clock lost in one hour */ + delta *= 3600.0; + + /* Average of the compensation to load */ + compensation = (compensation*(nb_sample-1) + delta)/nb_sample; + + if (compensation >= 0x7FFF) + tmp_value = 0x7FFE; + else if (compensation <= -0x7FFF) + tmp_value = -0x7FFE; + else + tmp_value = (INT16) compensation; + + if (tmp_value > 0) /* if 32 Khz clock is slow */ + value = tmp_value; + if (tmp_value < 0) /* if 32 Khz clock is fast */ + value = 0xFFFF + tmp_value + 1; + + /* Set value in compensation register */ + if (!RTC_TEST_BUSY) + { + *(volatile UINT8*) RTC_COMP_MSB_REG = (UINT8) (value >> 8); + *(volatile UINT8*) RTC_COMP_LSB_REG = (UINT8) (value & 0xFF); + } +/*toto = value; tmp*/ +/*NU_Activate_HISR(&hisr); tmp*/ + +} + + +/******************************************************************************* + * + * RTC_ItAlarmHandle + * + ******************************************************************************/ + +void RTC_ItAlarmHandle(void) +{ + /* Sending alarm event */ + /* Post alarm event in RTC mailbox */ + NU_Activate_HISR(&hisr); + + /*if (rtc_msg_alarm_event) + rvf_send_msg(rtc_env_ctrl_blk->task_id, rtc_env_ctrl_blk->mbox_id, rtc_msg_alarm_event);*/ + + /* Free alarm IT line */ + RTC_FREE_AL_ITLINE; +} + +/******************************************************************************* + * + * RTC_GaugingHandler + * + ******************************************************************************/ +void RTC_GaugingHandler(void) +{ + /* Number of 32 Khz clock at the end of the gauging */ + rtc_nb_32khz = ((*(volatile UINT16 *)ULDP_COUNTER_32_MSB_REG) * 0x10000) + + (*(volatile UINT16 *)ULDP_COUNTER_32_LSB_REG); + + /* Number of high frequency clock at the end of the gauging */ + /* To convert in nbr of 13 Mhz clocks (5*13=65Mhz) */ + rtc_nb_hf = ( ((*(volatile UINT16 *)ULDP_COUNTER_HI_FREQ_MSB_REG) * 0x10000) + + (*(volatile UINT16 *)ULDP_COUNTER_HI_FREQ_LSB_REG) ); +} + + +/******************************************************************************* + * + * RTC_ProcessAlarmEvent + * + ******************************************************************************/ + +void RTC_ProcessAlarmEvent(void) +{ + T_RVF_MB_STATUS mb_status; + T_RTC_ALARM* msg_alarm; + + /* Call MMI */ + if (rtc_return_path.callback_func != NULL) + { + rtc_return_path.callback_func(NULL); + } + else + { + /* Reserve memory for alarm event */ + mb_status = rvf_get_buf (rtc_env_ctrl_blk->prim_id, sizeof (T_RTC_ALARM ), (void **) &msg_alarm); + + if ((mb_status == RVF_GREEN) || (mb_status == RVF_YELLOW)) /* Memory allocation success */ + { + msg_alarm->os_hdr.msg_id = RTC_ALARM_EVT; + /* Send event in the mailbox */ + rvf_send_msg(rtc_return_path.addr_id, msg_alarm); + } + else + { + rvf_send_trace("Memory allocation error",23, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RTC_USE_ID ); + } + } +} + + + +/*---------------------------------------------------------------------------------------*/ +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/bsp/rtc/rtc_handle_message.c Sun Nov 17 22:10:10 2013 +0000 @@ -0,0 +1,50 @@ +/** + * @file rtc_handle_msg.c + * + * Coding of the rtc_handle_msg function, which is called when the SWE + * receives a new message. + * + * @author Laurent Sollier (l-sollier@ti.com) + * @version 0.1 + */ + +/* + * History: + * + * Date Author Modification + * ------------------------------------ + * 10/24/2001 L Sollier Create + * + * + * (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved + */ + + +#include "rv/rv_general.h" +#include "rvf/rvf_api.h" +#include "rvm/rvm_use_id_list.h" + + +/* External declaration */ +extern void rtc_process(T_RV_HDR * msg_ptr); + +/** + * @name Functions implementation + * + */ +/*@{*/ + +/** + * function: rtc_handle_msg + */ +UINT8 rtc_handle_msg(T_RV_HDR* msg_p) +{ + if (msg_p != NULL) + { + rtc_process(msg_p); + } + + return RV_OK; +} + +/*@}*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/bsp/rtc/rtc_i.h Sun Nov 17 22:10:10 2013 +0000 @@ -0,0 +1,124 @@ +/********************************************************************************/ +/* */ +/* File Name: rtc_i.h */ +/* */ +/* Purpose: This file contains the structures, constants and prototypes */ +/* dedicated to RTC. */ +/* */ +/* Note: None. */ +/* */ +/* Revision History: */ +/* 03/20/01 Laurent Sollier Create. */ +/* */ +/* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved */ +/* */ +/********************************************************************************/ + +#ifndef _RTC_I_H_ +#define _RTC_I_H_ + +#include "rvm/rvm_gen.h" +#include "rvf/rvf_api.h" + +/********************************************************************************/ +/* */ +/* Define a structure used to store all the informations related to RTC's task*/ +/* & MBs identifiers. */ +/* */ +/********************************************************************************/ + +typedef struct +{ + T_RVF_MB_ID prim_id; + T_RVF_ADDR_ID addr_id; + void* msg_alarm_event; +} T_RTC_ENV_CTRL_BLK; + +/******************************************************************************* + * + * RTC_Initialize + * + * Purpose : Initializes the RTC driver. + * + * Arguments: In : none + * Out: none + * + * Returns: RVF_OK if initialisation is ok + * RVF_INTERNAL_ERROR else + * + ******************************************************************************/ + +T_RVF_RET RTC_Initialize(void); + + +/******************************************************************************* + * + * RTC_ProcessAlarmEvent + * + * Purpose : Call MMI when SW RTC module receive alarm event + * + * Arguments: In : none + * Out: none + * + * Returns: none + * + * + ******************************************************************************/ + +void RTC_ProcessAlarmEvent(void); + +/******************************************************************************* + * + * RTC_ItTimerHandle + * + * Purpose : Compute an average value for compensation register + * + * Arguments: In : none + * Out: none + * + * Returns: none + * + * + ******************************************************************************/ + +void RTC_ItTimerHandle(void); + + +/******************************************************************************* + * + * RTC_ItAlarmHandle + * + * Purpose : Activate HISR which will send a message in the RTC mailbox to + * inform that time alarm is reached + * + * Arguments: In : none + * Out: none + * + * Returns: none + * + * + ******************************************************************************/ + +void RTC_ItAlarmHandle(void); + + +/******************************************************************************* + * + * RTC_GaugingHandler + * + * Purpose : This function is called when a gauging is finished (started by + * layer1). It save clock counter for average value computation + * ( done by RTC_ItTimerHandle) + * + * Arguments: In : none + * Out: none + * + * Returns: none + * + * + ******************************************************************************/ + +void RTC_GaugingHandler(void); + + +#endif /* #ifndef _RTC_I_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/bsp/rtc/rtc_messages_i.h Sun Nov 17 22:10:10 2013 +0000 @@ -0,0 +1,60 @@ +/****************************************************************************/ +/* */ +/* File Name: rtc_messages_i.h */ +/* */ +/* Purpose: This file contains data structures and functions prototypes */ +/* used to send events to the RTC SWE. */ +/* */ +/* Version 0.1 */ +/* */ +/* Date Modification */ +/* ------------------------------------ */ +/* 03/20/2001 Create */ +/* */ +/* Author Laurent Sollier */ +/* */ +/* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/ +/****************************************************************************/ +#ifndef __RTC_MESSAGES_H_ +#define __RTC_MESSAGES_H_ + + +#include "rv/rv_general.h" +#include "rvf/rvf_api.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* the message offset must differ for each SWE in order to have unique msg_id in the system */ +#define RTC_MESSAGES_OFFSET (0x35 << 10) +#define RTC_MAIL_BOX 1 + + + + +/*****************************************/ +/* structures of messages send to DRV */ + + +/******* RTC ALARM **********/ + +#define RTC_ALARM_EVT 1 + +typedef struct +{ + T_RV_HDR os_hdr; + +} T_RTC_ALARM; + + + + +#ifdef __cplusplus +} +#endif + + +#endif /* __RTC_MESSAGES_H_ */ +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/bsp/rtc/rtc_pool_size.h Sun Nov 17 22:10:10 2013 +0000 @@ -0,0 +1,35 @@ +/** + * @file rtc_pool_size.h + * + * Declarations of: + * - the memory bank sizes and their watermark + * - the SWE stack size + * - the pool size needed (generally the sum of memory bank and stack sizes) + * + * @author Vincent Oberle + * @version 0.1 + */ + +/* + * History: + * + * Date Author Modification + * ------------------------------------------------------------------- + * 07/08/2003 Vincent Oberle Extracted from rvf_pool_size.h + * + * (C) Copyright 2003 by Texas Instruments Incorporated, All Rights Reserved + */ + +#ifndef __RTC_POOL_SIZE_H_ +#define __RTC_POOL_SIZE_H_ + + +/* + * Values used in rtc_env.h + */ +#define RTC_STACK_SIZE (700) +#define RTC_MB1_SIZE (100) +#define RTC_POOL_SIZE (RTC_STACK_SIZE + RTC_MB1_SIZE) + + +#endif /*__RTC_POOL_SIZE_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/bsp/rtc/rtc_process.c Sun Nov 17 22:10:10 2013 +0000 @@ -0,0 +1,49 @@ +/********************************************************************************/ +/* */ +/* File Name: rtc_process.c */ +/* */ +/* Purpose: This file contains routine(s) that dispatch and process */ +/* message(s) received from other entity */ +/* */ +/* Note: None. */ +/* */ +/* Revision History: */ +/* 03/22/01 Laurent Sollier Create. */ +/* */ +/* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved */ +/* */ +/********************************************************************************/ + +#include "rvf/rvf_api.h" +#include "rv/rv_general.h" +#include "rvm/rvm_use_id_list.h" +#include "rtc/rtc_messages_i.h" +#include "rtc/rtc_i.h" + + +void rtc_process(T_RV_HDR * msg_ptr) +{ + switch (msg_ptr->msg_id) + { + case RTC_ALARM_EVT: + rvf_send_trace("RTC: received RTC_ALARM event",29, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_MEDIUM, RTC_USE_ID ); + + RTC_ProcessAlarmEvent(); + /* free memory used for the RTC message */ + break; + + default: + /* Unknow message has been received */ + rvf_send_trace("RTC: Message received unknown",29, + NULL_PARAM, + RV_TRACE_LEVEL_ERROR, + RTC_USE_ID ); + break; + } +} + + + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/bsp/rtc/rtc_task.c Sun Nov 17 22:10:10 2013 +0000 @@ -0,0 +1,68 @@ +/** + * @file rtc_task.c + * + * Coding of the main RTC function : rtc_core + * This function loop in the process message function for waiting messages. + * + * @author Laurent Sollier (l-sollier@ti.com) + * @version 0.1 + */ + +/* + * History: + * + * Date Author Modification + * ------------------------------------ + * 10/24/2001 L Sollier Create + * + * + * (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved + */ + +#include "rtc/rtc_env.h" + +#include "rv/rv_general.h" +#include "rvf/rvf_api.h" +#include "rvm/rvm_use_id_list.h" + +#define RTC_MAILBOX_USED RVF_TASK_MBOX_0 + +/* External declaration until Riviera 1.6 is available*/ +extern UINT8 rtc_handle_msg(T_RV_HDR* msg_p); + + + +/** + * @name Functions implementation + * + */ +/*@{*/ + +/** + * function: rtc_core + */ +T_RV_RET rtc_core(void) +{ + BOOLEAN error_occured = FALSE; + T_RV_HDR * msg_ptr; + UINT16 received_event; + + rvf_send_trace("RTC: Initialization", 19, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, RTC_USE_ID ); + + /* loop to process messages */ + while (error_occured == FALSE) + { + /* Wait for the necessary events. */ + received_event = rvf_wait ( 0xffff,0); + + if (received_event & RVF_TASK_MBOX_0_EVT_MASK) + { + /* Read the message */ + msg_ptr = (T_RV_HDR *) rvf_read_mbox(RTC_MAILBOX_USED); + + rtc_handle_msg(msg_ptr); + } + } + + return RV_OK; +} \ No newline at end of file