2 * Copyright © 2011 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 * CC1111 definitions and code fragments for AltOS
27 /* Convert a __data pointer into an __xdata pointer */
28 #define DATA_TO_XDATA(a) ((void __xdata *) ((uint8_t) (a) | 0xff00))
30 /* Stack runs from above the allocated __data space to 0xfe, which avoids
31 * writing to 0xff as that triggers the stack overflow indicator
33 #define AO_STACK_START 0x90
34 #define AO_STACK_END 0xfe
35 #define AO_STACK_SIZE (AO_STACK_END - AO_STACK_START + 1)
37 #define ao_arch_reboot() do { \
38 WDCTL = WDCTL_EN | WDCTL_MODE_WATCHDOG | WDCTL_INT_64; \
39 ao_delay(AO_SEC_TO_TICKS(2)); \
42 #define ao_arch_nop() _asm nop _endasm
43 #define ao_arch_interrupt(n) __interrupt n
45 #define ao_arch_naked_declare __naked
46 #define ao_arch_naked_define __naked
48 /* CC1111-specific drivers */
54 #define AO_ROMCONFIG_VERSION 2
56 extern __code __at (0x00a0) uint16_t ao_romconfig_version;
57 extern __code __at (0x00a2) uint16_t ao_romconfig_check;
58 extern __code __at (0x00a4) uint16_t ao_serial_number;
59 extern __code __at (0x00a6) uint32_t ao_radio_cal;
62 #error Please define HAS_USB
66 extern __code __at (0x00aa) uint8_t ao_usb_descriptors [];
69 /* Initialize stack */
70 #define ao_arch_init_stack(task, start) { \
71 uint8_t __xdata *stack = task->stack; \
73 *stack++ = ((uint16_t) start); /* 0 */ \
74 *stack++ = ((uint16_t) start) >> 8; /* 1 */ \
76 /* and the stuff saved by ao_switch */ \
77 *stack++ = 0; /* 2 acc */ \
78 *stack++ = 0x80; /* 3 IE */ \
94 for (t = 0; t < 13; t++) \
96 task->stack_count = 17; \
101 /* Save current context */
103 #define ao_arch_save_context() \
105 /* Push ACC first, as when restoring the context it must be restored \
106 * last (it is used to set the IE register). */ \
108 /* Store the IE register then enable interrupts. */ \
131 #endif /* _AO_ARCH_H_ */