Skip to content

Commit b489640

Browse files
committedMay 24, 2014
zigbee
0 parents  commit b489640

File tree

1,417 files changed

+2224339
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,417 files changed

+2224339
-0
lines changed
 

‎Components/hal/common/hal_assert.c

+307
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
/**************************************************************************************************
2+
Filename: hal_assert.c
3+
Revised: $Date: 2010-01-07 10:10:43 -0800 (Thu, 07 Jan 2010) $
4+
Revision: $Revision: 21451 $
5+
6+
Description: Describe the purpose and contents of the file.
7+
8+
9+
Copyright 2006-2010 Texas Instruments Incorporated. All rights reserved.
10+
11+
IMPORTANT: Your use of this Software is limited to those specific rights
12+
granted under the terms of a software license agreement between the user
13+
who downloaded the software, his/her employer (which must be your employer)
14+
and Texas Instruments Incorporated (the "License"). You may not use this
15+
Software unless you agree to abide by the terms of the License. The License
16+
limits your use, and you acknowledge, that the Software may not be modified,
17+
copied or distributed unless embedded on a Texas Instruments microcontroller
18+
or used solely and exclusively in conjunction with a Texas Instruments radio
19+
frequency transceiver, which is integrated into your product. Other than for
20+
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
21+
works of, modify, distribute, perform, display or sell this Software and/or
22+
its documentation for any purpose.
23+
24+
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
25+
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
26+
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
27+
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
28+
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
29+
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
30+
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
31+
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
32+
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
33+
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
34+
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
35+
36+
Should you have any questions regarding your right to use this Software,
37+
contact Texas Instruments Incorporated at www.TI.com.
38+
**************************************************************************************************/
39+
40+
41+
/* ------------------------------------------------------------------------------------------------
42+
* Includes
43+
* ------------------------------------------------------------------------------------------------
44+
*/
45+
#include "hal_assert.h"
46+
#include "hal_types.h"
47+
#include "hal_board.h"
48+
#include "hal_defs.h"
49+
#include "hal_mcu.h"
50+
51+
#if (defined HAL_MCU_AVR) || (defined HAL_MCU_CC2430) || (defined HAL_MCU_CC2530) || \
52+
(defined HAL_MCU_CC2533) || (defined HAL_MCU_MSP430)
53+
/* for access to debug data */
54+
#include "mac_rx.h"
55+
#include "mac_tx.h"
56+
#endif
57+
58+
/* ------------------------------------------------------------------------------------------------
59+
* Local Prototypes
60+
* ------------------------------------------------------------------------------------------------
61+
*/
62+
void halAssertHazardLights(void);
63+
64+
65+
/**************************************************************************************************
66+
* @fn halAssertHandler
67+
*
68+
* @brief Logic to handle an assert.
69+
*
70+
* @param none
71+
*
72+
* @return none
73+
**************************************************************************************************
74+
*/
75+
void halAssertHandler(void)
76+
{
77+
/* execute code that handles asserts */
78+
#ifdef ASSERT_RESET
79+
HAL_SYSTEM_RESET();
80+
#else
81+
halAssertHazardLights();
82+
#endif
83+
84+
}
85+
86+
87+
/**************************************************************************************************
88+
* @fn halAssertHazardLights
89+
*
90+
* @brief Blink LEDs to indicate an error.
91+
*
92+
* @param none
93+
*
94+
* @return none
95+
**************************************************************************************************
96+
*/
97+
void halAssertHazardLights(void)
98+
{
99+
enum
100+
{
101+
DEBUG_DATA_RSTACK_HIGH_OFS,
102+
DEBUG_DATA_RSTACK_LOW_OFS,
103+
DEBUG_DATA_TX_ACTIVE_OFS,
104+
DEBUG_DATA_RX_ACTIVE_OFS,
105+
106+
#if (defined HAL_MCU_AVR) || (defined HAL_MCU_CC2430)
107+
DEBUG_DATA_INT_MASK_OFS,
108+
#elif (defined HAL_MCU_CC2530) || (defined HAL_MCU_CC2533)
109+
DEBUG_DATA_INT_MASK0_OFS,
110+
DEBUG_DATA_INT_MASK1_OFS,
111+
#endif
112+
113+
DEBUG_DATA_SIZE
114+
};
115+
116+
uint8 buttonHeld;
117+
uint8 debugData[DEBUG_DATA_SIZE];
118+
119+
/* disable all interrupts before anything else */
120+
HAL_DISABLE_INTERRUPTS();
121+
122+
/*-------------------------------------------------------------------------------
123+
* Initialize LEDs and turn them off.
124+
*/
125+
HAL_BOARD_INIT();
126+
127+
HAL_TURN_OFF_LED1();
128+
HAL_TURN_OFF_LED2();
129+
HAL_TURN_OFF_LED3();
130+
HAL_TURN_OFF_LED4();
131+
132+
/*-------------------------------------------------------------------------------
133+
* Master infinite loop.
134+
*/
135+
for (;;)
136+
{
137+
buttonHeld = 0;
138+
139+
/*-------------------------------------------------------------------------------
140+
* "Hazard lights" loop. A held keypress will exit this loop.
141+
*/
142+
do
143+
{
144+
HAL_LED_BLINK_DELAY();
145+
146+
/* toggle LEDS, the #ifdefs are in case HAL has logically remapped non-existent LEDs */
147+
#if (HAL_NUM_LEDS >= 1)
148+
HAL_TOGGLE_LED1();
149+
#if (HAL_NUM_LEDS >= 2)
150+
HAL_TOGGLE_LED2();
151+
#if (HAL_NUM_LEDS >= 3)
152+
HAL_TOGGLE_LED3();
153+
#if (HAL_NUM_LEDS >= 4)
154+
HAL_TOGGLE_LED4();
155+
#endif
156+
#endif
157+
#endif
158+
#endif
159+
160+
/* escape hatch to continue execution, set escape to '1' to continue execution */
161+
{
162+
static uint8 escape = 0;
163+
if (escape)
164+
{
165+
escape = 0;
166+
return;
167+
}
168+
}
169+
170+
/* break out of loop if button is held long enough */
171+
if (HAL_PUSH_BUTTON1())
172+
{
173+
buttonHeld++;
174+
}
175+
else
176+
{
177+
buttonHeld = 0;
178+
}
179+
}
180+
while (buttonHeld != 10); /* loop until button is held specified number of loops */
181+
182+
/*-------------------------------------------------------------------------------
183+
* Just exited from "hazard lights" loop.
184+
*/
185+
186+
/* turn off all LEDs */
187+
HAL_TURN_OFF_LED1();
188+
HAL_TURN_OFF_LED2();
189+
HAL_TURN_OFF_LED3();
190+
HAL_TURN_OFF_LED4();
191+
192+
/* wait for button release */
193+
HAL_DEBOUNCE(!HAL_PUSH_BUTTON1());
194+
195+
/*-------------------------------------------------------------------------------
196+
* Load debug data into memory.
197+
*/
198+
#ifdef HAL_MCU_AVR
199+
{
200+
uint8 * pStack;
201+
pStack = (uint8 *) SP;
202+
pStack++; /* point to return address on stack */
203+
debugData[DEBUG_DATA_RSTACK_HIGH_OFS] = *pStack;
204+
pStack++;
205+
debugData[DEBUG_DATA_RSTACK_LOW_OFS] = *pStack;
206+
}
207+
debugData[DEBUG_DATA_INT_MASK_OFS] = EIMSK;
208+
#endif
209+
210+
#if (defined HAL_MCU_CC2430)
211+
debugData[DEBUG_DATA_INT_MASK_OFS] = RFIM;
212+
#elif (defined HAL_MCU_CC2530) || (defined HAL_MCU_CC2533)
213+
debugData[DEBUG_DATA_INT_MASK0_OFS] = RFIRQM0;
214+
debugData[DEBUG_DATA_INT_MASK1_OFS] = RFIRQM1;
215+
#endif
216+
217+
218+
#if (defined HAL_MCU_AVR) || (defined HAL_MCU_CC2430) || (defined HAL_MCU_CC2530) || \
219+
(defined HAL_MCU_CC2533) || (defined HAL_MCU_MSP430)
220+
debugData[DEBUG_DATA_TX_ACTIVE_OFS] = macTxActive;
221+
debugData[DEBUG_DATA_RX_ACTIVE_OFS] = macRxActive;
222+
#endif
223+
224+
/* initialize for data dump loop */
225+
{
226+
uint8 iBit;
227+
uint8 iByte;
228+
229+
iBit = 0;
230+
iByte = 0;
231+
232+
/*-------------------------------------------------------------------------------
233+
* Data dump loop. A button press cycles data bits to an LED.
234+
*/
235+
while (iByte < DEBUG_DATA_SIZE)
236+
{
237+
/* wait for key press */
238+
while(!HAL_PUSH_BUTTON1());
239+
240+
/* turn on all LEDs for first bit of byte, turn on three LEDs if not first bit */
241+
HAL_TURN_ON_LED1();
242+
HAL_TURN_ON_LED2();
243+
HAL_TURN_ON_LED3();
244+
if (iBit == 0)
245+
{
246+
HAL_TURN_ON_LED4();
247+
}
248+
else
249+
{
250+
HAL_TURN_OFF_LED4();
251+
}
252+
253+
/* wait for debounced key release */
254+
HAL_DEBOUNCE(!HAL_PUSH_BUTTON1());
255+
256+
/* turn off all LEDs */
257+
HAL_TURN_OFF_LED1();
258+
HAL_TURN_OFF_LED2();
259+
HAL_TURN_OFF_LED3();
260+
HAL_TURN_OFF_LED4();
261+
262+
/* output value of data bit to LED1 */
263+
if (debugData[iByte] & (1 << (7 - iBit)))
264+
{
265+
HAL_TURN_ON_LED1();
266+
}
267+
else
268+
{
269+
HAL_TURN_OFF_LED1();
270+
}
271+
272+
/* advance to next bit */
273+
iBit++;
274+
if (iBit == 8)
275+
{
276+
iBit = 0;
277+
iByte++;
278+
}
279+
}
280+
}
281+
282+
/*
283+
* About to enter "hazard lights" loop again. Turn off LED1 in case the last bit
284+
* displayed happened to be one. This guarantees all LEDs are off at the start of
285+
* the flashing loop which uses a toggle operation to change LED states.
286+
*/
287+
HAL_TURN_OFF_LED1();
288+
}
289+
}
290+
291+
292+
/* ------------------------------------------------------------------------------------------------
293+
* Compile Time Assertions
294+
* ------------------------------------------------------------------------------------------------
295+
*/
296+
297+
/* integrity check of type sizes */
298+
HAL_ASSERT_SIZE( int8, 1);
299+
HAL_ASSERT_SIZE( uint8, 1);
300+
HAL_ASSERT_SIZE( int16, 2);
301+
HAL_ASSERT_SIZE(uint16, 2);
302+
HAL_ASSERT_SIZE( int32, 4);
303+
HAL_ASSERT_SIZE(uint32, 4);
304+
305+
306+
/**************************************************************************************************
307+
*/

