updated example name”

This commit is contained in:
2017-06-10 17:57:47 +08:00
parent 5de4ac202c
commit c5327f8717
827 changed files with 1 additions and 1 deletions

View File

@@ -0,0 +1,308 @@
/**************************************************************************************************
Filename: hal_assert.c
Revised: $Date: 2010-11-22 08:13:43 -0800 (Mon, 22 Nov 2010) $
Revision: $Revision: 24480 $
Description: Describe the purpose and contents of the file.
Copyright 2006-2010 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
/* ------------------------------------------------------------------------------------------------
* Includes
* ------------------------------------------------------------------------------------------------
*/
#include "hal_assert.h"
#include "hal_types.h"
#include "hal_board.h"
#include "hal_defs.h"
#include "hal_mcu.h"
#if (defined HAL_MCU_AVR) || (defined HAL_MCU_CC2430) || (defined HAL_MCU_CC2530) || \
(defined HAL_MCU_CC2533) || (defined HAL_MCU_MSP430)
/* for access to debug data */
#include "mac_rx.h"
#include "mac_tx.h"
#endif
/* ------------------------------------------------------------------------------------------------
* Local Prototypes
* ------------------------------------------------------------------------------------------------
*/
void halAssertHazardLights(void);
/**************************************************************************************************
* @fn halAssertHandler
*
* @brief Logic to handle an assert.
*
* @param none
*
* @return none
**************************************************************************************************
*/
void halAssertHandler(void)
{
/* execute code that handles asserts */
#ifdef ASSERT_RESET
HAL_SYSTEM_RESET();
#elif !defined ASSERT_WHILE
halAssertHazardLights();
#else
while(1);
#endif
}
#if !defined ASSERT_WHILE
/**************************************************************************************************
* @fn halAssertHazardLights
*
* @brief Blink LEDs to indicate an error.
*
* @param none
*
* @return none
**************************************************************************************************
*/
void halAssertHazardLights(void)
{
enum
{
DEBUG_DATA_RSTACK_HIGH_OFS,
DEBUG_DATA_RSTACK_LOW_OFS,
DEBUG_DATA_TX_ACTIVE_OFS,
DEBUG_DATA_RX_ACTIVE_OFS,
#if (defined HAL_MCU_AVR) || (defined HAL_MCU_CC2430)
DEBUG_DATA_INT_MASK_OFS,
#elif (defined HAL_MCU_CC2530) || (defined HAL_MCU_CC2533)
DEBUG_DATA_INT_MASK0_OFS,
DEBUG_DATA_INT_MASK1_OFS,
#endif
DEBUG_DATA_SIZE
};
uint8 buttonHeld;
uint8 debugData[DEBUG_DATA_SIZE];
/* disable all interrupts before anything else */
HAL_DISABLE_INTERRUPTS();
/*-------------------------------------------------------------------------------
* Initialize LEDs and turn them off.
*/
HAL_BOARD_INIT();
HAL_TURN_OFF_LED1();
HAL_TURN_OFF_LED2();
HAL_TURN_OFF_LED3();
HAL_TURN_OFF_LED4();
/*-------------------------------------------------------------------------------
* Master infinite loop.
*/
for (;;)
{
buttonHeld = 0;
/*-------------------------------------------------------------------------------
* "Hazard lights" loop. A held keypress will exit this loop.
*/
do
{
HAL_LED_BLINK_DELAY();
/* toggle LEDS, the #ifdefs are in case HAL has logically remapped non-existent LEDs */
#if (HAL_NUM_LEDS >= 1)
HAL_TOGGLE_LED1();
#if (HAL_NUM_LEDS >= 2)
HAL_TOGGLE_LED2();
#if (HAL_NUM_LEDS >= 3)
HAL_TOGGLE_LED3();
#if (HAL_NUM_LEDS >= 4)
HAL_TOGGLE_LED4();
#endif
#endif
#endif
#endif
/* escape hatch to continue execution, set escape to '1' to continue execution */
{
static uint8 escape = 0;
if (escape)
{
escape = 0;
return;
}
}
/* break out of loop if button is held long enough */
if (HAL_PUSH_BUTTON1())
{
buttonHeld++;
}
else
{
buttonHeld = 0;
}
}
while (buttonHeld != 10); /* loop until button is held specified number of loops */
/*-------------------------------------------------------------------------------
* Just exited from "hazard lights" loop.
*/
/* turn off all LEDs */
HAL_TURN_OFF_LED1();
HAL_TURN_OFF_LED2();
HAL_TURN_OFF_LED3();
HAL_TURN_OFF_LED4();
/* wait for button release */
HAL_DEBOUNCE(!HAL_PUSH_BUTTON1());
/*-------------------------------------------------------------------------------
* Load debug data into memory.
*/
#ifdef HAL_MCU_AVR
{
uint8 * pStack;
pStack = (uint8 *) SP;
pStack++; /* point to return address on stack */
debugData[DEBUG_DATA_RSTACK_HIGH_OFS] = *pStack;
pStack++;
debugData[DEBUG_DATA_RSTACK_LOW_OFS] = *pStack;
}
debugData[DEBUG_DATA_INT_MASK_OFS] = EIMSK;
#endif
#if (defined HAL_MCU_CC2430)
debugData[DEBUG_DATA_INT_MASK_OFS] = RFIM;
#elif (defined HAL_MCU_CC2530) || (defined HAL_MCU_CC2533)
debugData[DEBUG_DATA_INT_MASK0_OFS] = RFIRQM0;
debugData[DEBUG_DATA_INT_MASK1_OFS] = RFIRQM1;
#endif
#if (defined HAL_MCU_AVR) || (defined HAL_MCU_CC2430) || (defined HAL_MCU_CC2530) || \
(defined HAL_MCU_CC2533) || (defined HAL_MCU_MSP430)
debugData[DEBUG_DATA_TX_ACTIVE_OFS] = macTxActive;
debugData[DEBUG_DATA_RX_ACTIVE_OFS] = macRxActive;
#endif
/* initialize for data dump loop */
{
uint8 iBit;
uint8 iByte;
iBit = 0;
iByte = 0;
/*-------------------------------------------------------------------------------
* Data dump loop. A button press cycles data bits to an LED.
*/
while (iByte < DEBUG_DATA_SIZE)
{
/* wait for key press */
while(!HAL_PUSH_BUTTON1());
/* turn on all LEDs for first bit of byte, turn on three LEDs if not first bit */
HAL_TURN_ON_LED1();
HAL_TURN_ON_LED2();
HAL_TURN_ON_LED3();
if (iBit == 0)
{
HAL_TURN_ON_LED4();
}
else
{
HAL_TURN_OFF_LED4();
}
/* wait for debounced key release */
HAL_DEBOUNCE(!HAL_PUSH_BUTTON1());
/* turn off all LEDs */
HAL_TURN_OFF_LED1();
HAL_TURN_OFF_LED2();
HAL_TURN_OFF_LED3();
HAL_TURN_OFF_LED4();
/* output value of data bit to LED1 */
if (debugData[iByte] & (1 << (7 - iBit)))
{
HAL_TURN_ON_LED1();
}
else
{
HAL_TURN_OFF_LED1();
}
/* advance to next bit */
iBit++;
if (iBit == 8)
{
iBit = 0;
iByte++;
}
}
}
/*
* About to enter "hazard lights" loop again. Turn off LED1 in case the last bit
* displayed happened to be one. This guarantees all LEDs are off at the start of
* the flashing loop which uses a toggle operation to change LED states.
*/
HAL_TURN_OFF_LED1();
}
}
#endif
/* ------------------------------------------------------------------------------------------------
* Compile Time Assertions
* ------------------------------------------------------------------------------------------------
*/
/* integrity check of type sizes */
HAL_ASSERT_SIZE( int8, 1);
HAL_ASSERT_SIZE( uint8, 1);
HAL_ASSERT_SIZE( int16, 2);
HAL_ASSERT_SIZE(uint16, 2);
HAL_ASSERT_SIZE( int32, 4);
HAL_ASSERT_SIZE(uint32, 4);
/**************************************************************************************************
*/