‎Components/hal/common/hal_drivers.c

+288
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
/**************************************************************************************************
2+
Filename: hal_drivers.c
3+
Revised: $Date: 2007-07-06 10:42:24 -0700 (Fri, 06 Jul 2007) $
4+
Revision: $Revision: 13579 $
5+
6+
Description: This file contains the interface to the Drivers Service.
7+
8+
9+
Copyright 2005-2009 Texas Instruments Incorporated. All rights reserved.
10+
11+
IMPORTANT: Your use of this Software is limited to those specific rights
12+
granted under the terms of a software license agreement between the user
13+
who downloaded the software, his/her employer (which must be your employer)
14+
and Texas Instruments Incorporated (the "License"). You may not use this
15+
Software unless you agree to abide by the terms of the License. The License
16+
limits your use, and you acknowledge, that the Software may not be modified,
17+
copied or distributed unless embedded on a Texas Instruments microcontroller
18+
or used solely and exclusively in conjunction with a Texas Instruments radio
19+
frequency transceiver, which is integrated into your product. Other than for
20+
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
21+
works of, modify, distribute, perform, display or sell this Software and/or
22+
its documentation for any purpose.
23+
24+
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
25+
PROVIDED “AS IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
26+
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
27+
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
28+
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
29+
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
30+
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
31+
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
32+
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
33+
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
34+
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
35+
36+
Should you have any questions regarding your right to use this Software,
37+
contact Texas Instruments Incorporated at www.TI.com.
38+
**************************************************************************************************/
39+
40+
41+
/**************************************************************************************************
42+
* INCLUDES
43+
**************************************************************************************************/
44+
#include "hal_types.h"
45+
#include "OSAL.h"
46+
#include "hal_drivers.h"
47+
#include "hal_adc.h"
48+
#if (defined HAL_DMA) && (HAL_DMA == TRUE)
49+
#include "hal_dma.h"
50+
#endif
51+
#include "hal_flash.h"
52+
#include "hal_key.h"
53+
#include "hal_lcd.h"
54+
#include "hal_led.h"
55+
#include "hal_timer.h"
56+
#include "hal_uart.h"
57+
#include "hal_sleep.h"
58+
#if (defined HAL_AES) && (HAL_AES == TRUE)
59+
#include "hal_aes.h"
60+
#endif
61+
62+
#if (defined HAL_SPI) && (HAL_SPI == TRUE)
63+
#include "hal_spi.h"
64+
#endif
65+
#if (defined HAL_HID) && (HAL_HID == TRUE)
66+
#include "usb_hid.h"
67+
#endif
68+
69+
/**************************************************************************************************
70+
* MACROS
71+
**************************************************************************************************/
72+
73+
74+
75+
/**************************************************************************************************
76+
* CONSTANTS
77+
**************************************************************************************************/
78+
79+
80+
/**************************************************************************************************
81+
* TYPEDEFS
82+
**************************************************************************************************/
83+
84+
85+
/**************************************************************************************************
86+
* GLOBAL VARIABLES
87+
**************************************************************************************************/
88+
uint8 Hal_TaskID;
89+
90+
extern void HalLedUpdate( void ); /* Notes: This for internal only so it shouldn't be in hal_led.h */
91+
92+
/**************************************************************************************************
93+
* FUNCTIONS - API
94+
**************************************************************************************************/
95+
96+
/**************************************************************************************************
97+
* @fn Hal_Init
98+
*
99+
* @brief Hal Initialization function.
100+
*
101+
* @param task_id - Hal TaskId
102+
*
103+
* @return None
104+
**************************************************************************************************/
105+
void Hal_Init( uint8 task_id )
106+
{
107+
/* Register task ID */
108+
Hal_TaskID = task_id;
109+
}
110+
111+
/**************************************************************************************************
112+
* @fn Hal_DriverInit
113+
*
114+
* @brief Initialize HW - These need to be initialized before anyone.
115+
*
116+
* @param task_id - Hal TaskId
117+
*
118+
* @return None
119+
**************************************************************************************************/
120+
void HalDriverInit (void)
121+
{
122+
/* TIMER */
123+
#if (defined HAL_TIMER) && (HAL_TIMER == TRUE)
124+
HalTimerInit();
125+
#endif
126+
127+
/* ADC */
128+
#if (defined HAL_ADC) && (HAL_ADC == TRUE)
129+
HalAdcInit();
130+
#endif
131+
132+
/* DMA */
133+
#if (defined HAL_DMA) && (HAL_DMA == TRUE)
134+
// Must be called before the init call to any module that uses DMA.
135+
HalDmaInit();
136+
#endif
137+
138+
/* Flash */
139+
#if (defined HAL_FLASH) && (HAL_FLASH == TRUE)
140+
// Must be called before the init call to any module that uses Flash access or NV.
141+
HalFlashInit();
142+
#endif
143+
144+
/* AES */
145+
#if (defined HAL_AES) && (HAL_AES == TRUE)
146+
HalAesInit();
147+
#endif
148+
149+
/* LCD */
150+
#if (defined HAL_LCD) && (HAL_LCD == TRUE)
151+
HalLcdInit();
152+
#endif
153+
154+
/* LED */
155+
#if (defined HAL_LED) && (HAL_LED == TRUE)
156+
HalLedInit();
157+
#endif
158+
159+
/* UART */
160+
#if (defined HAL_UART) && (HAL_UART == TRUE)
161+
HalUARTInit();
162+
#endif
163+
164+
/* KEY */
165+
#if (defined HAL_KEY) && (HAL_KEY == TRUE)
166+
HalKeyInit();
167+
#endif
168+
169+
/* SPI */
170+
#if (defined HAL_SPI) && (HAL_SPI == TRUE)
171+
HalSpiInit();
172+
#endif
173+
174+
/* HID */
175+
#if (defined HAL_HID) && (HAL_HID == TRUE)
176+
usbHidInit();
177+
#endif
178+
}
179+
180+
181+
/**************************************************************************************************
182+
* @fn Hal_ProcessEvent
183+
*
184+
* @brief Hal Process Event
185+
*
186+
* @param task_id - Hal TaskId
187+
* events - events
188+
*
189+
* @return None
190+
**************************************************************************************************/
191+
uint16 Hal_ProcessEvent( uint8 task_id, uint16 events )
192+
{
193+
uint8 *msgPtr;
194+
195+
(void)task_id; // Intentionally unreferenced parameter
196+
197+
if ( events & SYS_EVENT_MSG )
198+
{
199+
msgPtr = osal_msg_receive(Hal_TaskID);
200+
201+
while (msgPtr)
202+
{
203+
/* Do something here - for now, just deallocate the msg and move on */
204+
205+
/* De-allocate */
206+
osal_msg_deallocate( msgPtr );
207+
/* Next */
208+
msgPtr = osal_msg_receive( Hal_TaskID );
209+
}
210+
return events ^ SYS_EVENT_MSG;
211+
}
212+
213+
if ( events & HAL_LED_BLINK_EVENT )
214+
{
215+
#if (defined (BLINK_LEDS)) && (HAL_LED == TRUE)
216+
HalLedUpdate();
217+
#endif /* BLINK_LEDS && HAL_LED */
218+
return events ^ HAL_LED_BLINK_EVENT;
219+
}
220+
221+
if (events & HAL_KEY_EVENT)
222+
{
223+
224+
#if (defined HAL_KEY) && (HAL_KEY == TRUE)
225+
/* Check for keys */
226+
HalKeyPoll();
227+
228+
/* if interrupt disabled, do next polling */
229+
if (!Hal_KeyIntEnable)
230+
{
231+
osal_start_timerEx( Hal_TaskID, HAL_KEY_EVENT, 100);
232+
}
233+
#endif // HAL_KEY
234+
235+
return events ^ HAL_KEY_EVENT;
236+
}
237+
238+
#ifdef POWER_SAVING
239+
if ( events & HAL_SLEEP_TIMER_EVENT )
240+
{
241+
halRestoreSleepLevel();
242+
return events ^ HAL_SLEEP_TIMER_EVENT;
243+
}
244+
#endif
245+
246+
/* Nothing interested, discard the message */
247+
return 0;
248+
249+
}
250+
251+
/**************************************************************************************************
252+
* @fn Hal_ProcessPoll
253+
*
254+
* @brief This routine will be called by OSAL to poll UART, TIMER...
255+
*
256+
* @param task_id - Hal TaskId
257+
*
258+
* @return None
259+
**************************************************************************************************/
260+
void Hal_ProcessPoll ()
261+
{
262+
263+
/* Timer Poll */
264+
#if (defined HAL_TIMER) && (HAL_TIMER == TRUE)
265+
HalTimerTick();
266+
#endif
267+
268+
/* UART Poll */
269+
#if (defined HAL_UART) && (HAL_UART == TRUE)
270+
HalUARTPoll();
271+
#endif
272+
273+
/* SPI Poll */
274+
#if (defined HAL_SPI) && (HAL_SPI == TRUE)
275+
HalSpiPoll();
276+
#endif
277+
278+
/* HID poll */
279+
#if (defined HAL_HID) && (HAL_HID == TRUE)
280+
usbHidProcessEvents();
281+
#endif
282+
283+
}
284+
285+
286+
/**************************************************************************************************
287+
**************************************************************************************************/
288+

0 commit comments

Comments
 (0)
Please sign in to comment.