View File

@@ -0,0 +1,283 @@
/**************************************************************************************************
Filename: hal_drivers.c
Revised: $Date: 2007-07-06 10:42:24 -0700 (Fri, 06 Jul 2007) $
Revision: $Revision: 13579 $
Description: This file contains the interface to the Drivers Service.
Copyright 2005-2012 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
/**************************************************************************************************
* INCLUDES
**************************************************************************************************/
#include "hal_adc.h"
#if (defined HAL_AES) && (HAL_AES == TRUE)
#include "hal_aes.h"
#endif
#if (defined HAL_BUZZER) && (HAL_BUZZER == TRUE)
#include "hal_buzzer.h"
#endif
#if (defined HAL_DMA) && (HAL_DMA == TRUE)
#include "hal_dma.h"
#endif
#include "hal_drivers.h"
#include "hal_key.h"
#include "hal_lcd.h"
#include "hal_led.h"
#include "hal_sleep.h"
#include "hal_timer.h"
#include "hal_types.h"
#include "hal_uart.h"
#ifdef CC2591_COMPRESSION_WORKAROUND
#include "mac_rx.h"
#endif
#include "OSAL.h"
#if defined POWER_SAVING
#include "OSAL_PwrMgr.h"
#endif
#if (defined HAL_HID) && (HAL_HID == TRUE)
#include "usb_hid.h"
#endif
/**************************************************************************************************
* GLOBAL VARIABLES
**************************************************************************************************/
uint8 Hal_TaskID;
extern void HalLedUpdate( void ); /* Notes: This for internal only so it shouldn't be in hal_led.h */
/**************************************************************************************************
* @fn Hal_Init
*
* @brief Hal Initialization function.
*
* @param task_id - Hal TaskId
*
* @return None
**************************************************************************************************/
void Hal_Init( uint8 task_id )
{
/* Register task ID */
Hal_TaskID = task_id;
#ifdef CC2591_COMPRESSION_WORKAROUND
osal_start_reload_timer( Hal_TaskID, PERIOD_RSSI_RESET_EVT, PERIOD_RSSI_RESET_TIMEOUT );
#endif
}
/**************************************************************************************************
* @fn Hal_DriverInit
*
* @brief Initialize HW - These need to be initialized before anyone.
*
* @param task_id - Hal TaskId
*
* @return None
**************************************************************************************************/
void HalDriverInit (void)
{
/* TIMER */
#if (defined HAL_TIMER) && (HAL_TIMER == TRUE)
#endif
/* ADC */
#if (defined HAL_ADC) && (HAL_ADC == TRUE)
HalAdcInit();
#endif
/* DMA */
#if (defined HAL_DMA) && (HAL_DMA == TRUE)
// Must be called before the init call to any module that uses DMA.
HalDmaInit();
#endif
/* AES */
#if (defined HAL_AES) && (HAL_AES == TRUE)
HalAesInit();
#endif
/* LCD */
#if (defined HAL_LCD) && (HAL_LCD == TRUE)
HalLcdInit();
#endif
/* LED */
#if (defined HAL_LED) && (HAL_LED == TRUE)
HalLedInit();
#endif
/* UART */
#if (defined HAL_UART) && (HAL_UART == TRUE)
HalUARTInit();
#endif
/* KEY */
#if (defined HAL_KEY) && (HAL_KEY == TRUE)
HalKeyInit();
#endif
/* HID */
#if (defined HAL_HID) && (HAL_HID == TRUE)
usbHidInit();
#endif
}
/**************************************************************************************************
* @fn Hal_ProcessEvent
*
* @brief Hal Process Event
*
* @param task_id - Hal TaskId
* events - events
*
* @return None
**************************************************************************************************/
uint16 Hal_ProcessEvent( uint8 task_id, uint16 events )
{
uint8 *msgPtr;
(void)task_id; // Intentionally unreferenced parameter
if ( events & SYS_EVENT_MSG )
{
msgPtr = osal_msg_receive(Hal_TaskID);
while (msgPtr)
{
/* Do something here - for now, just deallocate the msg and move on */
/* De-allocate */
osal_msg_deallocate( msgPtr );
/* Next */
msgPtr = osal_msg_receive( Hal_TaskID );
}
return events ^ SYS_EVENT_MSG;
}
#if (defined HAL_BUZZER) && (HAL_BUZZER == TRUE)
if (events & HAL_BUZZER_EVENT)
{
HalBuzzerStop();
return events ^ HAL_BUZZER_EVENT;
}
#endif
#ifdef CC2591_COMPRESSION_WORKAROUND
if ( events & PERIOD_RSSI_RESET_EVT )
{
macRxResetRssi();
return (events ^ PERIOD_RSSI_RESET_EVT);
}
#endif
if ( events & HAL_LED_BLINK_EVENT )
{
#if (defined (BLINK_LEDS)) && (HAL_LED == TRUE)
HalLedUpdate();
#endif /* BLINK_LEDS && HAL_LED */
return events ^ HAL_LED_BLINK_EVENT;
}
if (events & HAL_KEY_EVENT)
{
#if (defined HAL_KEY) && (HAL_KEY == TRUE)
/* Check for keys */
HalKeyPoll();
/* if interrupt disabled, do next polling */
if (!Hal_KeyIntEnable)
{
osal_start_timerEx( Hal_TaskID, HAL_KEY_EVENT, 100);
}
#endif
return events ^ HAL_KEY_EVENT;
}
#if defined POWER_SAVING
if ( events & HAL_SLEEP_TIMER_EVENT )
{
halRestoreSleepLevel();
return events ^ HAL_SLEEP_TIMER_EVENT;
}
if ( events & HAL_PWRMGR_HOLD_EVENT )
{
(void)osal_pwrmgr_task_state(Hal_TaskID, PWRMGR_HOLD);
(void)osal_stop_timerEx(Hal_TaskID, HAL_PWRMGR_CONSERVE_EVENT);
(void)osal_clear_event(Hal_TaskID, HAL_PWRMGR_CONSERVE_EVENT);
return (events & ~(HAL_PWRMGR_HOLD_EVENT | HAL_PWRMGR_CONSERVE_EVENT));
}
if ( events & HAL_PWRMGR_CONSERVE_EVENT )
{
(void)osal_pwrmgr_task_state(Hal_TaskID, PWRMGR_CONSERVE);
return events ^ HAL_PWRMGR_CONSERVE_EVENT;
}
#endif
return 0;
}
/**************************************************************************************************
* @fn Hal_ProcessPoll
*
* @brief This routine will be called by OSAL to poll UART, TIMER...
*
* @param task_id - Hal TaskId
*
* @return None
**************************************************************************************************/
void Hal_ProcessPoll ()
{
/* UART Poll */
#if (defined HAL_UART) && (HAL_UART == TRUE)
HalUARTPoll();
#endif
/* HID poll */
#if (defined HAL_HID) && (HAL_HID == TRUE)
usbHidProcessEvents();
#endif
#if defined( POWER_SAVING )
/* Allow sleep before the next OSAL event loop */
ALLOW_SLEEP_MODE();
#endif
}
/**************************************************************************************************
**************************************************************************************************/