From: Keith Packard Date: Sun, 5 Aug 2018 04:17:19 +0000 (+0800) Subject: altos: Remove cc1111 products X-Git-Tag: 1.9~27^2~45 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=56629222711ba3ef7853405c9b07ad614fb29b95 altos: Remove cc1111 products We're not testing these anyways; building new firmware for them is not helpful. Signed-off-by: Keith Packard --- diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 144d21d7..cddc78d3 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -118,26 +118,18 @@ LINUX_MIMETYPE =\ $(ICONDIR)/org-altusmetrum-mimetypes.xml # Firmware -FIRMWARE_TD_0_2=$(top_srcdir)/src/teledongle-v0.2/teledongle-v0.2-$(VERSION).ihx FIRMWARE_TD_3_0=$(top_srcdir)/src/teledongle-v3.0/teledongle-v3.0-$(VERSION).ihx -FIRMWARE_TD=$(FIRMWARE_TD_0_2) $(FIRMWARE_TD_3_0) +FIRMWARE_TD=$(FIRMWARE_TD_3_0) -FIRMWARE_TM_1_0=$(top_srcdir)/src/telemetrum-v1.0/telemetrum-v1.0-$(VERSION).ihx -FIRMWARE_TM_1_1=$(top_srcdir)/src/telemetrum-v1.1/telemetrum-v1.1-$(VERSION).ihx -FIRMWARE_TM_1_2=$(top_srcdir)/src/telemetrum-v1.2/telemetrum-v1.2-$(VERSION).ihx FIRMWARE_TM_2_0=$(top_srcdir)/src/telemetrum-v2.0/telemetrum-v2.0-$(VERSION).ihx -#FIRMWARE_TM_3_0=$(top_srcdir)/src/telemetrum-v3.0/telemetrum-v3.0-$(VERSION).ihx -#FIRMWARE_TM=$(FIRMWARE_TM_1_0) $(FIRMWARE_TM_1_1) $(FIRMWARE_TM_1_2) $(FIRMWARE_TM_2_0) $(FIRMWARE_TM_3_0) -FIRMWARE_TM=$(FIRMWARE_TM_1_0) $(FIRMWARE_TM_1_1) $(FIRMWARE_TM_1_2) $(FIRMWARE_TM_2_0) +FIRMWARE_TM=$(FIRMWARE_TM_2_0) -FIRMWARE_TELEMINI_1_0=$(top_srcdir)/src/telemini-v1.0/telemini-v1.0-$(VERSION).ihx FIRMWARE_TELEMINI_3_0=$(top_srcdir)/src/telemini-v3.0/telemini-v3.0-$(VERSION).ihx -FIRMWARE_TELEMINI=$(FIRMWARE_TELEMINI_1_0) $(FIRMWARE_TELEMINI_3_0) +FIRMWARE_TELEMINI=$(FIRMWARE_TELEMINI_3_0) -FIRMWARE_TBT_1_0=$(top_srcdir)/src/telebt-v1.0/telebt-v1.0-$(VERSION).ihx FIRMWARE_TBT_3_0=$(top_srcdir)/src/telebt-v3.0/telebt-v3.0-$(VERSION).ihx FIRMWARE_TBT_4_0=$(top_srcdir)/src/telebt-v4.0/telebt-v4.0-$(VERSION).ihx -FIRMWARE_TBT=$(FIRMWARE_TBT_1_0) $(FIRMWARE_TBT_3_0) $(FIRMWARE_TBT_4_0) +FIRMWARE_TBT=$(FIRMWARE_TBT_3_0) $(FIRMWARE_TBT_4_0) FIRMWARE_TMEGA_1_0=$(top_srcdir)/src/telemega-v1.0/telemega-v1.0-$(VERSION).ihx FIRMWARE_TMEGA_2_0=$(top_srcdir)/src/telemega-v2.0/telemega-v2.0-$(VERSION).ihx diff --git a/altosui/altos-windows.nsi.in b/altosui/altos-windows.nsi.in index be9fb433..7aca30e2 100644 --- a/altosui/altos-windows.nsi.in +++ b/altosui/altos-windows.nsi.in @@ -120,18 +120,12 @@ Section "Firmware" SetOutPath $INSTDIR - File "../src/telemetrum-v1.0/telemetrum-v1.0-${VERSION}.ihx" - File "../src/telemetrum-v1.1/telemetrum-v1.1-${VERSION}.ihx" - File "../src/telemetrum-v1.2/telemetrum-v1.2-${VERSION}.ihx" File "../src/telemetrum-v2.0/telemetrum-v2.0-${VERSION}.ihx" ; File "../src/telemetrum-v3.0/telemetrum-v3.0-${VERSION}.ihx" - File "../src/telemini-v1.0/telemini-v1.0-${VERSION}.ihx" File "../src/telemini-v3.0/telemini-v3.0-${VERSION}.ihx" File "../src/telegps-v1.0/telegps-v1.0-${VERSION}.ihx" File "../src/telegps-v2.0/telegps-v2.0-${VERSION}.ihx" - File "../src/teledongle-v0.2/teledongle-v0.2-${VERSION}.ihx" File "../src/teledongle-v3.0/teledongle-v3.0-${VERSION}.ihx" - File "../src/telebt-v1.0/telebt-v1.0-${VERSION}.ihx" File "../src/telebt-v3.0/telebt-v3.0-${VERSION}.ihx" File "../src/telebt-v4.0/telebt-v4.0-${VERSION}.ihx" File "../src/telemega-v1.0/telemega-v1.0-${VERSION}.ihx" diff --git a/configure.ac b/configure.ac index 9dba0a5e..519f18f1 100644 --- a/configure.ac +++ b/configure.ac @@ -209,36 +209,6 @@ if test "x$GCC" = "xyes"; then fi AC_SUBST(WARN_CFLAGS) -# -# Configure SDCC -# - -AC_ARG_WITH([sdcc], - [AS_HELP_STRING([--with-sdcc], - [Name of SDCC])], - [], - [with_sdcc=auto]) - -if test "x$with_sdcc" != "xno"; then - if test "x$with_sdcc" = "xauto"; then - with_sdcc="sdcc" - AC_CHECK_PROG([HAVE_SDCC],[$with_sdcc], yes, no) - else - HAVE_SDCC=yes - fi -else - HAVE_SDCC=no -fi - -if test "x$HAVE_SDCC" = "xno"; then - AC_MSG_WARN([SDCC not found, cc1111 binaries will not be built]) -else - SDCC=$with_sdcc -fi - -AC_SUBST(SDCC) -AC_SUBST(HAVE_SDCC) - # # Configure ARM compiler for STM32L and LPC11U14 # @@ -587,8 +557,6 @@ echo " Configuration" echo " Arm compiler................: ${ARM_CC}" echo " STM32L support..............: ${HAVE_ARM_M3_CC}" echo " LPC11U14 support............: ${HAVE_ARM_M0_CC}" -echo " SDCC........................: ${SDCC}" -echo " CC1111 support..............: ${HAVE_SDCC}" echo " AVR compiler................: ${AVR_CC} ${AVR_OBJCOPY}" echo " AVR support.................: ${HAVE_AVR_CC}" echo " Android support.............: ${HAVE_ANDROID_SDK}" diff --git a/src/Makefile b/src/Makefile index a1ff84c2..3e00d70c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -16,14 +16,6 @@ include Version TOPDIR=. include Makedefs -SDCCDIRS=\ - telemetrum-v1.2 telemetrum-v1.1 telemetrum-v1.0 \ - teledongle-v0.2 \ - telemini-v1.0 \ - telebt-v1.0 \ - telefire-v0.1 telefire-v0.2 \ - telerepeat-v1.0 - ARMM3DIRS=\ easymega-v1.0 easymega-v1.0/flash-loader \ telemega-v0.1 telemega-v0.1/flash-loader \ @@ -59,15 +51,6 @@ AVRDIRS=\ SUBDIRS= -ifeq ($(strip $(HAVE_PDCLIB)),yes) -PDCLIB=pdclib -CLEAN_PDCLIB=clean-pdclib -endif - -ifeq ($(strip $(HAVE_SDCC)),yes) -SUBDIRS+=$(SDCCDIRS) -endif - ifeq ($(strip $(HAVE_ARM_M3_CC)),yes) SUBDIRS+=$(ARMM3DIRS) foo=bar @@ -82,7 +65,7 @@ ifeq ($(strip $(HAVE_AVR_CC)),yes) SUBDIRS += $(AVRDIRS) endif -ALLDIRS=$(SDCCDIRS) $(ARMM3DIRS) $(ARMM0DIRS) $(AVRDIRS) +ALLDIRS=$(ARMM3DIRS) $(ARMM0DIRS) $(AVRDIRS) all: all-local all-recursive diff --git a/src/cc1111/Makefile.cc1111 b/src/cc1111/Makefile.cc1111 deleted file mode 100644 index cb2d3db4..00000000 --- a/src/cc1111/Makefile.cc1111 +++ /dev/null @@ -1,39 +0,0 @@ -include ../Makedefs -CC=$(SDCC) - -CFLAGS=--model-small --debug --opt-code-speed -DCODESIZE=$(CODESIZE) -DCC1111 - -CFLAGS += $(PRODUCT_DEF) -I. -I.. -I../kernel -I../cc1111 -I../drivers -I../product - -CODESIZE ?= 0x8000 - -LDFLAGS=--out-fmt-ihx --code-loc 0x0000 --code-size $(CODESIZE) \ - --xram-loc 0xf000 --xram-size 0xda2 --iram-size 0xff - -REL=$(SRC:.c=.rel) ao_product.rel -ADB=$(REL:.rel=.adb) -ASM=$(REL:.rel=.asm) -LNK=$(REL:.rel=.lnk) -LST=$(REL:.rel=.lst) -RST=$(REL:.rel=.rst) -SYM=$(REL:.rel=.sym) - -PCDB=$(PROG:.ihx=.cdb) -PLNK=$(PROG:.ihx=.lnk) -PMAP=$(PROG:.ihx=.map) -PMEM=$(PROG:.ihx=.mem) -PAOM=$(PROG:.ihx=) - -%.rel : %.c $(INC) - $(call quiet,CC,$(PRODUCT_DEF)) $(CFLAGS) -c -o$@ $< - -all: - -clean-cc1111: - rm -f *.adb *.asm *.lnk *.lst *.rel *.rst *.sym - rm -f $(PROGNAME)-* - rm -f ao_product.h - rm -f ../$(PROGNAME)-* - -../ao_kalman.h: - +(cd .. && make ao_kalman.h) diff --git a/src/cc1111/_bp.c b/src/cc1111/_bp.c deleted file mode 100644 index 6bf135bc..00000000 --- a/src/cc1111/_bp.c +++ /dev/null @@ -1,26 +0,0 @@ -/*------------------------------------------------------------------------- - - _bp.c :- just declares bp as a variable - - Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this program; if not, write to the Free Software - Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - In other words, you are welcome to use, share and improve this program. - You are forbidden to forbid anyone else to use, share and improve - what you give them. Help stamp out software-hoarding! --------------------------------------------------------------------------*/ - -__data unsigned char bp ; diff --git a/src/cc1111/ao_adc.c b/src/cc1111/ao_adc.c deleted file mode 100644 index 94af5cda..00000000 --- a/src/cc1111/ao_adc.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright © 2009 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -volatile __xdata struct ao_data ao_data_ring[AO_DATA_RING]; -volatile __data uint8_t ao_data_head; -#if (AO_DATA_ALL & ~(AO_DATA_ADC)) -volatile __data uint8_t ao_data_present; -#endif - -#ifdef TELENANO_V_0_1 -# define AO_ADC_FIRST_PIN 1 -#endif - -#if HAS_ACCEL_REF -# define AO_ADC_FIRST_PIN 2 -#endif - -#ifndef AO_ADC_FIRST_PIN -# define AO_ADC_FIRST_PIN 0 -#endif - -void -ao_adc_poll(void) -{ - ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | AO_ADC_FIRST_PIN; -} - -void -ao_data_get(__xdata struct ao_data *packet) -{ -#if HAS_FLIGHT - uint8_t i = ao_data_ring_prev(ao_sample_data); -#else - uint8_t i = ao_data_ring_prev(ao_data_head); -#endif - ao_xmemcpy(packet, (void __xdata *) &ao_data_ring[i], sizeof (struct ao_data)); -} - -void -ao_adc_isr(void) __interrupt 1 -{ - uint8_t sequence; - uint8_t __xdata *a; - - sequence = (ADCCON2 & ADCCON2_SCH_MASK) >> ADCCON2_SCH_SHIFT; -#if TELEMETRUM_V_0_1 || TELEMETRUM_V_0_2 || TELEMETRUM_V_1_0 || TELEMETRUM_V_1_1 || TELEMETRUM_V_1_2 || TELELAUNCH_V_0_1 || TELEBALLOON_V_1_1 - /* TeleMetrum readings */ -#if HAS_ACCEL_REF - if (sequence == 2) { - a = (uint8_t __xdata *) (&ao_data_ring[ao_data_head].adc.accel_ref); - sequence = 0; - } else -#endif - { - if (sequence == ADCCON3_ECH_TEMP) - sequence = 2; - a = (uint8_t __xdata *) (&ao_data_ring[ao_data_head].adc.accel + sequence); - sequence++; - } -#define GOT_ADC - a[0] = ADCL; - a[1] = ADCH; - if (sequence < 6) { -#if HAS_EXTERNAL_TEMP == 0 - /* start next channel conversion */ - /* v0.2 replaces external temp sensor with internal one */ - if (sequence == 2) - ADCCON3 = ADCCON3_EREF_1_25 | ADCCON3_EDIV_512 | ADCCON3_ECH_TEMP; - else -#endif - ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | sequence; - return; - } -#endif - -#if TELEMINI_V_1_0 || TELENANO_V_0_1 - /* TeleMini readings */ - a = (uint8_t __xdata *) (&ao_data_ring[ao_data_head].adc.pres); -#if TELEMINI_V_1_0 - switch (sequence) { - case 0: - /* pressure */ - a += 0; - sequence = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | 1; - break; - case 1: - /* drogue sense */ - a += 6; - sequence = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | 2; - break; - case 2: - /* main sense */ - a += 8; - sequence = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | 3; - break; - case 3: - /* battery */ - a += 4; - sequence = ADCCON3_EREF_1_25 | ADCCON3_EDIV_512 | ADCCON3_ECH_TEMP; - break; - case ADCCON3_ECH_TEMP: - a += 2; - sequence = 0; - break; - } -#define GOT_ADC -#endif -#ifdef TELENANO_V_0_1 - switch (sequence) { - case 1: - /* pressure */ - a += 0; - sequence = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | 3; - break; - case 3: - /* battery */ - a += 4; - sequence = ADCCON3_EREF_1_25 | ADCCON3_EDIV_512 | ADCCON3_ECH_TEMP; - break; - case ADCCON3_ECH_TEMP: - a += 2; - sequence = 0; - break; - } -#define GOT_ADC -#endif - a[0] = ADCL; - a[1] = ADCH; - if (sequence) { - /* Start next conversion */ - ADCCON3 = sequence; - return; - } -#endif /* telemini || telenano */ - -#if defined(TELEFIRE_V_0_1) || defined(TELEFIRE_V_0_2) - a = (uint8_t __xdata *) (&ao_data_ring[ao_data_head].adc.sense[0] + sequence - AO_ADC_FIRST_PIN); - a[0] = ADCL; - a[1] = ADCH; - if (sequence < 5) { - ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | (sequence + 1); - return; - } -#define GOT_ADC -#endif /* TELEFIRE_V_0_1 */ - -#ifdef TELEBT_V_1_0 - a = (uint8_t __xdata *) (&ao_data_ring[ao_data_head].adc.batt); - a[0] = ADCL; - a[1] = ADCH; -#define GOT_ADC -#endif - -#ifdef FETCH_ADC - FETCH_ADC(); -#define GOT_ADC -#endif - -#ifndef GOT_ADC -#error No known ADC configuration set -#endif - - /* record this conversion series */ - ao_data_ring[ao_data_head].tick = ao_time(); - ao_data_head = ao_data_ring_next(ao_data_head); - ao_wakeup(DATA_TO_XDATA(&ao_data_head)); -} - -static void -ao_adc_dump(void) __reentrant -{ - static __xdata struct ao_data packet; - ao_data_get(&packet); -#ifndef AO_ADC_DUMP - printf("tick: %5u accel: %5d pres: %5d temp: %5d batt: %5d drogue: %5d main: %5d\n", - packet.tick, packet.adc.accel, packet.adc.pres, packet.adc.temp, - packet.adc.v_batt, packet.adc.sense_d, packet.adc.sense_m); -#else - AO_ADC_DUMP(&packet); -#endif -} - -__code struct ao_cmds ao_adc_cmds[] = { - { ao_adc_dump, "a\0Current ADC" }, - { 0, NULL }, -}; - -void -ao_adc_init(void) -{ -#ifdef AO_ADC_PINS - ADCCFG = AO_ADC_PINS; - -#else - -#if IGNITE_ON_P2 - /* TeleMetrum configuration */ - ADCCFG = ((1 << 0) | /* acceleration */ - (1 << 1) | /* pressure */ -#if HAS_EXTERNAL_TEMP - (1 << 2) | /* v0.1 temperature */ -#endif - (1 << 3) | /* battery voltage */ - (1 << 4) | /* drogue sense */ - (1 << 5)); /* main sense */ -#endif - -#if IGNITE_ON_P0 - /* TeleMini configuration */ - ADCCFG = ((1 << 0) | /* pressure */ - (1 << 1) | /* drogue sense */ - (1 << 2) | /* main sense */ - (1 << 3)); /* battery voltage */ -#endif - -#endif /* else AO_ADC_PINS */ - - /* enable interrupts */ - ADCIF = 0; - IEN0 |= IEN0_ADCIE; - ao_cmd_register(&ao_adc_cmds[0]); -} diff --git a/src/cc1111/ao_aes.c b/src/cc1111/ao_aes.c deleted file mode 100644 index e845a928..00000000 --- a/src/cc1111/ao_aes.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -#if !HAS_AES -#error Must define HAS_AES 1 -#endif - -__xdata uint8_t ao_aes_mutex; -__xdata uint8_t ao_aes_done; -__xdata uint8_t ao_aes_dma_in, ao_aes_dma_out; -__xdata uint8_t ao_aes_dma_in_done, ao_aes_dma_out_done; -__pdata enum ao_aes_mode ao_aes_current_mode; - -void -ao_aes_isr(void) __interrupt 4 -{ - S0CON = 0; - if (ENCCCS & ENCCCS_RDY) { - ao_aes_done = 1; - ao_wakeup(&ao_aes_done); - } -} - -void -ao_aes_set_mode(enum ao_aes_mode mode) -{ - ao_aes_current_mode = mode; -} - -void -ao_aes_set_key(__xdata uint8_t *in) -{ - ao_dma_set_transfer(ao_aes_dma_in, - in, - &ENCDIXADDR, - AO_AES_LEN, - DMA_CFG0_WORDSIZE_8 | - DMA_CFG0_TMODE_SINGLE | - DMA_CFG0_TRIGGER_ENC_DW, - DMA_CFG1_SRCINC_1 | - DMA_CFG1_DESTINC_0 | - DMA_CFG1_PRIORITY_LOW); - ao_dma_start(ao_aes_dma_in); - ao_aes_done = 0; - ENCCCS = ENCCCS_MODE_CBC_MAC | - ENCCCS_CMD_LOAD_KEY; - ENCCCS |= ENCCCS_START; - __critical while (!ao_aes_done) - ao_sleep(&ao_aes_done); -} - -void -ao_aes_zero_iv(void) -{ - uint8_t b; - - ENCCCS = ENCCCS_MODE_CBC_MAC | ENCCCS_CMD_LOAD_IV | ENCCCS_START; - for (b = 0; b < AO_AES_LEN; b++) - ENCDI = 0; -} - -void -ao_aes_run(__xdata uint8_t *in, - __xdata uint8_t *out) -{ - uint8_t b; - if (in) { - ao_dma_set_transfer(ao_aes_dma_in, - in, - &ENCDIXADDR, - AO_AES_LEN, - DMA_CFG0_WORDSIZE_8 | - DMA_CFG0_TMODE_SINGLE | - DMA_CFG0_TRIGGER_ENC_DW, - DMA_CFG1_SRCINC_1 | - DMA_CFG1_DESTINC_0 | - DMA_CFG1_PRIORITY_LOW); - } - if (out) { - ao_dma_set_transfer(ao_aes_dma_out, - &ENCDOXADDR, - out, - AO_AES_LEN, - DMA_CFG0_WORDSIZE_8 | - DMA_CFG0_TMODE_SINGLE | - DMA_CFG0_TRIGGER_ENC_UP, - DMA_CFG1_SRCINC_0 | - DMA_CFG1_DESTINC_1 | - DMA_CFG1_PRIORITY_LOW); - } - switch (ao_aes_current_mode) { - case ao_aes_mode_cbc_mac: - if (out) - b = (ENCCCS_MODE_CBC | - ENCCCS_CMD_ENCRYPT); - else - b = (ENCCCS_MODE_CBC_MAC | - ENCCCS_CMD_ENCRYPT); - break; - default: - return; - } - ao_aes_done = 0; - if (in) - ao_dma_start(ao_aes_dma_in); - if (out) - ao_dma_start(ao_aes_dma_out); - ENCCCS = b; - ENCCCS |= ENCCCS_START; - if (out) { - __critical while (!ao_aes_dma_out_done) - ao_sleep(&ao_aes_dma_out_done); - } else { - __critical while (!ao_aes_done) - ao_sleep(&ao_aes_done); - } -} - -void -ao_aes_init(void) -{ -#if DMA_SHARE_AES_RADIO - ao_aes_dma_in = ao_radio_dma; -#else - ao_aes_dma_in = ao_dma_alloc(&ao_aes_dma_in_done); -#endif - ao_aes_dma_out = ao_dma_alloc(&ao_aes_dma_out_done); - S0CON = 0; - ENCIE = 1; -} diff --git a/src/cc1111/ao_arch.h b/src/cc1111/ao_arch.h deleted file mode 100644 index 937e6d0c..00000000 --- a/src/cc1111/ao_arch.h +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -/* - * CC1111 definitions and code fragments for AltOS - */ - -#ifndef _AO_ARCH_H_ -#define _AO_ARCH_H_ - -#include "cc1111.h" - -/* Convert a __data pointer into an __xdata pointer */ -#define DATA_TO_XDATA(a) ((void __xdata *) ((uint8_t) (a) | 0xff00)) - -/* Code and xdata use the same address space */ -#define CODE_TO_XDATA(a) ((__xdata void *) ((uint16_t) (a))) - -/* Pdata lives at the start of xdata */ -#define PDATA_TO_XDATA(a) ((void __xdata *) ((uint8_t) (a) | 0xf000)) - -/* Stack runs from above the allocated __data space to 0xfe, which avoids - * writing to 0xff as that triggers the stack overflow indicator - */ -#define AO_STACK_START 0x90 -#define AO_STACK_END 0xfe -#define AO_STACK_SIZE (AO_STACK_END - AO_STACK_START + 1) - -#define AO_PORT_TYPE uint8_t - -#define ao_arch_reboot() do { \ - WDCTL = WDCTL_EN | WDCTL_MODE_WATCHDOG | WDCTL_INT_64; \ - ao_delay(AO_SEC_TO_TICKS(2)); \ - } while (0) - -#define ao_arch_nop() __asm nop __endasm -#define ao_arch_interrupt(n) __interrupt n - -#define ao_arch_naked_declare __naked -#define ao_arch_naked_define __naked - -/* CC1111-specific drivers */ - -/* - * ao_romconfig.c - */ - -#define AO_ROMCONFIG_VERSION 2 - -#define AO_ROMCONFIG_SYMBOL(a) __code __at(a) - -extern AO_ROMCONFIG_SYMBOL(0x00a0) uint16_t ao_romconfig_version; -extern AO_ROMCONFIG_SYMBOL(0x00a2) uint16_t ao_romconfig_check; -extern AO_ROMCONFIG_SYMBOL(0x00a4) uint16_t ao_serial_number; -extern AO_ROMCONFIG_SYMBOL(0x00a6) uint32_t ao_radio_cal; - -#ifndef HAS_USB -#error Please define HAS_USB -#endif - -#define ao_arch_task_members\ - uint8_t stack_count; /* amount of saved stack */ - -/* Initialize stack */ -#define ao_arch_init_stack(task, start) { \ - uint8_t __xdata *stack = task->stack; \ - uint8_t t; \ - *stack++ = ((uint16_t) start); /* 0 */ \ - *stack++ = ((uint16_t) start) >> 8; /* 1 */ \ - \ - /* and the stuff saved by ao_switch */ \ - *stack++ = 0; /* 2 acc */ \ - *stack++ = 0x80; /* 3 IE */ \ - \ - /* 4 DPL \ - * 5 DPH \ - * 6 B \ - * 7 R2 \ - * 8 R3 \ - * 9 R4 \ - * 10 R5 \ - * 11 R6 \ - * 12 R7 \ - * 13 R0 \ - * 14 R1 \ - * 15 PSW \ - * 16 BP \ - */ \ - for (t = 0; t < 13; t++) \ - *stack++ = 0; \ - task->stack_count = 17; \ - } - - - -/* Save current context */ - -#define ao_arch_save_regs() \ - __asm \ - /* Push ACC first, as when restoring the context it must be restored \ - * last (it is used to set the IE register). */ \ - push ACC \ - push _IEN0 \ - push DPL \ - push DPH \ - push b \ - push ar2 \ - push ar3 \ - push ar4 \ - push ar5 \ - push ar6 \ - push ar7 \ - push ar0 \ - push ar1 \ - push PSW \ - __endasm; \ - PSW = 0; \ - __asm \ - push _bp \ - __endasm - -#define ao_arch_save_stack() { \ - uint8_t stack_len; \ - __data uint8_t *stack_ptr; \ - __xdata uint8_t *save_ptr; \ - /* Save the current stack */ \ - stack_len = SP - (AO_STACK_START - 1); \ - ao_cur_task->stack_count = stack_len; \ - stack_ptr = (uint8_t __data *) AO_STACK_START; \ - save_ptr = (uint8_t __xdata *) ao_cur_task->stack; \ - do \ - *save_ptr++ = *stack_ptr++; \ - while (--stack_len); \ - } - -/* Empty the stack; might as well let interrupts have the whole thing */ -#define ao_arch_isr_stack() (SP = AO_STACK_START - 1) - -#define ao_arch_block_interrupts() __asm clr _EA __endasm -#define ao_arch_release_interrupts() __asm setb _EA __endasm - -/* Idle the CPU, waking when an interrupt occurs */ -#define ao_arch_wait_interrupt() do { \ - ao_arch_release_interrupts(); \ - (PCON = PCON_IDLE); \ - ao_arch_block_interrupts(); \ - } while (0) - -#define ao_arch_restore_stack() { \ - uint8_t stack_len; \ - __data uint8_t *stack_ptr; \ - __xdata uint8_t *save_ptr; \ - \ - /* Restore the old stack */ \ - stack_len = ao_cur_task->stack_count; \ - SP = AO_STACK_START - 1 + stack_len; \ - \ - stack_ptr = (uint8_t __data *) AO_STACK_START; \ - save_ptr = (uint8_t __xdata *) ao_cur_task->stack; \ - do \ - *stack_ptr++ = *save_ptr++; \ - while (--stack_len); \ - \ - __asm \ - pop _bp \ - pop PSW \ - pop ar1 \ - pop ar0 \ - pop ar7 \ - pop ar6 \ - pop ar5 \ - pop ar4 \ - pop ar3 \ - pop ar2 \ - pop b \ - pop DPH \ - pop DPL \ - /* The next byte of the stack is the IE register. Only the global \ - enable bit forms part of the task context. Pop off the IE then set \ - the global enable bit to match that of the stored IE register. */ \ - pop ACC \ - JB ACC.7,0098$ \ - CLR _EA \ - LJMP 0099$ \ - 0098$: \ - SETB _EA \ - 0099$: \ - /* Finally restore ACC, which was the first register saved. */ \ - pop ACC \ - ret \ - __endasm; \ -} - -#define ao_arch_critical(b) __critical { b } - -#define AO_DATA_RING 32 - -/* ao_button.c */ -#ifdef HAS_BUTTON -void -ao_p0_isr(void) ao_arch_interrupt(13); - -void -ao_p1_isr(void) ao_arch_interrupt(15); - -void -ao_p2_isr(void); - -#define HAS_P2_ISR 1 - -#endif - -void -ao_button_init(void); - -char -ao_button_get(uint16_t timeout) __critical; - -void -ao_button_clear(void) __critical; - -/* console I/O funcs */ -#define ao_getchar getchar -#define ao_putchar putchar - -/* ao_string.c */ - -void -_ao_xmemcpy(__xdata void *dst, __xdata void *src, uint16_t count); - -#define ao_xmemcpy(d,s,c) _ao_xmemcpy(d,s,c) - -void -_ao_xmemset(__xdata void *dst, uint8_t value, uint16_t count); - -#define ao_xmemset(d,v,c) _ao_xmemset(d,v,c) - -int8_t -_ao_xmemcmp(__xdata void *a, __xdata void *b, uint16_t count); - -#define ao_xmemcmp(d,s,c) _ao_xmemcmp((d), (s), (c)) - -struct ao_serial_speed { - uint8_t baud; - uint8_t gcr; -}; - -extern const __code struct ao_serial_speed ao_serial_speeds[]; - -/* - * ao_dma.c - */ - -/* Allocate a DMA channel. the 'done' parameter will be set when the - * dma is finished and will be used to wakeup any waiters - */ - -uint8_t -ao_dma_alloc(__xdata uint8_t * done); - -/* Setup a DMA channel */ -void -ao_dma_set_transfer(uint8_t id, - void __xdata *srcaddr, - void __xdata *dstaddr, - uint16_t count, - uint8_t cfg0, - uint8_t cfg1); - -/* Start a DMA channel */ -void -ao_dma_start(uint8_t id); - -/* Manually trigger a DMA channel */ -void -ao_dma_trigger(uint8_t id); - -/* Abort a running DMA transfer */ -void -ao_dma_abort(uint8_t id); - -/* DMA interrupt routine */ -void -ao_dma_isr(void) ao_arch_interrupt(8); - -/* ao_adc.c */ - -#if HAS_ADC -/* The A/D interrupt handler */ -void -ao_adc_isr(void) ao_arch_interrupt(1); -#endif - -#if HAS_USB -/* USB interrupt handler */ -void -ao_usb_isr(void) ao_arch_interrupt(6); -#endif - -#if HAS_SERIAL_0 -void -ao_serial0_rx_isr(void) ao_arch_interrupt(2); - -void -ao_serial0_tx_isr(void) ao_arch_interrupt(7); -#endif - -#if HAS_SERIAL_1 -void -ao_serial1_rx_isr(void) ao_arch_interrupt(3); - -void -ao_serial1_tx_isr(void) ao_arch_interrupt(14); -#endif - -#if HAS_EXTI_0 -void -ao_p0_isr(void) __interrupt(13); -#endif - -#define AO_ADC_MAX 32767 - -#endif /* _AO_ARCH_H_ */ diff --git a/src/cc1111/ao_arch_funcs.h b/src/cc1111/ao_arch_funcs.h deleted file mode 100644 index d849655b..00000000 --- a/src/cc1111/ao_arch_funcs.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -/* - * ao_spi.c - */ - -#if !HAS_SPI_0 && !HAS_SPI_1 -#define HAS_SPI_0 1 -#define SPI_0_ALT_2 1 -#endif - -#if HAS_SPI_0 && HAS_SPI_1 -#define MULTI_SPI 1 -#define N_SPI 2 -#else -#define MULTI_SPI 0 -#define N_SPI 1 -#endif - -extern __xdata uint8_t ao_spi_mutex[N_SPI]; - -#if MULTI_SPI -#define ao_spi_get(bus) ao_mutex_get(&ao_spi_mutex[bus]) -#define ao_spi_put(bus) ao_mutex_put(&ao_spi_mutex[bus]) -#else -#define ao_spi_get(bus) ao_mutex_get(&ao_spi_mutex[0]) -#define ao_spi_put(bus) ao_mutex_put(&ao_spi_mutex[0]) -#endif - -#define AO_SPI_SPEED_FAST 17 -#define AO_SPI_SPEED_200kHz 13 - -#if MULTI_SPI -#define ao_spi_set_speed(bus,speed) (*(bus ? &U1GCR : &U0GCR) =(UxGCR_CPOL_NEGATIVE | \ - UxGCR_CPHA_FIRST_EDGE | \ - UxGCR_ORDER_MSB | \ - ((speed) << UxGCR_BAUD_E_SHIFT))) -#else -#define ao_spi_set_speed(bus,speed) (U0GCR = (UxGCR_CPOL_NEGATIVE | \ - UxGCR_CPHA_FIRST_EDGE | \ - UxGCR_ORDER_MSB | \ - ((speed) << UxGCR_BAUD_E_SHIFT))) -#endif - -#define ao_spi_get_slave(bus) do { \ - ao_spi_get(bus); \ - ao_spi_set_speed(bus,AO_SPI_SPEED_FAST); \ - } while (0) - -#define ao_spi_put_slave(bus) do { \ - ao_spi_put(bus); \ - } while (0) - -#define ao_spi_get_mask(reg,mask,bus,speed) do { \ - ao_spi_get(bus); \ - ao_spi_set_speed(bus,speed); \ - (reg) &= ~(mask); \ - } while (0) - -#define ao_spi_put_mask(reg,mask,bus) do { \ - (reg) |= (mask); \ - ao_spi_put(bus); \ - } while (0) - - -#define ao_spi_get_bit(reg,bit,pin,bus,speed) do { \ - ao_spi_get(bus); \ - ao_spi_set_speed(bus,speed); \ - pin = 0; \ - } while (0) - -#define ao_spi_put_bit(reg,bit,pin,bus) do { \ - pin = 1; \ - ao_spi_put(bus); \ - } while (0) - - -/* - * The SPI mutex must be held to call either of these - * functions -- this mutex covers the entire SPI operation, - * from chip select low to chip select high - */ - -#if MULTI_SPI -void -ao_spi_send(void __xdata *block, uint16_t len, uint8_t bus) __reentrant; - -void -ao_spi_recv(void __xdata *block, uint16_t len, uint8_t bus) __reentrant; -#else -void -ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant; - -void -ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant; - -#define ao_spi_send(block, len, bus) ao_spi_send_bus(block, len) -#define ao_spi_recv(block, len, bus) ao_spi_recv_bus(block, len) -#endif - -#if AO_SPI_SLAVE -void -ao_spi_send_wait(void); - -void -ao_spi_recv_wait(void); -#endif - -void -ao_spi_init(void); - -#define token_paster(x,y) x ## y -#define token_paster3(x,y,z) x ## y ## z -#define token_evaluator(x,y) token_paster(x,y) -#define token_evaluator3(x,y,z) token_paster3(x,y,z) - -#define ao_spi_init_cs(port, mask) do { \ - port |= mask; \ - token_evaluator(port,DIR) |= mask; \ - token_evaluator(port,SEL) &= ~mask; \ - } while (0) - -#define cc1111_enable_output(port,dir,sel,pin,bit,v) do { \ - pin = v; \ - dir |= (1 << bit); \ - sel &= ~(1 << bit); \ - } while (0) - -#define disable_unreachable _Pragma("disable_warning 126") - -#define ao_enable_output(port,bit,pin,v) cc1111_enable_output(port,token_evaluator(port,DIR), token_evaluator(port,SEL), pin, bit, v) -#define ao_gpio_set(port, bit, pin, v) ((pin) = (v)) -#define ao_gpio_get(port, bit, pin) (pin) -#define ao_gpio_get_bits(port) (port) -#define ao_gpio_set_bits(port, bits) ((port) |= bits) -#define ao_gpio_clr_bits(port, bits) ((port) &= ~bits) diff --git a/src/cc1111/ao_battery.c b/src/cc1111/ao_battery.c deleted file mode 100644 index 9fb4c26b..00000000 --- a/src/cc1111/ao_battery.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" -static __data union { - uint8_t d[2]; - int16_t v; -} ao_battery_value; - -void -ao_battery_isr(void) ao_arch_interrupt(1) -{ - ao_battery_value.d[0] = ADCL; - ao_battery_value.d[1] = ADCH; - ao_wakeup(DATA_TO_XDATA(&ao_battery_value)); -} - -uint16_t -ao_battery_get(void) -{ - ao_arch_critical( - ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | BATTERY_PIN; - ao_sleep(DATA_TO_XDATA(&ao_battery_value)); - ); - return (uint16_t) ((int32_t) ao_battery_value.v * (int32_t) 4950 >> 15); -} - -static void -ao_battery_show(void) -{ - printf("Battery: %u mV\n", ao_battery_get()); -} - -__code struct ao_cmds ao_battery_cmds[] = { - { ao_battery_show, "B\0Show battery voltage" }, - { 0, NULL }, -}; - -void -ao_battery_init(void) -{ - ADCCFG = (1 << BATTERY_PIN); - ADCIF = 0; - IEN0 |= IEN0_ADCIE; - ao_cmd_register(&ao_battery_cmds[0]); -} diff --git a/src/cc1111/ao_beep.c b/src/cc1111/ao_beep.c deleted file mode 100644 index 04d10485..00000000 --- a/src/cc1111/ao_beep.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2009 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -void -ao_beep(uint8_t beep) -{ - if (beep == 0) { - P2_0 = 0; - P2SEL = (P2SEL & ~P2SEL_SELP2_0_MASK) | P2SEL_SELP2_0_GPIO; - T4CTL = 0; - } else { - P2SEL = (P2SEL & ~P2SEL_SELP2_0_MASK) | P2SEL_SELP2_0_PERIPHERAL; - T4CC0 = beep; - T4CTL = TxCTL_DIV_32 | TxCTL_MODE_MODULO | TxCTL_START; - } -} - -void -ao_beep_for(uint8_t beep, uint16_t ticks) __reentrant -{ - ao_beep(beep); - ao_delay(ticks); - ao_beep(0); -} - -void -ao_beep_init(void) -{ - /* Our beeper is on P2_0, which is hooked to timer 4 using - * configuration alternative 2 - */ - P2_0 = 0; - P2SEL = (P2SEL & ~P2SEL_SELP2_0_MASK) | P2SEL_SELP2_0_GPIO; - PERCFG = (PERCFG & ~PERCFG_T4CFG_ALT_MASK) | PERCFG_T4CFG_ALT_2; - T4CCTL0 = TxCCTLy_CMP_TOGGLE|TxCCTLy_CMP_MODE_ENABLE; -} diff --git a/src/cc1111/ao_button.c b/src/cc1111/ao_button.c deleted file mode 100644 index 0496a32f..00000000 --- a/src/cc1111/ao_button.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -volatile __xdata struct ao_fifo ao_button_fifo; - -static __code struct { - uint8_t mask; - uint8_t reg; -} ao_buttons[] = { -#ifdef BUTTON_1_MASK - { BUTTON_1_MASK, BUTTON_1_REG }, -#endif -#ifdef BUTTON_2_MASK - { BUTTON_2_MASK, BUTTON_2_REG }, -#endif -#ifdef BUTTON_3_MASK - { BUTTON_3_MASK, BUTTON_3_REG }, -#endif -}; - -#define NUM_BUTTONS ((sizeof ao_buttons) / sizeof (ao_buttons[0])) - -static __xdata uint16_t ao_button_tick[NUM_BUTTONS]; - -static void -ao_button_insert(char n) -{ - uint16_t now = ao_time(); - if ((now - ao_button_tick[n]) > 20) { - ao_button_tick[n] = now; - ao_fifo_insert(ao_button_fifo, n); - ao_wakeup(&ao_button_fifo); - } -} - -static void -ao_button_isr(uint8_t flag, uint8_t reg) -{ - uint8_t b; - - for (b = 0; b < NUM_BUTTONS; b++) - if (ao_buttons[b].reg == reg && (ao_buttons[b].mask & flag)) - ao_button_insert(b + 1); -} - -static uint8_t -ao_button_mask(uint8_t reg) -{ - uint8_t b; - uint8_t mask = 0; - - for (b = 0; b < NUM_BUTTONS; b++) - if (ao_buttons[b].reg == reg) - mask |= ao_buttons[b].mask; - return mask; -} - -char -ao_button_get(uint16_t timeout) __critical -{ - char b; - - while (ao_fifo_empty(ao_button_fifo)) - if (ao_sleep_for(&ao_button_fifo, timeout)) - return 0; - ao_fifo_remove(ao_button_fifo, b); - return b; -} - -void -ao_button_clear(void) __critical -{ - char b; - - while (!ao_fifo_empty(ao_button_fifo)) - ao_fifo_remove(ao_button_fifo, b); -} - -void -ao_p0_isr(void) ao_arch_interrupt(13) -{ - P0IF = 0; - ao_button_isr(P0IFG, 0); - P0IFG = 0; -} - -void -ao_p1_isr(void) ao_arch_interrupt(15) -{ - P1IF = 0; - ao_button_isr(P1IFG, 1); - P1IFG = 0; -} - -/* Shared with USB */ -void -ao_p2_isr(void) -{ - ao_button_isr(P2IFG, 2); - P2IFG = 0; -} - -void -ao_button_init(void) -{ - uint8_t mask; - - /* Pins are configured as inputs with pull-up by default */ - - /* Enable interrupts for P0 inputs */ - mask = ao_button_mask(0); - if (mask) { - if (mask & 0x0f) - PICTL |= PICTL_P0IENL; - if (mask & 0xf0) - PICTL |= PICTL_P0IENH; - P0IFG = 0; - P0IF = 0; - IEN1 |= IEN1_P0IE; - PICTL |= PICTL_P0ICON; - } - - /* Enable interrupts for P1 inputs */ - mask = ao_button_mask(1); - if (mask) { - P1IEN |= mask; - P1IFG = 0; - P1IF = 0; - IEN2 |= IEN2_P1IE; - PICTL |= PICTL_P1ICON; - } - - /* Enable interrupts for P2 inputs */ - mask = ao_button_mask(2); - if (mask) { - PICTL |= PICTL_P2IEN; - P2IFG = 0; - P2IF = 0; - IEN2 |= IEN2_P2IE; - PICTL |= PICTL_P2ICON; - } -} diff --git a/src/cc1111/ao_dbg.c b/src/cc1111/ao_dbg.c deleted file mode 100644 index ca751b88..00000000 --- a/src/cc1111/ao_dbg.c +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright © 2009 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" -#include "ao_pins.h" - -static void -ao_dbg_send_bits(uint8_t msk, uint8_t val) __reentrant -{ - DBG_PORT = (DBG_PORT & ~msk) | (val & msk); - __asm - nop - nop - __endasm; -} - -void -ao_dbg_send_byte(uint8_t byte) -{ - __pdata uint8_t b, d; - - DBG_PORT |= DBG_DATA; - DBG_PORT_DIR |= DBG_DATA; - for (b = 0; b < 8; b++) { - d = 0; - if (byte & 0x80) - d = DBG_DATA; - byte <<= 1; - ao_dbg_send_bits(DBG_CLOCK|DBG_DATA, DBG_CLOCK|d); - ao_dbg_send_bits(DBG_CLOCK|DBG_DATA, 0 |d); - } - DBG_PORT_DIR &= ~DBG_DATA; -} - -uint8_t -ao_dbg_recv_byte(void) -{ - __pdata uint8_t byte, b; - - byte = 0; - for (b = 0; b < 8; b++) { - byte = byte << 1; - ao_dbg_send_bits(DBG_CLOCK, DBG_CLOCK); - if (DBG_DATA_PIN) - byte |= 1; - ao_dbg_send_bits(DBG_CLOCK, 0); - } - return byte; -} - -/* 8051 instructions - */ -#define NOP 0x00 -#define MOV_direct_data 0x75 -#define LJMP 0x02 -#define MOV_Rn_data(n) (0x78 | (n)) -#define DJNZ_Rn_rel(n) (0xd8 | (n)) -#define MOV_A_direct 0xe5 -#define MOV_direct1_direct2 0x85 -#define MOV_direct_A 0xf5 -#define MOV_DPTR_data16 0x90 -#define MOV_A_data 0x74 -#define MOVX_atDPTR_A 0xf0 -#define MOVX_A_atDPTR 0xe0 -#define INC_DPTR 0xa3 -#define TRAP 0xa5 -#define SJMP 0x80 -#define JB 0x20 - -#define DEBUG_INSTR(l) (0x54 | (l)) - -#define SFR_PSW 0xD0 -#define SFR_DPL0 0x82 -#define SFR_DPH0 0x83 -#define SFR_DPL1 0x84 -#define SFR_DPH1 0x85 - -__pdata uint8_t save_acc; -__pdata uint8_t save_psw; -__pdata uint8_t save_dpl0; -__pdata uint8_t save_dph0; -__pdata uint8_t save_dpl1; -__pdata uint8_t save_dph1; - -static uint8_t -ao_dbg_inst1(uint8_t a) __reentrant -{ - ao_dbg_send_byte(DEBUG_INSTR(1)); - ao_dbg_send_byte(a); - return ao_dbg_recv_byte(); -} - -static uint8_t -ao_dbg_inst2(uint8_t a, uint8_t b) __reentrant -{ - ao_dbg_send_byte(DEBUG_INSTR(2)); - ao_dbg_send_byte(a); - ao_dbg_send_byte(b); - return ao_dbg_recv_byte(); -} - -static uint8_t -ao_dbg_inst3(uint8_t a, uint8_t b, uint8_t c) __reentrant -{ - ao_dbg_send_byte(DEBUG_INSTR(3)); - ao_dbg_send_byte(a); - ao_dbg_send_byte(b); - ao_dbg_send_byte(c); - return ao_dbg_recv_byte(); -} - -void -ao_dbg_start_transfer(uint16_t addr) -{ - save_acc = ao_dbg_inst1(NOP); - save_psw = ao_dbg_inst2(MOV_A_direct, SFR_PSW); - save_dpl0 = ao_dbg_inst2(MOV_A_direct, SFR_DPL0); - save_dph0 = ao_dbg_inst2(MOV_A_direct, SFR_DPH0); - save_dpl1 = ao_dbg_inst2(MOV_A_direct, SFR_DPL1); - save_dph1 = ao_dbg_inst2(MOV_A_direct, SFR_DPH1); - ao_dbg_inst3(MOV_DPTR_data16, addr >> 8, addr); -} - -void -ao_dbg_end_transfer(void) -{ - ao_dbg_inst3(MOV_direct_data, SFR_DPL0, save_dpl0); - ao_dbg_inst3(MOV_direct_data, SFR_DPH0, save_dph0); - ao_dbg_inst3(MOV_direct_data, SFR_DPL1, save_dpl1); - ao_dbg_inst3(MOV_direct_data, SFR_DPH1, save_dph1); - ao_dbg_inst3(MOV_direct_data, SFR_PSW, save_psw); - ao_dbg_inst2(MOV_A_data, save_acc); -} - -void -ao_dbg_write_byte(uint8_t byte) -{ - ao_dbg_inst2(MOV_A_data, byte); - ao_dbg_inst1(MOVX_atDPTR_A); - ao_dbg_inst1(INC_DPTR); -} - -uint8_t -ao_dbg_read_byte(void) -{ - ao_dbg_inst1(MOVX_A_atDPTR); - return ao_dbg_inst1(INC_DPTR); -} - -static void -ao_dbg_set_pins(void) -{ - /* Make the DBG pins GPIOs. On TeleMetrum, this will - * disable the SPI link, so don't expect SPI to work after - * using the debugger. - */ - DBG_PORT_SEL &= ~(DBG_CLOCK|DBG_DATA|DBG_RESET_N); - - /* make DBG_DATA tri-state */ - DBG_PORT_INP |= DBG_DATA; - - /* Raise RESET_N and CLOCK */ - DBG_PORT |= DBG_RESET_N | DBG_CLOCK; - - /* RESET_N and CLOCK are outputs now */ - DBG_PORT_DIR |= DBG_RESET_N | DBG_CLOCK; - DBG_PORT_DIR &= ~DBG_DATA; -} - -static void -ao_dbg_long_delay(void) -{ - uint8_t n; - - for (n = 0; n < 20; n++) - __asm nop __endasm; -} - -#define AO_RESET_LOW_DELAY AO_MS_TO_TICKS(100) -#define AO_RESET_HIGH_DELAY AO_MS_TO_TICKS(100) - -static void -ao_dbg_send_bits_delay(uint8_t msk, uint8_t val) -{ - ao_dbg_long_delay(); - ao_dbg_send_bits(msk, val); -} - -void -ao_dbg_do_reset(uint8_t clock_up) -{ - ao_dbg_set_pins(); - ao_dbg_send_bits_delay(DBG_CLOCK|DBG_DATA|DBG_RESET_N, DBG_CLOCK|DBG_DATA|DBG_RESET_N); - ao_dbg_send_bits_delay(DBG_CLOCK|DBG_DATA|DBG_RESET_N, clock_up |DBG_DATA| 0 ); - ao_delay(AO_RESET_LOW_DELAY); - ao_dbg_send_bits (DBG_CLOCK|DBG_DATA|DBG_RESET_N, DBG_CLOCK|DBG_DATA| 0 ); - ao_dbg_send_bits_delay(DBG_CLOCK|DBG_DATA|DBG_RESET_N, clock_up |DBG_DATA| 0 ); - ao_dbg_send_bits_delay(DBG_CLOCK|DBG_DATA|DBG_RESET_N, DBG_CLOCK|DBG_DATA| 0 ); - ao_dbg_send_bits_delay(DBG_CLOCK|DBG_DATA|DBG_RESET_N, clock_up |DBG_DATA|DBG_RESET_N); - ao_delay(AO_RESET_HIGH_DELAY); -} - -static void -debug_enable(void) -{ - /* toggle clock line while holding reset low */ - ao_dbg_do_reset(0); -} - -static void -debug_reset(void) -{ - /* hold clock high while holding reset low */ - ao_dbg_do_reset(DBG_CLOCK); -} - -static void -debug_put(void) -{ - for (;;) { - ao_cmd_white (); - if (ao_cmd_lex_c == '\n') - break; - ao_cmd_hex(); - if (ao_cmd_status != ao_cmd_success) - break; - ao_dbg_send_byte(ao_cmd_lex_i); - } -} - -static void -debug_get(void) -{ - __pdata uint16_t count; - __pdata uint16_t i; - __pdata uint8_t byte; - ao_cmd_hex(); - if (ao_cmd_status != ao_cmd_success) - return; - count = ao_cmd_lex_i; - if (count > 256) { - ao_cmd_status = ao_cmd_syntax_error; - return; - } - for (i = 0; i < count; i++) { - if (i && (i & 7) == 0) - putchar('\n'); - byte = ao_dbg_recv_byte(); - ao_cmd_put8(byte); - putchar(' '); - } - putchar('\n'); -} - -static void -debug_input(void) -{ - __pdata uint16_t count; - __pdata uint16_t addr; - __pdata uint8_t b; - __pdata uint8_t i; - - ao_cmd_hex(); - count = ao_cmd_lex_i; - ao_cmd_hex(); - addr = ao_cmd_lex_i; - if (ao_cmd_status != ao_cmd_success) - return; - ao_dbg_start_transfer(addr); - i = 0; - while (count--) { - if (!(i++ & 7)) - putchar('\n'); - b = ao_dbg_read_byte(); - ao_cmd_put8(b); - } - ao_dbg_end_transfer(); - putchar('\n'); -} - -static void -debug_output(void) -{ - __pdata uint16_t count; - __pdata uint16_t addr; - __pdata uint8_t b; - - ao_cmd_hex(); - count = ao_cmd_lex_i; - ao_cmd_hex(); - addr = ao_cmd_lex_i; - if (ao_cmd_status != ao_cmd_success) - return; - ao_dbg_start_transfer(addr); - while (count--) { - b = ao_getnibble() << 4; - b |= ao_getnibble(); - if (ao_cmd_status != ao_cmd_success) - return; - ao_dbg_write_byte(b); - } - ao_dbg_end_transfer(); -} - -__code struct ao_cmds ao_dbg_cmds[7] = { - { debug_enable, "D\0Enable debug" }, - { debug_get, "G \0Get data" }, - { debug_input, "I \0Input at " }, - { debug_output, "O \0Output at " }, - { debug_put, "P ...\0Put data" }, - { debug_reset, "R\0Reset" }, - { 0, NULL }, -}; - -void -ao_dbg_init(void) -{ - ao_cmd_register(&ao_dbg_cmds[0]); -} diff --git a/src/cc1111/ao_dma.c b/src/cc1111/ao_dma.c deleted file mode 100644 index 18266518..00000000 --- a/src/cc1111/ao_dma.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright © 2009 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -#define NUM_DMA 5 - -/* - * The config address for DMA0 is programmed - * separately from that of DMA1-4, but for simplicity, - * we make them all contiguous. - */ - -static __xdata struct cc_dma_channel ao_dma_config[NUM_DMA]; -static __xdata uint8_t * __xdata ao_dma_done[NUM_DMA]; -static __data uint8_t ao_next_dma; - -uint8_t -ao_dma_alloc(__xdata uint8_t *done) -{ - uint8_t id; - - if (ao_next_dma == NUM_DMA) - ao_panic(AO_PANIC_DMA); - id = ao_next_dma++; - ao_dma_done[id] = done; - - /* When the first dma object is allocated, set up the DMA - * controller - */ - if (id == 0) { - DMAIRQ = 0; - DMAIF = 0; - IEN1 |= IEN1_DMAIE; - DMA0CFGH = ((uint16_t) (&ao_dma_config[0])) >> 8; - DMA0CFGL = ((uint16_t) (&ao_dma_config[0])); - DMA1CFGH = ((uint16_t) (&ao_dma_config[1])) >> 8; - DMA1CFGL = ((uint16_t) (&ao_dma_config[1])); - } - - return id; -} - -void -ao_dma_set_transfer(uint8_t id, - void __xdata *srcaddr, - void __xdata *dstaddr, - uint16_t count, - uint8_t cfg0, - uint8_t cfg1) -{ - if (DMAARM & (1 << id)) - ao_panic(AO_PANIC_DMA); - ao_dma_config[id].src_high = ((uint16_t) srcaddr) >> 8; - ao_dma_config[id].src_low = ((uint16_t) srcaddr); - ao_dma_config[id].dst_high = ((uint16_t) dstaddr) >> 8; - ao_dma_config[id].dst_low = ((uint16_t) dstaddr); - ao_dma_config[id].len_high = count >> 8; - ao_dma_config[id].len_low = count; - ao_dma_config[id].cfg0 = cfg0; - ao_dma_config[id].cfg1 = cfg1 | DMA_CFG1_IRQMASK; -} - -#define nop() __asm nop __endasm; - -void -ao_dma_start(uint8_t id) -{ - uint8_t mask = (1 << id); - DMAIRQ &= ~mask; - if (DMAARM & mask) { - DMAARM = 0x80 | mask; - nop(); nop(); nop(); nop(); - nop(); nop(); nop(); nop(); - } - *(ao_dma_done[id]) = 0; - DMAARM = mask; - nop(); nop(); nop(); nop(); - nop(); nop(); nop(); nop(); - nop(); -} - -void -ao_dma_trigger(uint8_t id) -{ - DMAREQ |= (1 << id); -} - -void -ao_dma_abort(uint8_t id) -{ - uint8_t mask = (1 << id); - DMAARM = 0x80 | mask; - DMAIRQ &= ~mask; -} - -void -ao_dma_isr(void) __interrupt 8 -{ - uint8_t id, mask; - - /* Find the first DMA channel which is done */ - mask = 1; - for (id = 0; id < ao_next_dma; id++) { - if (DMAIRQ & mask) { - /* Clear CPU interrupt flag */ - DMAIF = 0; - /* Clear the completed ID */ - DMAIRQ = ~mask; - *(ao_dma_done[id]) = 1; - ao_wakeup(ao_dma_done[id]); - break; - } - mask <<= 1; - } -} diff --git a/src/cc1111/ao_exti.c b/src/cc1111/ao_exti.c deleted file mode 100644 index e21e417c..00000000 --- a/src/cc1111/ao_exti.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include -#include - -#if HAS_EXTI_0 -__xdata void (*ao_int_callback)(void); - -void -ao_p0_isr(void) __interrupt(13) -{ - if (P0IF && (P0IFG & (AO_MS5607_MISO_MASK))) { - (*ao_int_callback)(); - } - P0IFG = 0; - P0IF = 0; -} -#endif diff --git a/src/cc1111/ao_exti.h b/src/cc1111/ao_exti.h deleted file mode 100644 index 927a4f09..00000000 --- a/src/cc1111/ao_exti.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_EXTI_H_ -#define _AO_EXTI_H_ - -#define AO_EXTI_MODE_RISING 1 -#define AO_EXTI_MODE_FALLING 2 -#define AO_EXTI_MODE_PULL_UP 4 -#define AO_EXTI_MODE_PULL_DOWN 8 -#define AO_EXTI_PRIORITY_LOW 16 -#define AO_EXTI_PRIORITY_MED 0 -#define AO_EXTI_PRIORITY_HIGH 32 - -extern void (*ao_int_callback)(void); - -#define ao_exti_setup(gpio, pin, mode, callback) do { \ - ao_int_callback = callback; \ - } while (0) - -#define ao_exti_set_mode(gpio, pin, mode) do { \ - } while (0) - -#define ao_exti_set_callback(port, pin, callback) do { \ - ao_int_callback = callback; \ - } while (0) - -#define ao_exti_init() - -#define ao_exti_enable(port, pin) do { \ - P0IFG &= ~(1 << pin); \ - P0IF = 0; \ - PICTL |= PICTL_P0IENL; \ - IEN1 |= IEN1_P0IE; \ - } while (0) - -#define ao_exti_disable(port, pin) do { \ - IEN1 &= ~IEN1_P0IE; \ - PICTL &= ~PICTL_P0IENL; \ - } while (0) - -#endif /* _AO_EXTI_H_ */ diff --git a/src/cc1111/ao_intflash.c b/src/cc1111/ao_intflash.c deleted file mode 100644 index 154b3c25..00000000 --- a/src/cc1111/ao_intflash.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright © 2011 Anthony Towns - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" -#include "cc1111.h" - -#define ENDOFCODE (CODESIZE) -#define AO_INTFLASH_BLOCK 1024 -#define AO_INTFLASH_BLOCKS ((0x8000 - ENDOFCODE)/AO_INTFLASH_BLOCK) -#define AO_INTFLASH_SIZE (AO_INTFLASH_BLOCK * AO_INTFLASH_BLOCKS) -#define AO_INTFLASH_LOCATION (0x8000 - AO_INTFLASH_SIZE) - -/* - * 21000 * 24e6 - * FWT = ------------ - * 16e9 - * - * = 31.5 - * - * Round up and use 32 - */ - -#define FLASH_TIMING 0x20 - -#if AO_INTFLASH_BLOCKS < 2 -#error "Too few pages" -#endif - -#if AO_INFTLASH_LOCATION % 1024 != 0 -#error "Pages aren't aligned properly" -#endif - -__xdata __at(AO_INTFLASH_LOCATION) uint8_t ao_intflash[AO_INTFLASH_SIZE]; - -/* Total bytes of available storage */ -__pdata uint32_t ao_storage_total = sizeof(ao_intflash); - -/* Block size - device is erased in these units. */ -__pdata uint32_t ao_storage_block = AO_INTFLASH_BLOCK; - -/* Byte offset of config block. Will be ao_storage_block bytes long */ -__pdata uint32_t ao_storage_config = sizeof(ao_intflash) - AO_INTFLASH_BLOCK; - -/* Storage unit size - device reads and writes must be within blocks of this size. */ -__pdata uint16_t ao_storage_unit = AO_INTFLASH_BLOCK; - -__xdata static uint8_t ao_intflash_dma_done; -static uint8_t ao_intflash_dma; - -/* - * The internal flash chip is arranged in 1kB sectors; the - * chip cannot erase in units smaller than that. - * - * Writing happens in units of 2 bytes and - * can only change bits from 1 to 0. So, you can rewrite - * the same contents, or append to an existing page easily enough - */ - -/* - * Erase the specified sector - */ -uint8_t -ao_storage_erase(uint32_t pos) __reentrant -{ - uint16_t addr; - - if (pos >= ao_storage_total || pos + ao_storage_block > ao_storage_total) - return 0; - - addr = ((uint16_t)(ao_intflash + pos) >> 1); - - FADDRH = addr >> 8; - FADDRL = addr; - - __critical { - _asm - .even - orl _FCTL, #FCTL_ERASE; ; FCTL |= FCTL_ERASE - nop ; Required, see datasheet. - _endasm; - } - - return 1; -} - -/* - * Write to flash - */ - -static void -ao_intflash_write_aligned(uint16_t pos, __xdata void *d, uint16_t len) __reentrant -{ - pos = ((uint16_t) ao_intflash + pos) >> 1; - - ao_dma_set_transfer(ao_intflash_dma, - d, - &FWDATAXADDR, - len, - DMA_CFG0_WORDSIZE_8 | - DMA_CFG0_TMODE_SINGLE | - DMA_CFG0_TRIGGER_FLASH, - DMA_CFG1_SRCINC_1 | - DMA_CFG1_DESTINC_0 | - DMA_CFG1_PRIORITY_HIGH); - - FADDRH = pos >> 8; - FADDRL = pos; - - ao_dma_start(ao_intflash_dma); - - __critical { - _asm - .even - orl _FCTL, #FCTL_WRITE; ; FCTL |= FCTL_WRITE - nop - _endasm; - } - __critical while (!ao_intflash_dma_done) - ao_sleep(&ao_intflash_dma_done); -} - -static void -ao_intflash_write_byte(uint16_t pos, uint8_t byte) __reentrant -{ - static __xdata uint8_t b[2]; - - if (pos & 1) { - b[0] = 0xff; - b[1] = byte; - } else { - b[0] = byte; - b[1] = 0xff; - } - ao_intflash_write_aligned(pos, b, 2); -} - -uint8_t -ao_storage_device_write(uint32_t pos32, __xdata void *v, uint16_t len) __reentrant -{ - uint16_t pos = pos32; - __xdata uint8_t *d = v; - uint8_t oddlen; - - if (pos >= ao_storage_total || pos + len > ao_storage_total) - return 0; - if (len == 0) - return 1; - - if (pos & 1) { - ao_intflash_write_byte(pos++, *d++); - len--; - } - oddlen = len & 1; - len -= oddlen; - if (len) - ao_intflash_write_aligned(pos, d, len); - if (oddlen) - ao_intflash_write_byte(pos + len, d[len]); - - return 1; -} - -/* - * Read from flash - */ -uint8_t -ao_storage_device_read(uint32_t pos, __xdata void *d, uint16_t len) __reentrant -{ - if (pos >= ao_storage_total || pos + len > ao_storage_total) - return 0; - ao_xmemcpy(d, ao_intflash+pos, len); - return 1; -} - -void -ao_storage_flush(void) __reentrant -{ -} - -void -ao_storage_setup(void) -{ -} - -void -ao_storage_device_info(void) __reentrant -{ - printf ("Using internal flash, starting at 0x%04x\n", AO_INTFLASH_LOCATION); -} - -void -ao_storage_device_init(void) -{ - ao_intflash_dma = ao_dma_alloc(&ao_intflash_dma_done); - - FWT = FLASH_TIMING; -} diff --git a/src/cc1111/ao_launch.c b/src/cc1111/ao_launch.c deleted file mode 100644 index 76d6d13b..00000000 --- a/src/cc1111/ao_launch.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include -#include -#include - -__xdata uint16_t ao_launch_ignite; - -#if 0 -#define PRINTD(...) printf(__VA_ARGS__) -#else -#define PRINTD(...) -#endif - -static void -ao_launch_run(void) -{ - for (;;) { - while (!ao_launch_ignite) - ao_sleep(&ao_launch_ignite); - ao_ignition[ao_igniter_drogue].firing = 1; - ao_ignition[ao_igniter_main].firing = 1; - AO_IGNITER_DIR |= AO_IGNITER_DROGUE_BIT | AO_IGNITER_MAIN_BIT; - AO_IGNITER_DROGUE = 1; - while (ao_launch_ignite) { - ao_launch_ignite = 0; - ao_delay(AO_MS_TO_TICKS(500)); - } - AO_IGNITER_DROGUE = 0; - ao_ignition[ao_igniter_drogue].firing = 0; - ao_ignition[ao_igniter_main].firing = 0; - } -} - -static void -ao_launch_status(void) -{ - uint8_t i; - for (;;) { - ao_delay(AO_SEC_TO_TICKS(1)); - if (ao_igniter_status(ao_igniter_drogue) == ao_igniter_ready) { - if (ao_igniter_status(ao_igniter_main) == ao_igniter_ready) { - for (i = 0; i < 5; i++) { - ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(50)); - ao_delay(AO_MS_TO_TICKS(100)); - } - } else { - ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200)); - } - } - } -} - -static __pdata uint8_t ao_launch_armed; -static __pdata uint16_t ao_launch_arm_time; - -static void -ao_launch(void) -{ - static __xdata struct ao_launch_command command; - static __xdata struct ao_launch_query query; - int16_t time_difference; - - ao_led_off(AO_LED_RED); - ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200)); - for (;;) { - flush(); - if (ao_radio_cmac_recv(&command, sizeof (command), 0) != AO_RADIO_CMAC_OK) - continue; - - PRINTD ("tick %d serial %d cmd %d channel %d\n", - command.tick, command.serial, command.cmd, command.channel); - - switch (command.cmd) { - case AO_LAUNCH_QUERY: - if (command.serial != ao_serial_number) { - PRINTD ("serial number mismatch\n"); - break; - } - - if (command.channel == 0) { - query.valid = 1; - query.arm_status = ao_igniter_status(ao_igniter_drogue); - query.igniter_status = ao_igniter_status(ao_igniter_main); - } else { - query.valid = 0; - } - query.tick = ao_time(); - query.serial = ao_serial_number; - query.channel = command.channel; - PRINTD ("query tick %d serial %d channel %d valid %d arm %d igniter %d\n", - query.tick, query.serial, query.channel, query.valid, query.arm_status, - query.igniter_status); - ao_radio_cmac_send(&query, sizeof (query)); - break; - case AO_LAUNCH_ARM: - if (command.serial != ao_serial_number) { - PRINTD ("serial number mismatch\n"); - break; - } - - if (command.channel != 0) - break; - time_difference = command.tick - ao_time(); - PRINTD ("arm tick %d local tick %d\n", command.tick, ao_time()); - if (time_difference < 0) - time_difference = -time_difference; - if (time_difference > 10) { - PRINTD ("time difference too large %d\n", time_difference); - break; - } - PRINTD ("armed\n"); - ao_launch_armed = 1; - ao_launch_arm_time = ao_time(); - break; - case AO_LAUNCH_FIRE: - if (!ao_launch_armed) { - PRINTD ("not armed\n"); - break; - } - if ((uint16_t) (ao_time() - ao_launch_arm_time) > AO_SEC_TO_TICKS(20)) { - PRINTD ("late launch arm_time %d time %d\n", - ao_launch_arm_time, ao_time()); - break; - } - time_difference = command.tick - ao_time(); - if (time_difference < 0) - time_difference = -time_difference; - if (time_difference > 10) { - PRINTD ("time different too large %d\n", time_difference); - break; - } - PRINTD ("ignite\n"); - ao_launch_ignite = 1; - ao_wakeup(&ao_launch_ignite); - break; - } - } -} - -void -ao_launch_test(void) -{ - switch (ao_igniter_status(ao_igniter_drogue)) { - case ao_igniter_ready: - case ao_igniter_active: - printf ("Armed: "); - switch (ao_igniter_status(ao_igniter_main)) { - default: - printf("unknown status\n"); - break; - case ao_igniter_ready: - printf("igniter good\n"); - break; - case ao_igniter_open: - printf("igniter bad\n"); - break; - } - break; - default: - printf("Disarmed\n"); - } -} - -void -ao_launch_manual(void) -{ - ao_cmd_white(); - if (!ao_match_word("DoIt")) - return; - ao_cmd_white(); - ao_launch_ignite = 1; - ao_wakeup(&ao_launch_ignite); -} - -static __xdata struct ao_task ao_launch_task; -static __xdata struct ao_task ao_launch_ignite_task; -static __xdata struct ao_task ao_launch_status_task; - -__code struct ao_cmds ao_launch_cmds[] = { - { ao_launch_test, "t\0Test launch continuity" }, - { ao_launch_manual, "i \0Fire igniter. is doit with D&I" }, - { 0, NULL } -}; - -void -ao_launch_init(void) -{ - AO_IGNITER_DROGUE = 0; - AO_IGNITER_MAIN = 0; - AO_IGNITER_DIR |= AO_IGNITER_DROGUE_BIT | AO_IGNITER_MAIN_BIT; - ao_cmd_register(&ao_launch_cmds[0]); - ao_add_task(&ao_launch_task, ao_launch, "launch listener"); - ao_add_task(&ao_launch_ignite_task, ao_launch_run, "launch igniter"); - ao_add_task(&ao_launch_status_task, ao_launch_status, "launch status"); -} diff --git a/src/cc1111/ao_launch.h b/src/cc1111/ao_launch.h deleted file mode 100644 index 966b5cea..00000000 --- a/src/cc1111/ao_launch.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright © 2017 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - */ - -#ifndef _AO_LAUNCH_H_ -#define _AO_LAUNCH_H_ -/* ao_launch.c */ - -struct ao_launch_command { - uint16_t tick; - uint16_t serial; - uint8_t cmd; - uint8_t channel; - uint16_t unused; -}; - -#define AO_LAUNCH_QUERY 1 - -struct ao_launch_query { - uint16_t tick; - uint16_t serial; - uint8_t channel; - uint8_t valid; - uint8_t arm_status; - uint8_t igniter_status; -}; - -#define AO_LAUNCH_ARM 2 -#define AO_LAUNCH_FIRE 3 - -void -ao_launch_init(void); - -#endif /* _AO_LAUNCH_H_ */ diff --git a/src/cc1111/ao_lcd_port.c b/src/cc1111/ao_lcd_port.c deleted file mode 100644 index 9b588090..00000000 --- a/src/cc1111/ao_lcd_port.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -static void -ao_lcd_port_delay(void) -{ - uint8_t i; - - for (i = 0; i < 100; i++) - ao_arch_nop(); -} - -void -ao_lcd_port_put_nibble(uint8_t rs, uint8_t nibble) -{ - P0 = (P0 & 0xf0) | (nibble & 0x0f); - P1_1 = rs; - P1_0 = 1; - ao_lcd_port_delay(); - P1_0 = 0; - ao_lcd_port_delay(); -} - -void -ao_lcd_port_init(void) -{ - /* LCD_E and LCD_RS are GPIO outputs */ - P1DIR |= 0x03; - P1SEL &= ~0x03; - - /* LCD D4-D7 are GPIO outputs */ - P0DIR |= 0x0f; - P0SEL &= ~0x0f; -} diff --git a/src/cc1111/ao_led.c b/src/cc1111/ao_led.c deleted file mode 100644 index 5fae46c2..00000000 --- a/src/cc1111/ao_led.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright © 2009 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -__pdata uint8_t ao_led_enable; - -void -ao_led_on(uint8_t colors) -{ - P1 |= (colors & ao_led_enable); -} - -void -ao_led_off(uint8_t colors) -{ - P1 &= ~(colors & ao_led_enable); -} - -void -ao_led_set(uint8_t colors) -{ - P1 = (P1 & ~(ao_led_enable)) | (colors & ao_led_enable); -} - -void -ao_led_toggle(uint8_t colors) -{ - P1 ^= (colors & ao_led_enable); -} - -void -ao_led_for(uint8_t colors, uint16_t ticks) __reentrant -{ - ao_led_on(colors); - ao_delay(ticks); - ao_led_off(colors); -} - -void -ao_led_init(uint8_t enable) -{ - ao_led_enable = enable; - P1SEL &= ~enable; - P1 &= ~enable; - P1DIR |= enable; -} diff --git a/src/cc1111/ao_pins.h b/src/cc1111/ao_pins.h deleted file mode 100644 index 9d6e1c1d..00000000 --- a/src/cc1111/ao_pins.h +++ /dev/null @@ -1,655 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_PINS_H_ -#define _AO_PINS_H_ - -#define HAS_RADIO 1 -#define DISABLE_LOG_SPACE 1 -#define AO_VALUE_32 0 -#define HAS_WIDE_GPS 0 - -#if defined(TELEMETRUM_V_1_0) - /* Discontinued and was never built with CC1111 chips needing this */ - #define NEEDS_CC1111_CLOCK_HACK 0 - #define HAS_FLIGHT 1 - #define HAS_USB 1 - #define HAS_BEEP 1 - #define HAS_BEEP_CONFIG 0 - #define HAS_GPS 1 - #define HAS_SERIAL_1 1 - #define HAS_ADC 1 - #define HAS_EEPROM 1 - #define HAS_LOG 1 - #define USE_INTERNAL_FLASH 0 - #define HAS_DBG 1 - #define DBG_ON_P1 1 - #define DBG_ON_P0 0 - #define IGNITE_ON_P2 1 - #define IGNITE_ON_P0 0 - #define PACKET_HAS_MASTER 0 - #define PACKET_HAS_SLAVE 1 - #define NOISY_ACCEL 1 - - #define HAS_COMPANION 1 - #define COMPANION_CS_ON_P1 1 - #define AO_COMPANION_CS_PORT P1 - #define AO_COMPANION_CS_PIN 2 - #define AO_COMPANION_CS P1_2 - - #define AO_LED_RED 1 - #define LEDS_AVAILABLE (AO_LED_RED) - #define HAS_EXTERNAL_TEMP 0 - #define HAS_ACCEL_REF 0 - #define HAS_ACCEL 1 - #define HAS_IGNITE 1 - #define HAS_MONITOR 0 - #define HAS_TELEMETRY 1 - #define HAS_RADIO_RATE 0 /* not enough space for this */ - #define HAS_MUTEX_TRY 0 - #define HAS_TASK_INFO 0 /* not enough space for this either */ - #define AO_LOG_FORMAT AO_LOG_FORMAT_FULL -#endif - -#if defined(TELEMETRUM_V_1_1) - /* Discontinued and was never built with CC1111 chips needing this */ - #define NEEDS_CC1111_CLOCK_HACK 0 - #define HAS_FLIGHT 1 - #define HAS_USB 1 - #define HAS_BEEP 1 - #define HAS_BEEP_CONFIG 0 - #define HAS_BATTERY_REPORT 1 - #define HAS_GPS 1 - #define HAS_SERIAL_1 1 - #define HAS_ADC 1 - #define HAS_EEPROM 1 - #define HAS_LOG 1 - #define USE_INTERNAL_FLASH 0 - #define HAS_DBG 1 - #define DBG_ON_P1 1 - #define DBG_ON_P0 0 - #define IGNITE_ON_P2 1 - #define IGNITE_ON_P0 0 - #define PACKET_HAS_MASTER 0 - #define PACKET_HAS_SLAVE 1 - - #define HAS_COMPANION 1 - #define AO_COMPANION_CS_PORT P1 - #define AO_COMPANION_CS_PIN 2 - #define AO_COMPANION_CS P1_2 - - #define AO_LED_RED 1 - #define LEDS_AVAILABLE (AO_LED_RED) - #define HAS_EXTERNAL_TEMP 0 - #define HAS_ACCEL_REF 1 - #define SPI_CS_ON_P1 1 - #define SPI_CS_ON_P0 0 - #define AO_M25_SPI_CS_MASK 0x02 /* CS0 is P1_1 */ - #define M25_MAX_CHIPS 1 - #define HAS_ACCEL 1 - #define HAS_IGNITE 1 - #define HAS_MONITOR 0 - #define HAS_TELEMETRY 1 - #define HAS_RADIO_RATE 0 /* not enough space for this */ - #define HAS_MUTEX_TRY 0 - #define AO_LOG_FORMAT AO_LOG_FORMAT_FULL -#endif - -#if defined(TELEMETRUM_V_1_2) - /* Discontinued and was never built with CC1111 chips needing this */ - #define NEEDS_CC1111_CLOCK_HACK 0 - #define HAS_FLIGHT 1 - #define HAS_USB 1 - #define HAS_BEEP 1 - #define HAS_BEEP_CONFIG 0 - #define HAS_BATTERY_REPORT 1 - #define HAS_GPS 1 - #define HAS_SERIAL_1 1 - #define HAS_ADC 1 - #define HAS_EEPROM 1 - #define HAS_LOG 1 - #define USE_INTERNAL_FLASH 0 - #define HAS_DBG 1 - #define DBG_ON_P1 1 - #define DBG_ON_P0 0 - #define IGNITE_ON_P2 1 - #define IGNITE_ON_P0 0 - #define PACKET_HAS_MASTER 0 - #define PACKET_HAS_SLAVE 1 - - #define HAS_COMPANION 1 - #define AO_COMPANION_CS_PORT P1 - #define AO_COMPANION_CS_PIN 2 - #define AO_COMPANION_CS P1_2 - - #define AO_LED_RED 1 - #define LEDS_AVAILABLE (AO_LED_RED) - #define HAS_EXTERNAL_TEMP 0 - #define HAS_ACCEL_REF 1 - #define SPI_CS_ON_P1 1 - #define SPI_CS_ON_P0 0 - #define AO_M25_SPI_CS_MASK 0x02 /* CS0 is P1_1 */ - #define M25_MAX_CHIPS 1 - #define HAS_ACCEL 1 - #define HAS_IGNITE 1 - #define HAS_MONITOR 0 - #define HAS_TELEMETRY 1 - #define HAS_RADIO_RATE 0 /* not enough space for this */ - #define HAS_MUTEX_TRY 0 - #define AO_LOG_FORMAT AO_LOG_FORMAT_FULL -#endif - -#if defined(TELEDONGLE_V_0_2) - #define HAS_FLIGHT 0 - #define HAS_USB 1 - #define HAS_BEEP 0 - #define HAS_SERIAL_1 0 - #define HAS_ADC 0 - #define HAS_DBG 1 - #define HAS_EEPROM 0 - #define HAS_LOG 0 - #define DBG_ON_P1 1 - #define DBG_ON_P0 0 - #define IGNITE_ON_P2 0 - #define IGNITE_ON_P0 0 - #define PACKET_HAS_MASTER 1 - #define PACKET_HAS_SLAVE 0 - #define AO_LED_RED 1 - #define AO_LED_GREEN 2 - #define AO_MONITOR_LED AO_LED_GREEN - #define LEDS_AVAILABLE (AO_LED_RED|AO_LED_GREEN) - #define SPI_CS_ON_P1 1 - #define SPI_CS_ON_P0 0 - #define HAS_IGNITE 0 - #define HAS_MONITOR 1 - #define LEGACY_MONITOR 1 - #define HAS_RSSI 1 - #define HAS_AES 0 - #define HAS_TELEMETRY 0 - #define AO_RADIO_REG_TEST 1 -#endif - -#if defined(TELEMINI_V_1_0) - /* Discontinued and was never built with CC1111 chips needing this */ - #define NEEDS_CC1111_CLOCK_HACK 0 - #define HAS_FLIGHT 1 - #define HAS_USB 0 - #define HAS_BEEP 0 - #define HAS_GPS 0 - #define HAS_SERIAL_1 0 - #define HAS_ADC 1 - #define HAS_EEPROM 1 - #define HAS_LOG 1 - #define HAS_FORCE_FREQ 1 - #define USE_INTERNAL_FLASH 1 - #define HAS_DBG 0 - #define IGNITE_ON_P2 0 - #define IGNITE_ON_P0 1 - #define PACKET_HAS_MASTER 0 - #define PACKET_HAS_SLAVE 1 - #define USE_FAST_ASCENT_LOG 1 - - #define AO_LED_GREEN 1 - #define AO_LED_RED 2 - #define LEDS_AVAILABLE (AO_LED_RED|AO_LED_GREEN) - #define HAS_EXTERNAL_TEMP 0 - #define HAS_ACCEL 0 - #define HAS_IGNITE 1 - #define HAS_MONITOR 0 - #define HAS_TELEMETRY 1 - #define HAS_RADIO_RATE 0 /* not enough space for this */ - #define AO_LOG_FORMAT AO_LOG_FORMAT_TINY -#endif - -#if defined(TELENANO_V_0_1) - /* Discontinued and was never built with CC1111 chips needing this */ - #define NEEDS_CC1111_CLOCK_HACK 0 - #define HAS_FLIGHT 1 - #define HAS_USB 0 - #define HAS_BEEP 0 - #define HAS_GPS 0 - #define HAS_SERIAL_1 0 - #define HAS_ADC 1 - #define HAS_EEPROM 1 - #define HAS_LOG 1 - #define USE_INTERNAL_FLASH 1 - #define HAS_DBG 0 - #define IGNITE_ON_P2 0 - #define IGNITE_ON_P0 1 - #define PACKET_HAS_MASTER 0 - #define PACKET_HAS_SLAVE 1 - - #define AO_LED_GREEN 1 - #define AO_LED_RED 2 - #define LEDS_AVAILABLE (AO_LED_RED|AO_LED_GREEN) - #define HAS_EXTERNAL_TEMP 0 - #define HAS_ACCEL 0 - #define HAS_IGNITE 0 - #define HAS_MONITOR 0 - #define HAS_TELEMETRY 1 - #define HAS_RADIO_RATE 0 /* not enough space for this */ -#endif - -#if defined(TELEMETRUM_V_0_1) - /* Discontinued and was never built with CC1111 chips needing this */ - #define NEEDS_CC1111_CLOCK_HACK 0 - #define HAS_FLIGHT 1 - #define HAS_USB 1 - #define HAS_BEEP 1 - #define HAS_BEEP_CONFIG 0 - #define HAS_GPS 1 - #define HAS_SERIAL_1 1 - #define HAS_ADC 1 - #define HAS_DBG 0 - #define HAS_EEPROM 1 - #define HAS_LOG 1 - #define USE_INTERNAL_FLASH 0 - #define DBG_ON_P1 0 - #define DBG_ON_P0 1 - #define IGNITE_ON_P2 1 - #define IGNITE_ON_P0 0 - #define PACKET_HAS_MASTER 0 - #define PACKET_HAS_SLAVE 1 - #define AO_LED_RED 2 - #define AO_LED_GREEN 1 - #define LEDS_AVAILABLE (AO_LED_RED|AO_LED_GREEN) - #define HAS_EXTERNAL_TEMP 1 - #define HAS_ACCEL_REF 0 - #define SPI_CS_ON_P1 1 - #define SPI_CS_ON_P0 0 - #define HAS_ACCEL 1 - #define HAS_IGNITE 1 - #define HAS_MONITOR 0 - #define HAS_TELEMETRY 1 - #define HAS_RADIO_RATE 0 /* not enough space for this */ - #define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX ((uint32_t) 127 * (uint32_t) 1024) - #define AO_LOG_FORMAT AO_LOG_FORMAT_FULL -#endif - -#if defined(TELEDONGLE_V_0_1) - /* Discontinued and was never built with CC1111 chips needing this */ - #define NEEDS_CC1111_CLOCK_HACK 0 - #define HAS_FLIGHT 0 - #define HAS_USB 1 - #define HAS_BEEP 0 - #define HAS_SERIAL_1 0 - #define HAS_ADC 0 - #define HAS_DBG 0 - #define HAS_EEPROM 0 - #define HAS_LOG 0 - #define DBG_ON_P1 0 - #define DBG_ON_P0 1 - #define IGNITE_ON_P2 0 - #define IGNITE_ON_P0 0 - #define PACKET_HAS_MASTER 1 - #define PACKET_HAS_SLAVE 0 - #define AO_LED_RED 2 - #define AO_LED_GREEN 1 - #define AO_MONITOR_LED AO_LED_GREEN - #define LEDS_AVAILABLE (AO_LED_RED|AO_LED_GREEN) - #define SPI_CS_ON_P1 0 - #define SPI_CS_ON_P0 1 - #define HAS_IGNITE 0 - #define HAS_MONITOR 1 - #define LEGACY_MONITOR 1 - #define HAS_RSSI 1 - #define HAS_AES 0 - #define HAS_TELEMETRY 0 -#endif - -#if defined(TIDONGLE) - /* Discontinued and was never built with CC1111 chips needing this */ - #define NEEDS_CC1111_CLOCK_HACK 0 - #define HAS_FLIGHT 0 - #define HAS_USB 1 - #define HAS_BEEP 0 - #define HAS_SERIAL_1 0 - #define HAS_ADC 0 - #define HAS_DBG 1 - #define HAS_EEPROM 0 - #define HAS_LOG 0 - #define DBG_ON_P1 0 - #define DBG_ON_P0 1 - #define IGNITE_ON_P2 0 - #define IGNITE_ON_P0 0 - #define PACKET_HAS_MASTER 1 - #define PACKET_HAS_SLAVE 0 - #define AO_LED_RED 2 - #define AO_MONITOR_LED AO_LED_RED - #define LEDS_AVAILABLE (AO_LED_RED) - #define SPI_CS_ON_P1 0 - #define SPI_CS_ON_P0 1 - #define HAS_IGNITE 0 - #define HAS_MONITOR 1 - #define LEGACY_MONITOR 1 - #define HAS_RSSI 1 - #define HAS_AES 0 - #define HAS_TELEMETRY 0 -#endif - -#if defined(TELEBT_V_0_0) - /* Discontinued and was never built with CC1111 chips needing this */ - #define NEEDS_CC1111_CLOCK_HACK 0 - #define HAS_FLIGHT 0 - #define HAS_USB 1 - #define HAS_BEEP 0 - #define HAS_SERIAL_1 1 - #define USE_SERIAL_1_STDIN 1 - #define DELAY_SERIAL_1_STDIN 1 - #define HAS_ADC 0 - #define HAS_DBG 1 - #define HAS_EEPROM 0 - #define HAS_LOG 0 - #define HAS_BTM 1 - #define DBG_ON_P1 0 - #define DBG_ON_P0 1 - #define IGNITE_ON_P2 0 - #define IGNITE_ON_P0 0 - #define PACKET_HAS_MASTER 1 - #define PACKET_HAS_SLAVE 0 - #define AO_LED_RED 2 - #define AO_LED_GREEN 1 - #define AO_MONITOR_LED AO_LED_RED - #define LEDS_AVAILABLE (AO_LED_RED|AO_LED_GREEN) - #define SPI_CS_ON_P1 1 - #define SPI_CS_ON_P0 0 - #define HAS_IGNITE 0 - #define HAS_IGNITE_REPORT 1 - #define BT_LINK_ON_P2 1 - #define BT_LINK_ON_P1 0 - #define BT_LINK_PIN_INDEX 7 - #define BT_LINK_PIN P2_1 - #define HAS_MONITOR 1 - #define LEGACY_MONITOR 1 - #define HAS_RSSI 0 - #define HAS_AES 0 - #define HAS_TELEMETRY 0 - #define AO_RADIO_REG_TEST 1 -#endif - -#if defined(TELEBT_V_0_1) - /* Discontinued and was never built with CC1111 chips needing this */ - #define NEEDS_CC1111_CLOCK_HACK 0 - #define HAS_FLIGHT 0 - #define HAS_USB 1 - #define HAS_BEEP 1 - #define HAS_BEEP_CONFIG 0 - #define HAS_SERIAL_1 1 - #define HAS_SERIAL_1_ALT_1 1 - #define HAS_SERIAL_1_ALT_2 0 - #define HAS_SERIAL_1_HW_FLOW 1 - #define USE_SERIAL_1_STDIN 1 - #define DELAY_SERIAL_1_STDIN 1 - #define HAS_ADC 0 - #define HAS_DBG 1 - #define HAS_EEPROM 1 - #define HAS_LOG 1 - #define USE_INTERNAL_FLASH 0 - #define HAS_BTM 1 - #define DBG_ON_P1 1 - #define DBG_ON_P0 0 - #define IGNITE_ON_P2 0 - #define IGNITE_ON_P0 0 - #define PACKET_HAS_MASTER 1 - #define PACKET_HAS_SLAVE 0 - #define AO_LED_RED 1 - #define AO_LED_GREEN 2 - #define AO_MONITOR_LED AO_LED_RED - #define LEDS_AVAILABLE (AO_LED_RED|AO_LED_GREEN) - #define SPI_CS_ON_P1 1 - #define SPI_CS_ON_P0 0 - #define AO_M25_SPI_CS_MASK 0x04 /* CS0 is P1_2 */ - #define M25_MAX_CHIPS 1 - #define HAS_ACCEL 0 - #define HAS_IGNITE 0 - #define HAS_IGNITE_REPORT 1 - #define BT_LINK_ON_P2 0 - #define BT_LINK_ON_P1 1 - #define BT_LINK_PIN_INDEX 7 - #define BT_LINK_PIN P1_7 - #define HAS_MONITOR 1 - #define LEGACY_MONITOR 1 - #define HAS_RSSI 0 - #define HAS_AES 0 - #define HAS_TELEMETRY 0 - #define AO_RADIO_REG_TEST 1 -#endif - -#if defined(TELELAUNCH_V_0_1) - /* Discontinued and was never built with CC1111 chips needing this */ - #define NEEDS_CC1111_CLOCK_HACK 0 - #define HAS_FLIGHT 0 - #define HAS_USB 1 - #define HAS_BEEP 1 - #define HAS_GPS 0 - #define HAS_SERIAL_1 1 - #define HAS_ADC 1 - #define HAS_DBG 0 - #define HAS_EEPROM 1 - #define HAS_LOG 0 - #define USE_INTERNAL_FLASH 1 - #define DBG_ON_P1 0 - #define DBG_ON_P0 1 - #define IGNITE_ON_P2 1 - #define IGNITE_ON_P0 0 - #define PACKET_HAS_MASTER 0 - #define PACKET_HAS_SLAVE 0 - #define AO_LED_RED 2 - #define AO_LED_GREEN 1 - #define LEDS_AVAILABLE (AO_LED_RED|AO_LED_GREEN) - #define HAS_EXTERNAL_TEMP 1 - #define HAS_ACCEL_REF 0 - #define SPI_CS_ON_P1 1 - #define SPI_CS_ON_P0 0 - #define HAS_ACCEL 0 - #define HAS_IGNITE 1 - #define HAS_MONITOR 0 - #define HAS_AES 1 - #define HAS_TELEMETRY 0 -#endif - -#if DBG_ON_P1 - - #define DBG_CLOCK (1 << 4) /* mi0 */ - #define DBG_DATA (1 << 5) /* mo0 */ - #define DBG_RESET_N (1 << 3) /* c0 */ - - #define DBG_CLOCK_PIN (P1_4) - #define DBG_DATA_PIN (P1_5) - #define DBG_RESET_N_PIN (P1_3) - - #define DBG_PORT_NUM 1 - #define DBG_PORT P1 - #define DBG_PORT_SEL P1SEL - #define DBG_PORT_INP P1INP - #define DBG_PORT_DIR P1DIR - -#endif /* DBG_ON_P1 */ - -#if DBG_ON_P0 - - #define DBG_CLOCK (1 << 3) - #define DBG_DATA (1 << 4) - #define DBG_RESET_N (1 << 5) - - #define DBG_CLOCK_PIN (P0_3) - #define DBG_DATA_PIN (P0_4) - #define DBG_RESET_N_PIN (P0_5) - - #define DBG_PORT_NUM 0 - #define DBG_PORT P0 - #define DBG_PORT_SEL P0SEL - #define DBG_PORT_INP P0INP - #define DBG_PORT_DIR P0DIR - -#endif /* DBG_ON_P0 */ - -#if COMPANION_CS_ON_P1 - #define COMPANION_CS_PORT P1 - #define COMPANION_CS_SEL P1SEL - #define COMPANION_CS_DIR P1DIR -#endif - -#if SPI_CS_ON_P1 - #define SPI_CS_PORT P1 - #define SPI_CS_SEL P1SEL - #define SPI_CS_DIR P1DIR -#endif - -#if SPI_CS_ON_P0 - #define SPI_CS_PORT P0 - #define SPI_CS_SEL P0SEL - #define SPI_CS_DIR P0DIR -#endif - -#define AO_M25_SPI_CS_PORT SPI_CS_PORT - -#ifndef IGNITE_ON_P2 -#error Please define IGNITE_ON_P2 -#endif - -#ifndef IGNITE_ON_P0 -#error Please define IGNITE_ON_P0 -#endif - -#ifndef HAS_ADC -#error Please define HAS_ADC -#endif - -#ifndef HAS_EEPROM -#error Please define HAS_EEPROM -#endif - -#ifndef HAS_LOG -#error Please define HAS_LOG -#endif - -#if HAS_EEPROM -#ifndef USE_INTERNAL_FLASH -#error Please define USE_INTERNAL_FLASH -#endif -#endif - -#ifndef HAS_DBG -#error Please define HAS_DBG -#endif - -#ifndef HAS_IGNITE -#error Please define HAS_IGNITE -#endif - -#if HAS_IGNITE -#define HAS_IGNITE_REPORT 1 -#endif - -#ifndef PACKET_HAS_MASTER -#error Please define PACKET_HAS_MASTER -#endif - -#ifndef PACKET_HAS_SLAVE -#error Please define PACKET_HAS_SLAVE -#endif - -#ifndef HAS_MONITOR -#error Please define HAS_MONITOR -#endif - -#if HAS_MONITOR -#ifndef HAS_RSSI -#error Please define HAS_RSSI -#endif -#endif - -#ifndef HAS_ADC -#error Please define HAS_ADC -#endif - -#if HAS_ADC - -#if HAS_ACCEL -#ifndef HAS_ACCEL_REF -#error Please define HAS_ACCEL_REF -#endif -#else -#define HAS_ACCEL_REF 0 -#endif - -#endif /* HAS_ADC */ - -#if IGNITE_ON_P2 -#define AO_IGNITER_PORT P2 -#define AO_IGNITER_DROGUE_PORT AO_IGNITER_PORT -#define AO_IGNITER_DROGUE P2_3 -#define AO_IGNITER_MAIN P2_4 -#define AO_IGNITER_DIR P2DIR -#define AO_IGNITER_DROGUE_BIT (1 << 3) -#define AO_IGNITER_MAIN_BIT (1 << 4) -#define AO_IGNITER_DROGUE_PIN 3 -#define AO_IGNITER_MAIN_PIN 4 -#endif - -#if IGNITE_ON_P0 -#define AO_IGNITER_PORT P0 -#define AO_IGNITER_DROGUE P0_5 -#define AO_IGNITER_MAIN P0_4 -#define AO_IGNITER_DIR P0DIR -#define AO_IGNITER_DROGUE_BIT (1 << 5) -#define AO_IGNITER_MAIN_BIT (1 << 4) -#define AO_IGNITER_DROGUE_PIN 5 -#define AO_IGNITER_MAIN_PIN 4 -#endif - -#define AO_IGNITER_DROGUE_PORT AO_IGNITER_PORT -#define AO_IGNITER_MAIN_PORT AO_IGNITER_PORT - -/* test these values with real igniters */ -#define AO_IGNITER_OPEN 1000 -#define AO_IGNITER_CLOSED 7000 -#define AO_IGNITER_FIRE_TIME AO_MS_TO_TICKS(50) -#define AO_IGNITER_CHARGE_TIME AO_MS_TO_TICKS(2000) - -struct ao_adc { - int16_t accel; /* accelerometer */ - int16_t pres; /* pressure sensor */ - int16_t temp; /* temperature sensor */ - int16_t v_batt; /* battery voltage */ - int16_t sense_d; /* drogue continuity sense */ - int16_t sense_m; /* main continuity sense */ -#if HAS_ACCEL_REF - uint16_t accel_ref; /* acceleration reference */ -#endif -}; - -/* - * Voltage divider on ADC battery sampler - */ -#define AO_BATTERY_DIV_PLUS 5 /* 5k */ -#define AO_BATTERY_DIV_MINUS 10 /* 10k */ - -/* - * Voltage divider on ADC igniter samplers - */ -#define AO_IGNITE_DIV_PLUS 100 /* 100k */ -#define AO_IGNITE_DIV_MINUS 27 /* 27k */ - -/* - * ADC reference in decivolts - */ -#define AO_ADC_REFERENCE_DV 33 - -#endif /* _AO_PINS_H_ */ diff --git a/src/cc1111/ao_radio.c b/src/cc1111/ao_radio.c deleted file mode 100644 index 166d14d5..00000000 --- a/src/cc1111/ao_radio.c +++ /dev/null @@ -1,689 +0,0 @@ -/* - * Copyright © 2009 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" -#if HAS_PAD -#include -#endif - -/* Values from SmartRF® Studio for: - * - * Deviation: 20.507812 kHz - * Datarate: 38.360596 kBaud - * Modulation: GFSK - * RF Freq: 434.549927 MHz - * Channel: 99.975586 kHz - * Channel: 0 - * RX filter: 93.75 kHz - */ - -/* - * For IF freq of 140.62kHz, the IF value is: - * - * 140.62e3 / (24e6 / 2**10) = 6 - */ - -#define IF_FREQ_CONTROL 6 - -/* - * http://www.ntia.doc.gov/files/ntia/publications/84-168.pdf - * - * Necessary bandwidth for a FSK modulated signal: - * - * bw = 2.6d + 0.55b 1.5 < m < 5.5 - * bw = 2.1d + 1.9b 5.5 < m < 20 - * - * b is the modulation rate in bps - * d is the peak deviation (from the center) - * - * m = 2d / b - * - * 20.5 kHz deviation 38.4kbps signal: - * - * m = 41 / 38.4, which is < 5.5: - * - * bw = 2.6 * 20.5 + 0.55 * 38.4 = 74.42kHz - * - * M = 1, E = 3, bw = 75kHz - * - * 5.125 kHz deviation, 9.6kbps signal - * - * m = 10.25 / 9.6, which is < 5.5: - * - * bw = 2.6 * 5.125 + 0.55 * 9.6 = 18.6kHz - * - * M = 2, E = 3, bw = 53.6kHz - * - * 1.28125kHz deviation, 2.4kbps signal - * - * m = 2.565 / 2.4, which is < 5.5: - * - * bw = 2.6 * 20.5 + 1.9 * 2.4 = 47.61kHz - * - * M = 3, E = 3, bw = 53.6kHz - * - * For channel bandwidth of 93.75 kHz, the CHANBW_E and CHANBW_M values are - * - * BW = 24e6 / (8 * (4 + M) * 2 ** E) - * - * So, M = 0 and E = 3 - */ - -#define CHANBW_M_384 1 -#define CHANBW_M_96 3 -#define CHANBW_M_24 3 -#define CHANBW_E 3 - -/* - * For a symbol rate of 38360kBaud, the DRATE_E and DRATE_M values are: - * - * R = (256 + M) * 2** E * 24e6 / 2**28 - * - * So for 38360kBaud, M is 163 and E is 10 - */ - -#define DRATE_M 163 - -#define DRATE_E_384 10 - -/* For 9600 baud, M is 163 and E is 8 - */ - -#define DRATE_E_96 8 - -/* For 2400 baud, M is 163 and E is 6 - */ - -#define DRATE_E_24 6 - -/* - * For a channel deviation of 20.5kHz, the DEVIATION_E and DEVIATION_M values are: - * - * F = 24e6/2**17 * (8 + DEVIATION_M) * 2**DEVIATION_E - * - * For 20.5kHz deviation, M is 6 and E is 3 - * For 5.125kHz deviation, M is 6 and E is 1 - * For 1.28125kHz deviation, M is 0 and E is 0 - */ - -#define DEVIATION_M_384 6 -#define DEVIATION_E_384 3 - -#define DEVIATION_M_96 6 -#define DEVIATION_E_96 1 - -#define DEVIATION_M_24 0 -#define DEVIATION_E_24 0 - -/* - * For our RDF beacon, set the symbol rate to 2kBaud (for a 1kHz tone), - * so the DRATE_E and DRATE_M values are: - * - * M is 94 and E is 6 - * - * To make the tone last for 200ms, we need 2000 * .2 = 400 bits or 50 bytes - */ - -#define RDF_DRATE_E 6 -#define RDF_DRATE_M 94 -#define RDF_PACKET_LEN 50 - -/* - * RDF deviation should match the normal NFM value of 5kHz - * - * M is 6 and E is 1 - * - */ - -#define RDF_DEVIATION_M 6 -#define RDF_DEVIATION_E 1 - -/* This are from the table for 433MHz */ - -#define RF_POWER_M30_DBM 0x12 -#define RF_POWER_M20_DBM 0x0e -#define RF_POWER_M15_DBM 0x1d -#define RF_POWER_M10_DBM 0x34 -#define RF_POWER_M5_DBM 0x2c -#define RF_POWER_0_DBM 0x60 -#define RF_POWER_5_DBM 0x84 -#define RF_POWER_7_DBM 0xc8 -#define RF_POWER_10_DBM 0xc0 - -#define RF_POWER RF_POWER_10_DBM - -static __code uint8_t radio_setup[] = { - RF_PA_TABLE7_OFF, RF_POWER, - RF_PA_TABLE6_OFF, RF_POWER, - RF_PA_TABLE5_OFF, RF_POWER, - RF_PA_TABLE4_OFF, RF_POWER, - RF_PA_TABLE3_OFF, RF_POWER, - RF_PA_TABLE2_OFF, RF_POWER, - RF_PA_TABLE1_OFF, RF_POWER, - RF_PA_TABLE0_OFF, RF_POWER, - - RF_FSCTRL1_OFF, (IF_FREQ_CONTROL << RF_FSCTRL1_FREQ_IF_SHIFT), - RF_FSCTRL0_OFF, (0 << RF_FSCTRL0_FREQOFF_SHIFT), - - RF_MDMCFG3_OFF, (DRATE_M << RF_MDMCFG3_DRATE_M_SHIFT), - RF_MDMCFG2_OFF, (RF_MDMCFG2_DEM_DCFILT_ON | - RF_MDMCFG2_MOD_FORMAT_GFSK | - RF_MDMCFG2_SYNC_MODE_15_16), - RF_MDMCFG1_OFF, (RF_MDMCFG1_FEC_EN | - RF_MDMCFG1_NUM_PREAMBLE_4 | - (2 << RF_MDMCFG1_CHANSPC_E_SHIFT)), - RF_MDMCFG0_OFF, (17 << RF_MDMCFG0_CHANSPC_M_SHIFT), - - RF_CHANNR_OFF, 0, - - /* SmartRF says set LODIV_BUF_CURRENT_TX to 0 - * And, we're not using power ramping, so use PA_POWER 0 - */ - RF_FREND0_OFF, ((1 << RF_FREND0_LODIV_BUF_CURRENT_TX_SHIFT) | - (0 << RF_FREND0_PA_POWER_SHIFT)), - - RF_FREND1_OFF, ((1 << RF_FREND1_LNA_CURRENT_SHIFT) | - (1 << RF_FREND1_LNA2MIX_CURRENT_SHIFT) | - (1 << RF_FREND1_LODIV_BUF_CURRENT_RX_SHIFT) | - (2 << RF_FREND1_MIX_CURRENT_SHIFT)), - - RF_FSCAL3_OFF, 0xE9, - RF_FSCAL2_OFF, 0x0A, - RF_FSCAL1_OFF, 0x00, - RF_FSCAL0_OFF, 0x1F, - - RF_TEST2_OFF, RF_TEST2_RX_LOW_DATA_RATE_MAGIC, - RF_TEST1_OFF, RF_TEST1_RX_LOW_DATA_RATE_MAGIC, - RF_TEST0_OFF, 0x09, - - /* default sync values */ - RF_SYNC1_OFF, 0xD3, - RF_SYNC0_OFF, 0x91, - - /* max packet length */ - RF_PKTCTRL1_OFF, ((1 << PKTCTRL1_PQT_SHIFT)| - PKTCTRL1_APPEND_STATUS| - PKTCTRL1_ADR_CHK_NONE), - RF_PKTCTRL0_OFF, (RF_PKTCTRL0_WHITE_DATA| - RF_PKTCTRL0_PKT_FORMAT_NORMAL| - RF_PKTCTRL0_CRC_EN| - RF_PKTCTRL0_LENGTH_CONFIG_FIXED), - RF_ADDR_OFF, 0x00, - RF_MCSM2_OFF, (RF_MCSM2_RX_TIME_END_OF_PACKET), - RF_MCSM1_OFF, (RF_MCSM1_CCA_MODE_RSSI_BELOW_UNLESS_RECEIVING| - RF_MCSM1_RXOFF_MODE_IDLE| - RF_MCSM1_TXOFF_MODE_IDLE), - RF_MCSM0_OFF, (RF_MCSM0_FS_AUTOCAL_FROM_IDLE| - RF_MCSM0_MAGIC_3| - RF_MCSM0_CLOSE_IN_RX_0DB), - RF_FOCCFG_OFF, (RF_FOCCFG_FOC_PRE_K_3K, - RF_FOCCFG_FOC_POST_K_PRE_K, - RF_FOCCFG_FOC_LIMIT_BW_OVER_4), - RF_BSCFG_OFF, (RF_BSCFG_BS_PRE_K_2K| - RF_BSCFG_BS_PRE_KP_3KP| - RF_BSCFG_BS_POST_KI_PRE_KI| - RF_BSCFG_BS_POST_KP_PRE_KP| - RF_BSCFG_BS_LIMIT_0), - RF_AGCCTRL2_OFF, (RF_AGCCTRL2_MAX_DVGA_GAIN_ALL| - RF_AGCCTRL2_MAX_LNA_GAIN_0| - RF_AGCCTRL2_MAGN_TARGET_33dB), - RF_AGCCTRL1_OFF, (RF_AGCCTRL1_AGC_LNA_PRIORITY_0 | - RF_AGCCTRL1_CARRIER_SENSE_REL_THR_DISABLE | - RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_0DB), - RF_AGCCTRL0_OFF, (RF_AGCCTRL0_HYST_LEVEL_NONE | - RF_AGCCTRL0_WAIT_TIME_8 | - RF_AGCCTRL0_AGC_FREEZE_NORMAL | - RF_AGCCTRL0_FILTER_LENGTH_8), - RF_IOCFG2_OFF, 0x00, - RF_IOCFG1_OFF, 0x00, - RF_IOCFG0_OFF, 0x00, -}; - -static __code uint8_t rdf_setup[] = { - RF_MDMCFG4_OFF, ((CHANBW_E << RF_MDMCFG4_CHANBW_E_SHIFT) | - (CHANBW_M_384 << RF_MDMCFG4_CHANBW_M_SHIFT) | - (RDF_DRATE_E << RF_MDMCFG4_DRATE_E_SHIFT)), - RF_MDMCFG3_OFF, (RDF_DRATE_M << RF_MDMCFG3_DRATE_M_SHIFT), - RF_MDMCFG2_OFF, (RF_MDMCFG2_DEM_DCFILT_OFF | - RF_MDMCFG2_MOD_FORMAT_GFSK | - RF_MDMCFG2_SYNC_MODE_NONE), - RF_MDMCFG1_OFF, (RF_MDMCFG1_FEC_DIS | - RF_MDMCFG1_NUM_PREAMBLE_2 | - (2 << RF_MDMCFG1_CHANSPC_E_SHIFT)), - - RF_DEVIATN_OFF, ((RDF_DEVIATION_E << RF_DEVIATN_DEVIATION_E_SHIFT) | - (RDF_DEVIATION_M << RF_DEVIATN_DEVIATION_M_SHIFT)), - - /* packet length is set in-line */ - RF_PKTCTRL1_OFF, ((0 << PKTCTRL1_PQT_SHIFT)| - PKTCTRL1_ADR_CHK_NONE), - RF_PKTCTRL0_OFF, (RF_PKTCTRL0_PKT_FORMAT_NORMAL| - RF_PKTCTRL0_LENGTH_CONFIG_FIXED), -}; - -static __code uint8_t fixed_pkt_setup[] = { -#if !HAS_RADIO_RATE - RF_MDMCFG4_OFF, ((CHANBW_E << RF_MDMCFG4_CHANBW_E_SHIFT) | - (CHANBW_M_384 << RF_MDMCFG4_CHANBW_M_SHIFT) | - (DRATE_E_384 << RF_MDMCFG4_DRATE_E_SHIFT)), -#endif - RF_MDMCFG3_OFF, (DRATE_M << RF_MDMCFG3_DRATE_M_SHIFT), - RF_MDMCFG2_OFF, (RF_MDMCFG2_DEM_DCFILT_ON | - RF_MDMCFG2_MOD_FORMAT_GFSK | - RF_MDMCFG2_SYNC_MODE_15_16), - RF_MDMCFG1_OFF, (RF_MDMCFG1_FEC_EN | - RF_MDMCFG1_NUM_PREAMBLE_4 | - (2 << RF_MDMCFG1_CHANSPC_E_SHIFT)), - -#if !HAS_RADIO_RATE - RF_DEVIATN_OFF, ((DEVIATION_E_384 << RF_DEVIATN_DEVIATION_E_SHIFT) | - (DEVIATION_M_384 << RF_DEVIATN_DEVIATION_M_SHIFT)), -#endif - - /* max packet length -- now set inline */ - RF_PKTCTRL1_OFF, ((1 << PKTCTRL1_PQT_SHIFT)| - PKTCTRL1_APPEND_STATUS| - PKTCTRL1_ADR_CHK_NONE), - RF_PKTCTRL0_OFF, (RF_PKTCTRL0_WHITE_DATA| - RF_PKTCTRL0_PKT_FORMAT_NORMAL| - RF_PKTCTRL0_CRC_EN| - RF_PKTCTRL0_LENGTH_CONFIG_FIXED), -}; - -#if HAS_RADIO_RATE -static __code struct { - uint8_t mdmcfg4; - uint8_t deviatn; -} packet_rate_setup[] = { - /* 38400 */ - { - ((CHANBW_E << RF_MDMCFG4_CHANBW_E_SHIFT) | - (CHANBW_M_384 << RF_MDMCFG4_CHANBW_M_SHIFT) | - (DRATE_E_384 << RF_MDMCFG4_DRATE_E_SHIFT)), - ((DEVIATION_E_384 << RF_DEVIATN_DEVIATION_E_SHIFT) | - (DEVIATION_M_384 << RF_DEVIATN_DEVIATION_M_SHIFT)), - }, - /* 9600 */ - { - ((CHANBW_E << RF_MDMCFG4_CHANBW_E_SHIFT) | - (CHANBW_M_96 << RF_MDMCFG4_CHANBW_M_SHIFT) | - (DRATE_E_96 << RF_MDMCFG4_DRATE_E_SHIFT)), - ((DEVIATION_E_96 << RF_DEVIATN_DEVIATION_E_SHIFT) | - (DEVIATION_M_96 << RF_DEVIATN_DEVIATION_M_SHIFT)), - }, - /* 2400 */ - { - ((CHANBW_E << RF_MDMCFG4_CHANBW_E_SHIFT) | - (CHANBW_M_24 << RF_MDMCFG4_CHANBW_M_SHIFT) | - (DRATE_E_24 << RF_MDMCFG4_DRATE_E_SHIFT)), - ((DEVIATION_E_24 << RF_DEVIATN_DEVIATION_E_SHIFT) | - (DEVIATION_M_24 << RF_DEVIATN_DEVIATION_M_SHIFT)), - }, -}; -#endif - -__xdata uint8_t ao_radio_dma; -__xdata uint8_t ao_radio_dma_done; -__xdata uint8_t ao_radio_done; -__xdata uint8_t ao_radio_abort; -__xdata uint8_t ao_radio_mutex; - -#if PACKET_HAS_MASTER || HAS_AES -#define NEED_RADIO_RSSI 1 -#endif - -#ifndef NEED_RADIO_RSSI -#define NEED_RADIO_RSSI 0 -#endif - -#if NEED_RADIO_RSSI -__xdata int8_t ao_radio_rssi; -#endif - -void -ao_radio_general_isr(void) __interrupt 16 -{ - S1CON &= ~0x03; - if (RFIF & RFIF_IM_TIMEOUT) { - ao_radio_recv_abort(); - RFIF &= ~ RFIF_IM_TIMEOUT; - } else if (RFIF & RFIF_IM_DONE) { - ao_radio_done = 1; - ao_wakeup(&ao_radio_done); - RFIF &= ~RFIF_IM_DONE; - } -} - -static void -ao_radio_set_packet(void) -{ - uint8_t i; - for (i = 0; i < sizeof (fixed_pkt_setup); i += 2) - RF[fixed_pkt_setup[i]] = fixed_pkt_setup[i+1]; -} - -static void -ao_radio_idle(void) -{ - if (RF_MARCSTATE != RF_MARCSTATE_IDLE) - { - do { - RFST = RFST_SIDLE; - ao_yield(); - } while (RF_MARCSTATE != RF_MARCSTATE_IDLE); - } -} - -#define ao_radio_put() ao_mutex_put(&ao_radio_mutex) - -static void -ao_radio_get(uint8_t len) -{ - ao_config_get(); - ao_mutex_get(&ao_radio_mutex); - ao_radio_idle(); - RF_CHANNR = 0; - RF_FREQ2 = (uint8_t) (ao_config.radio_setting >> 16); - RF_FREQ1 = (uint8_t) (ao_config.radio_setting >> 8); - RF_FREQ0 = (uint8_t) (ao_config.radio_setting); - RF_PKTLEN = len; -#if HAS_RADIO_RATE - RF_MDMCFG4 = packet_rate_setup[ao_config.radio_rate].mdmcfg4; - RF_DEVIATN = packet_rate_setup[ao_config.radio_rate].deviatn; -#endif -} - - -void -ao_radio_send(__xdata void *packet, uint8_t size) __reentrant -{ - ao_radio_get(size); - ao_radio_done = 0; - ao_dma_set_transfer(ao_radio_dma, - packet, - &RFDXADDR, - size, - DMA_CFG0_WORDSIZE_8 | - DMA_CFG0_TMODE_SINGLE | - DMA_CFG0_TRIGGER_RADIO, - DMA_CFG1_SRCINC_1 | - DMA_CFG1_DESTINC_0 | - DMA_CFG1_PRIORITY_HIGH); - ao_dma_start(ao_radio_dma); - RFST = RFST_STX; - __critical while (!ao_radio_done) - ao_sleep(&ao_radio_done); - ao_radio_put(); -} - -uint8_t -ao_radio_recv(__xdata void *packet, uint8_t size, uint8_t timeout) __reentrant -{ - ao_radio_abort = 0; - ao_radio_get(size - 2); - ao_dma_set_transfer(ao_radio_dma, - &RFDXADDR, - packet, - size, - DMA_CFG0_WORDSIZE_8 | - DMA_CFG0_TMODE_SINGLE | - DMA_CFG0_TRIGGER_RADIO, - DMA_CFG1_SRCINC_0 | - DMA_CFG1_DESTINC_1 | - DMA_CFG1_PRIORITY_HIGH); - ao_dma_start(ao_radio_dma); - RFST = RFST_SRX; - - /* Wait for DMA to be done, for the radio receive process to - * get aborted or for a receive timeout to fire - */ - __critical while (!ao_radio_dma_done && !ao_radio_abort) - if (ao_sleep_for(&ao_radio_dma_done, timeout)) - break; - - /* If recv was aborted, clean up by stopping the DMA engine - * and idling the radio - */ - if (!ao_radio_dma_done) { - ao_dma_abort(ao_radio_dma); - ao_radio_idle(); -#if NEED_RADIO_RSSI - ao_radio_rssi = 0; -#endif - } -#if NEED_RADIO_RSSI - else - ao_radio_rssi = AO_RSSI_FROM_RADIO(((uint8_t *)packet)[size - 2]); -#endif - ao_radio_put(); - return ao_radio_dma_done; -} - -/* - * Wake up a task waiting to receive a radio packet - * and tell them to abort the transfer - */ - -void -ao_radio_recv_abort(void) -{ - ao_radio_abort = 1; - ao_wakeup(&ao_radio_dma_done); -} - -__code ao_radio_rdf_value = 0x55; - -static void -ao_radio_rdf_start(void) -{ - uint8_t i; - ao_radio_abort = 0; - ao_radio_get(AO_RADIO_RDF_LEN); - ao_radio_done = 0; - for (i = 0; i < sizeof (rdf_setup); i += 2) - RF[rdf_setup[i]] = rdf_setup[i+1]; -} - -static void -ao_radio_rdf_run(void) -{ - ao_dma_start(ao_radio_dma); - RFST = RFST_STX; - __critical while (!ao_radio_done && !ao_radio_abort) - ao_sleep(&ao_radio_done); - if (!ao_radio_done) { - ao_dma_abort(ao_radio_dma); - ao_radio_idle(); - } - ao_radio_set_packet(); - ao_radio_put(); -} - -void -ao_radio_rdf(void) -{ - ao_radio_rdf_start(); - - ao_dma_set_transfer(ao_radio_dma, - CODE_TO_XDATA(&ao_radio_rdf_value), - &RFDXADDR, - AO_RADIO_RDF_LEN, - DMA_CFG0_WORDSIZE_8 | - DMA_CFG0_TMODE_SINGLE | - DMA_CFG0_TRIGGER_RADIO, - DMA_CFG1_SRCINC_0 | - DMA_CFG1_DESTINC_0 | - DMA_CFG1_PRIORITY_HIGH); - ao_radio_rdf_run(); -} - -#define PA 0x00 -#define BE 0x55 - -#define CONT_PAUSE_8 PA, PA, PA, PA, PA, PA, PA, PA -#define CONT_PAUSE_16 CONT_PAUSE_8, CONT_PAUSE_8 -#define CONT_PAUSE_24 CONT_PAUSE_16, CONT_PAUSE_8 - -#define CONT_BEEP_8 BE, BE, BE, BE, BE, BE, BE, BE - -#if AO_RADIO_CONT_PAUSE_LEN == 24 -#define CONT_PAUSE CONT_PAUSE_24 -#endif - -#if AO_RADIO_CONT_TONE_LEN == 8 -#define CONT_BEEP CONT_BEEP_8 -#define CONT_PAUSE_SHORT CONT_PAUSE_8 -#endif - -#define CONT_ADDR(c) CODE_TO_XDATA(&ao_radio_cont[(3-(c)) * (AO_RADIO_CONT_PAUSE_LEN + AO_RADIO_CONT_TONE_LEN)]) - -__code uint8_t ao_radio_cont[] = { - CONT_PAUSE, CONT_BEEP, - CONT_PAUSE, CONT_BEEP, - CONT_PAUSE, CONT_BEEP, - CONT_PAUSE, CONT_PAUSE_SHORT, - CONT_PAUSE, CONT_PAUSE_SHORT, - CONT_PAUSE, -}; - -void -ao_radio_continuity(uint8_t c) -{ - ao_radio_rdf_start(); - ao_dma_set_transfer(ao_radio_dma, - CONT_ADDR(c), - &RFDXADDR, - AO_RADIO_CONT_TOTAL_LEN, - DMA_CFG0_WORDSIZE_8 | - DMA_CFG0_TMODE_SINGLE | - DMA_CFG0_TRIGGER_RADIO, - DMA_CFG1_SRCINC_1 | - DMA_CFG1_DESTINC_0 | - DMA_CFG1_PRIORITY_HIGH); - ao_radio_rdf_run(); -} - -void -ao_radio_rdf_abort(void) -{ - ao_radio_abort = 1; - ao_wakeup(&ao_radio_done); -} - - -/* Output carrier */ - -static __xdata radio_test_on; - -void -ao_radio_test(uint8_t on) -{ - if (on) { - if (!radio_test_on) { -#if HAS_MONITOR - ao_monitor_disable(); -#endif -#if PACKET_HAS_SLAVE - ao_packet_slave_stop(); -#endif -#if HAS_PAD - ao_pad_disable(); -#endif - ao_radio_get(0xff); - RFST = RFST_STX; - radio_test_on = 1; - } - } else { - if (radio_test_on) { - ao_radio_idle(); - ao_radio_put(); - radio_test_on = 0; -#if HAS_MONITOR - ao_monitor_enable(); -#endif -#if HAS_PAD - ao_pad_enable(); -#endif - } - } -} - -static void -ao_radio_test_cmd(void) -{ - uint8_t mode = 2; - static __xdata radio_on; - ao_cmd_white(); - if (ao_cmd_lex_c != '\n') { - ao_cmd_decimal(); - mode = (uint8_t) ao_cmd_lex_u32; - } - mode++; - if ((mode & 2)) - ao_radio_test(1); - if (mode == 3) { - printf ("Hit a character to stop..."); flush(); - getchar(); - putchar('\n'); - } - if ((mode & 1)) - ao_radio_test(0); -} - -#if AO_RADIO_REG_TEST -static void -ao_radio_set_reg(void) -{ - uint8_t offset; - ao_cmd_hex(); - offset = ao_cmd_lex_i; - if (ao_cmd_status != ao_cmd_success) - return; - ao_cmd_hex(); - printf("RF[%x] %x", offset, RF[offset]); - if (ao_cmd_status == ao_cmd_success) { - RF[offset] = ao_cmd_lex_i; - printf (" -> %x", RF[offset]); - } - ao_cmd_status = ao_cmd_success; - printf("\n"); -} -#endif - -__code struct ao_cmds ao_radio_cmds[] = { - { ao_radio_test_cmd, "C <1 start, 0 stop, none both>\0Radio carrier test" }, -#if AO_RADIO_REG_TEST - { ao_radio_set_reg, "V \0Set radio register" }, -#endif - { 0, NULL }, -}; - -void -ao_radio_init(void) -{ - uint8_t i; - for (i = 0; i < sizeof (radio_setup); i += 2) - RF[radio_setup[i]] = radio_setup[i+1]; - ao_radio_set_packet(); - ao_radio_dma_done = 1; - ao_radio_dma = ao_dma_alloc(&ao_radio_dma_done); - RFIF = 0; - RFIM = RFIM_IM_TIMEOUT|RFIM_IM_DONE; - IEN2 |= IEN2_RFIE; - ao_cmd_register(&ao_radio_cmds[0]); -} diff --git a/src/cc1111/ao_reboot.c b/src/cc1111/ao_reboot.c deleted file mode 100644 index 6e1de7a3..00000000 --- a/src/cc1111/ao_reboot.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright © 2009 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -/* Use the watchdog timer to force a complete reboot - */ -void -ao_reboot(void) -{ - WDCTL = WDCTL_EN | WDCTL_MODE_WATCHDOG | WDCTL_INT_32768; - ao_delay(AO_SEC_TO_TICKS(2)); - ao_panic(AO_PANIC_REBOOT); -} diff --git a/src/cc1111/ao_romconfig.c b/src/cc1111/ao_romconfig.c deleted file mode 100644 index abd51b23..00000000 --- a/src/cc1111/ao_romconfig.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -__code __at (0x00a0) uint16_t ao_romconfig_version = AO_ROMCONFIG_VERSION; -__code __at (0x00a2) uint16_t ao_romconfig_check = ~AO_ROMCONFIG_VERSION; -__code __at (0x00a4) uint16_t ao_serial_number = 0; -/* - * For 434.550MHz, the frequency value is: - * - * 434.550e6 / (24e6 / 2**16) = 1186611.2 - * - * This value is stored in a const variable so that - * ao-load can change it during programming for - * devices that have no eeprom for config data. - */ -__code __at (0x00a6) uint32_t ao_radio_cal = 1186611; diff --git a/src/cc1111/ao_serial.c b/src/cc1111/ao_serial.c deleted file mode 100644 index 70293b4e..00000000 --- a/src/cc1111/ao_serial.c +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Copyright © 2009 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -const __code struct ao_serial_speed ao_serial_speeds[] = { - /* [AO_SERIAL_SPEED_4800] = */ { - /* .baud = */ 163, - /* .gcr = */ (7 << UxGCR_BAUD_E_SHIFT) | UxGCR_ORDER_LSB - }, - /* [AO_SERIAL_SPEED_9600] = */ { - /* .baud = */ 163, - /* .gcr = */ (8 << UxGCR_BAUD_E_SHIFT) | UxGCR_ORDER_LSB - }, - /* [AO_SERIAL_SPEED_19200] = */ { - /* .baud = */ 163, - /* .gcr = */ (9 << UxGCR_BAUD_E_SHIFT) | UxGCR_ORDER_LSB - }, - /* [AO_SERIAL_SPEED_57600] = */ { - /* .baud = */ 59, - /* .gcr = */ (11 << UxGCR_BAUD_E_SHIFT) | UxGCR_ORDER_LSB - }, - /* [AO_SERIAL_SPEED_115200] = */ { - /* .baud = */ 59, - /* .gcr = */ (12 << UxGCR_BAUD_E_SHIFT) | UxGCR_ORDER_LSB - }, -}; - -#define AO_SERIAL_SPEED_MAX AO_SERIAL_SPEED_115200 - -#if HAS_SERIAL_1_ALT_1 -#define SERIAL_1_RTS P0_3 -#else -#define SERIAL_1_RTS P1_5 -#endif - -#if HAS_SERIAL_0_ALT_1 -#define SERIAL_0_RTS P0_5 -#else -#define SERIAL_0_RTS P1_3 -#endif - -#if HAS_SERIAL_0 - -volatile __xdata struct ao_fifo ao_serial0_rx_fifo; -volatile __xdata struct ao_fifo ao_serial0_tx_fifo; - -void -ao_serial0_rx_isr(void) __interrupt 2 -{ - if (!ao_fifo_full(ao_serial0_rx_fifo)) - ao_fifo_insert(ao_serial0_rx_fifo, U0DBUF); - ao_wakeup(&ao_serial0_rx_fifo); -#if USE_SERIAL_0_STDIN - ao_wakeup(&ao_stdin_ready); -#endif -#if HAS_SERIAL_0_HW_FLOW - if (ao_fifo_mostly(ao_serial0_rx_fifo)) - SERIAL_0_RTS = 1; -#endif -} - -static __xdata uint8_t ao_serial0_tx_started; - -static void -ao_serial0_tx_start(void) -{ - if (!ao_fifo_empty(ao_serial0_tx_fifo) && - !ao_serial0_tx_started) - { - ao_serial0_tx_started = 1; - ao_fifo_remove(ao_serial0_tx_fifo, U0DBUF); - } -} - -void -ao_serial0_tx_isr(void) __interrupt 7 -{ - UTX0IF = 0; - ao_serial0_tx_started = 0; - ao_serial0_tx_start(); - ao_wakeup(&ao_serial0_tx_fifo); -} - -char -ao_serial0_getchar(void) __critical -{ - char c; - while (ao_fifo_empty(ao_serial0_rx_fifo)) - ao_sleep(&ao_serial0_rx_fifo); - ao_fifo_remove(ao_serial0_rx_fifo, c); -#if HAS_SERIAL_0_HW_FLOW - if (ao_fifo_barely(ao_serial0_rx_fifo)) - SERIAL_0_RTS = 0; -#endif - return c; -} - -#if USE_SERIAL_0_STDIN -int -_ao_serial0_pollchar(void) -{ - uint8_t c; - if (ao_fifo_empty(ao_serial0_rx_fifo)) - return AO_READ_AGAIN; - ao_fifo_remove(ao_serial0_rx_fifo,c); -#if HAS_SERIAL_0_HW_FLOW - if (ao_fifo_barely(ao_serial0_rx_fifo)) - SERIAL_0_RTS = 0; -#endif - return c; -} -#endif - -void -ao_serial0_putchar(char c) __critical -{ - while (ao_fifo_full(ao_serial0_tx_fifo)) - ao_sleep(&ao_serial0_tx_fifo); - ao_fifo_insert(ao_serial0_tx_fifo, c); - ao_serial0_tx_start(); -} - -void -ao_serial0_drain(void) __critical -{ - while (!ao_fifo_empty(ao_serial0_tx_fifo)) - ao_sleep(&ao_serial0_tx_fifo); -} - -void -ao_serial0_set_speed(uint8_t speed) -{ - ao_serial0_drain(); - if (speed > AO_SERIAL_SPEED_MAX) - return; - U0UCR |= UxUCR_FLUSH; - U0BAUD = ao_serial_speeds[speed].baud; - U0GCR = ao_serial_speeds[speed].gcr; -} -#endif /* HAS_SERIAL_0 */ - -#if HAS_SERIAL_1 - -volatile __xdata struct ao_fifo ao_serial1_rx_fifo; -volatile __xdata struct ao_fifo ao_serial1_tx_fifo; - -void -ao_serial1_rx_isr(void) __interrupt 3 -{ - if (!ao_fifo_full(ao_serial1_rx_fifo)) - ao_fifo_insert(ao_serial1_rx_fifo, U1DBUF); - ao_wakeup(&ao_serial1_rx_fifo); -#if USE_SERIAL_1_STDIN - ao_wakeup(&ao_stdin_ready); -#endif -#if HAS_SERIAL_1_HW_FLOW - if (ao_fifo_mostly(ao_serial1_rx_fifo)) - SERIAL_1_RTS = 1; -#endif -} - -static __xdata uint8_t ao_serial1_tx_started; - -static void -ao_serial1_tx_start(void) -{ - if (!ao_fifo_empty(ao_serial1_tx_fifo) && - !ao_serial1_tx_started) - { - ao_serial1_tx_started = 1; - ao_fifo_remove(ao_serial1_tx_fifo, U1DBUF); - } -} - -void -ao_serial1_tx_isr(void) __interrupt 14 -{ - UTX1IF = 0; - ao_serial1_tx_started = 0; - ao_serial1_tx_start(); - ao_wakeup(&ao_serial1_tx_fifo); -} - -char -ao_serial1_getchar(void) __critical -{ - char c; - while (ao_fifo_empty(ao_serial1_rx_fifo)) - ao_sleep(&ao_serial1_rx_fifo); - ao_fifo_remove(ao_serial1_rx_fifo, c); -#if HAS_SERIAL_1_HW_FLOW - if (ao_fifo_barely(ao_serial1_rx_fifo)) - SERIAL_1_RTS = 0; -#endif - return c; -} - -#if USE_SERIAL_1_STDIN -int -_ao_serial1_pollchar(void) -{ - uint8_t c; - if (ao_fifo_empty(ao_serial1_rx_fifo)) - return AO_READ_AGAIN; - ao_fifo_remove(ao_serial1_rx_fifo,c); -#if HAS_SERIAL_1_HW_FLOW - if (ao_fifo_barely(ao_serial1_rx_fifo)) - SERIAL_1_RTS = 0; -#endif - return c; -} -#endif - -void -ao_serial1_putchar(char c) __critical -{ - while (ao_fifo_full(ao_serial1_tx_fifo)) - ao_sleep(&ao_serial1_tx_fifo); - ao_fifo_insert(ao_serial1_tx_fifo, c); - ao_serial1_tx_start(); -} - -void -ao_serial1_drain(void) __critical -{ - while (!ao_fifo_empty(ao_serial1_tx_fifo)) - ao_sleep(&ao_serial1_tx_fifo); -} - -void -ao_serial1_set_speed(uint8_t speed) -{ - ao_serial1_drain(); - if (speed > AO_SERIAL_SPEED_MAX) - return; - U1UCR |= UxUCR_FLUSH; - U1BAUD = ao_serial_speeds[speed].baud; - U1GCR = ao_serial_speeds[speed].gcr; -} - -#endif /* HAS_SERIAL_1 */ - -void -ao_serial_init(void) -{ -#if HAS_SERIAL_0 -#if HAS_SERIAL_0_ALT_1 - /* Set up the USART pin assignment */ - PERCFG = (PERCFG & ~PERCFG_U0CFG_ALT_MASK) | PERCFG_U0CFG_ALT_1; - - P2DIR = (P2DIR & ~P2DIR_PRIP0_MASK) | P2DIR_PRIP0_USART0_USART1; - - /* Make the USART pins be controlled by the USART */ - P0SEL |= (1 << 2) | (1 << 3); -#if HAS_SERIAL_0_HW_FLOW - SERIAL_0_RTS = 0; - P0DIR |= (1 << 5); - - P0SEL |= (1 << 4); - P0INP |= (1 << 4); -#endif -#else - /* Set up the USART pin assignment */ - PERCFG = (PERCFG & ~PERCFG_U0CFG_ALT_MASK) | PERCFG_U0CFG_ALT_2; - - P2SEL = (P2SEL & ~(P2SEL_PRI3P1_MASK | P2SEL_PRI0P1_MASK)) | - (P2SEL_PRI3P1_USART0 | P2SEL_PRI0P1_USART0); - - /* Make the USART pins be controlled by the USART */ - P1SEL |= (1 << 5) | (1 << 4); -#if HAS_SERIAL_0_HW_FLOW - SERIAL_0_RTS = 0; - P1DIR |= (1 << 3); - - P1SEL |= (1 << 2); - P1INP |= (1 << 2); -#endif -#endif - - /* UART mode with receiver enabled */ - U0CSR = (UxCSR_MODE_UART | UxCSR_RE); - - /* Pick a 9600 baud rate */ - ao_serial0_set_speed(AO_SERIAL_SPEED_9600); - - /* Reasonable serial parameters */ - U0UCR = (UxUCR_FLUSH | -#if HAS_SERIAL_0_HW_FLOW - UxUCR_FLOW_ENABLE | -#else - UxUCR_FLOW_DISABLE | -#endif - UxUCR_D9_EVEN_PARITY | - UxUCR_BIT9_8_BITS | - UxUCR_PARITY_DISABLE | - UxUCR_SPB_1_STOP_BIT | - UxUCR_STOP_HIGH | - UxUCR_START_LOW); - - IEN0 |= IEN0_URX0IE; - IEN2 |= IEN2_UTX0IE; -#if USE_SERIAL_0_STDIN && !DELAY_SERIAL_0_STDIN - ao_add_stdio(_ao_serial0_pollchar, - ao_serial0_putchar, - NULL); -#endif -#endif /* HAS_SERIAL_0 */ - -#if HAS_SERIAL_1 -#if HAS_SERIAL_1_ALT_1 - /* Set up the USART pin assignment */ - PERCFG = (PERCFG & ~PERCFG_U1CFG_ALT_MASK) | PERCFG_U1CFG_ALT_1; - - P2DIR = (P2DIR & ~P2DIR_PRIP0_MASK) | P2DIR_PRIP0_USART1_USART0; - - /* Make the USART pins be controlled by the USART */ - P0SEL |= (1 << 5) | (1 << 4); -#if HAS_SERIAL_1_HW_FLOW - /* SW RTS control (hw doesn't work) */ - SERIAL_1_RTS = 0; - P0DIR |= 1 << 3; - - /* HW CTS. Maybe this works? */ - P0SEL |= 1 << 2; - P0INP |= 1 << 2; -#endif -#else - /* Set up the USART pin assignment */ - PERCFG = (PERCFG & ~PERCFG_U1CFG_ALT_MASK) | PERCFG_U1CFG_ALT_2; - - P2SEL = (P2SEL & ~(P2SEL_PRI3P1_MASK | P2SEL_PRI2P1_MASK)) | - (P2SEL_PRI3P1_USART1 | P2SEL_PRI2P1_USART1); - - /* Make the USART pins be controlled by the USART */ - P1SEL |= (1 << 6) | (1 << 7); -#if HAS_SERIAL_1_HW_FLOW - /* SW RTS control (hw doesn't work) */ - SERIAL_1_RTS = 0; - P1DIR |= (1 << 5); - - /* HW CTS. Maybe this works? */ - P1SEL |= (1 << 4); - P1INP |= (1 << 4); -#endif -#endif - - /* UART mode with receiver enabled */ - U1CSR = (UxCSR_MODE_UART | UxCSR_RE); - - /* Pick a 4800 baud rate */ - ao_serial1_set_speed(AO_SERIAL_SPEED_4800); - - /* Reasonable serial parameters */ - U1UCR = (UxUCR_FLUSH | -#if HAS_SERIAL_1_HW_FLOW - UxUCR_FLOW_ENABLE | -#else - UxUCR_FLOW_DISABLE | -#endif - UxUCR_D9_EVEN_PARITY | - UxUCR_BIT9_8_BITS | - UxUCR_PARITY_DISABLE | - UxUCR_SPB_1_STOP_BIT | - UxUCR_STOP_HIGH | - UxUCR_START_LOW); - - IEN0 |= IEN0_URX1IE; - IEN2 |= IEN2_UTX1IE; - -#if USE_SERIAL_1_STDIN && !DELAY_SERIAL_1_STDIN - ao_add_stdio(_ao_serial1_pollchar, - ao_serial1_putchar, - NULL); -#endif -#endif /* HAS_SERIAL_1 */ -} diff --git a/src/cc1111/ao_spi.c b/src/cc1111/ao_spi.c deleted file mode 100644 index 124e09cb..00000000 --- a/src/cc1111/ao_spi.c +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -/* Default pin usage for existing Altus Metrum devices */ - -#ifndef SPI_CONST -#define SPI_CONST 0xff -#endif - -/* - * USART0 SPI config alt 1 - * - * MO P0_3 - * MI P0_2 - * CLK P0_5 - * SS P0_4 - * - * USART0 SPI config alt 2 - * - * MO P1_5 - * MI P1_4 - * CLK P1_3 - * CSS P1_2 - * - * USART1 SPI config alt 1 - * - * MO P0_4 - * MI P0_5 - * CLK P0_3 - * SS P0_2 - * - * USART1 SPI config alt 2 - * - * MO P1_6 - * MI P1_7 - * CLK P1_5 - * SS P1_4 - * - * - * Chip select is the responsibility of the caller in master mode - */ - -#if HAS_SPI_0 -#define SPI_BUF_0 &U0DBUFXADDR -#define SPI_CSR_0 U0CSR -#define SPI_BAUD_0 U0BAUD -#define SPI_GCR_0 U0GCR -#define SPI_CFG_MASK_0 PERCFG_U0CFG_ALT_MASK -#define SPI_DMA_TX_0 DMA_CFG0_TRIGGER_UTX0 -#define SPI_DMA_RX_0 DMA_CFG0_TRIGGER_URX0 - -#if SPI_0_ALT_1 -#define SPI_CFG_0 PERCFG_U0CFG_ALT_1 -#define SPI_SEL_0 P0SEL -#define SPI_BITS_0 (1 << 3) | (1 << 2) | (1 << 5) -#define SPI_CSS_BIT_0 (1 << 4) -#endif - -#if SPI_0_ALT_2 -#define SPI_CFG_0 PERCFG_U0CFG_ALT_2 -#define SPI_SEL_0 P1SEL -#define SPI_PRI_0 P2SEL_PRI3P1_USART0 -#define SPI_BITS_0 (1 << 5) | (1 << 4) | (1 << 3) -#define SPI_CSS_BIT_0 (1 << 2) -#endif - -#endif - -#if HAS_SPI_1 -#define SPI_BUF_1 &U1DBUFXADDR -#define SPI_CSR_1 U1CSR -#define SPI_BAUD_1 U1BAUD -#define SPI_GCR_1 U1GCR -#define SPI_CFG_MASK_1 PERCFG_U1CFG_ALT_MASK -#define SPI_DMA_TX_1 DMA_CFG0_TRIGGER_UTX1 -#define SPI_DMA_RX_1 DMA_CFG0_TRIGGER_URX1 - -#if SPI_1_ALT_1 -#define SPI_CFG_1 PERCFG_U1CFG_ALT_1 -#define SPI_SEL_1 P0SEL -#define SPI_BITS_1 (1 << 4) | (1 << 5) | (1 << 3) -#define SPI_CSS_BIT_1 (1 << 2) -#endif - -#if SPI_1_ALT_2 -#define SPI_CFG_1 PERCFG_U1CFG_ALT_2 -#define SPI_SEL_1 P1SEL -#define SPI_PRI_1 P2SEL_PRI3P1_USART1 -#define SPI_BITS_1 (1 << 6) | (1 << 7) | (1 << 5) -#define SPI_CSS_BIT_1 (1 << 4) -#endif - -#endif - -#if MULTI_SPI - -#define SPI_BUF(bus) ((bus) ? SPI_BUF_1 : SPI_BUF_0) -#define SPI_CSR(bus) ((bus) ? SPI_CSR_1 : SPI_CSR_0) -#define SPI_BAUD(bus) ((bus) ? SPI_BAUD_1 : SPI_BAUD_0) -#define SPI_GCR(bus) ((bus) ? SPI_GCR_1 : SPI_GCR_0) -#define SPI_CFG_MASK(bus) ((bus) ? SPI_CFG_MASK_1 : SPI_CFG_MASK_0) -#define SPI_DMA_TX(bus) ((bus) ? SPI_DMA_TX_1 : SPI_DMA_TX_0) -#define SPI_DMA_RX(bus) ((bus) ? SPI_DMA_RX_1 : SPI_DMA_RX_0) -#define SPI_CFG(bus) ((bus) ? SPI_CFG_1 : SPI_CFG_0) -#define SPI_SEL(bus) ((bus) ? SPI_SEL_1 : SPI_SEL_0) -#define SPI_BITS(bus) ((bus) ? SPI_BITS_1 : SPI_BITS_0) -#define SPI_CSS_BIT(bus) ((bus) ? SPI_CSS_BIT_1 : SPI_CSS_BIT_0) - -#else - -#if HAS_SPI_0 -#define SPI_BUF(bus) SPI_BUF_0 -#define SPI_CSR(bus) SPI_CSR_0 -#define SPI_BAUD(bus) SPI_BAUD_0 -#define SPI_GCR(bus) SPI_GCR_0 -#define SPI_CFG_MASK(bus) SPI_CFG_MASK_0 -#define SPI_DMA_TX(bus) SPI_DMA_TX_0 -#define SPI_DMA_RX(bus) SPI_DMA_RX_0 -#define SPI_CFG(bus) SPI_CFG_0 -#define SPI_SEL(bus) SPI_SEL_0 -#define SPI_BITS(bus) SPI_BITS_0 -#define SPI_CSS_BIT(bus) SPI_CSS_BIT_0 -#endif -#if HAS_SPI_1 -#define SPI_BUF(bus) SPI_BUF_1 -#define SPI_CSR(bus) SPI_CSR_1 -#define SPI_BAUD(bus) SPI_BAUD_1 -#define SPI_GCR(bus) SPI_GCR_1 -#define SPI_CFG_MASK(bus) SPI_CFG_MASK_1 -#define SPI_DMA_TX(bus) SPI_DMA_TX_1 -#define SPI_DMA_RX(bus) SPI_DMA_RX_1 -#define SPI_CFG(bus) SPI_CFG_1 -#define SPI_SEL(bus) SPI_SEL_1 -#define SPI_BITS(bus) SPI_BITS_1 -#define SPI_CSS_BIT(bus) SPI_CSS_BIT_1 -#endif - -#endif /* MULTI_SPI */ - -#if AO_SPI_SLAVE -#define CSS(bus) SPI_CSS_BIT(bus) -#define UxCSR_DIRECTION UxCSR_SLAVE -#else -#define CSS(bus) 0 -#define UxCSR_DIRECTION UxCSR_MASTER -#endif - -/* Shared mutex to protect SPI bus, must cover the entire - * operation, from CS low to CS high. This means that any SPI - * user must protect the SPI bus with this mutex - */ -__xdata uint8_t ao_spi_mutex[N_SPI]; -__xdata uint8_t ao_spi_dma_in_done[N_SPI]; -__xdata uint8_t ao_spi_dma_out_done[N_SPI]; - -uint8_t ao_spi_dma_out_id[N_SPI]; -uint8_t ao_spi_dma_in_id[N_SPI]; - -static __xdata uint8_t ao_spi_const; - - -/* Send bytes over SPI. - * - * This sets up two DMA engines, one writing the data and another reading - * bytes coming back. We use the bytes coming back to tell when the transfer - * is complete, as the transmit register is double buffered and hence signals - * completion one byte before the transfer is actually complete - */ -#if MULTI_SPI -void -ao_spi_send(void __xdata *block, uint16_t len, uint8_t bus) __reentrant -#else -void -ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant -#define bus 0 -#endif -{ - ao_dma_set_transfer(ao_spi_dma_in_id[bus], - SPI_BUF(bus), - &ao_spi_const, - len, - DMA_CFG0_WORDSIZE_8 | - DMA_CFG0_TMODE_SINGLE | - SPI_DMA_RX(bus), - DMA_CFG1_SRCINC_0 | - DMA_CFG1_DESTINC_0 | - DMA_CFG1_PRIORITY_NORMAL); - ao_dma_set_transfer(ao_spi_dma_out_id[bus], - block, - SPI_BUF(bus), - len, - DMA_CFG0_WORDSIZE_8 | - DMA_CFG0_TMODE_SINGLE | - SPI_DMA_TX(bus), - DMA_CFG1_SRCINC_1 | - DMA_CFG1_DESTINC_0 | - DMA_CFG1_PRIORITY_NORMAL); - - ao_dma_start(ao_spi_dma_in_id[bus]); - ao_dma_start(ao_spi_dma_out_id[bus]); - ao_dma_trigger(ao_spi_dma_out_id[bus]); -#if !AO_SPI_SLAVE - __critical while (!ao_spi_dma_in_done[bus]) - ao_sleep(&ao_spi_dma_in_done[bus]); -#endif -#undef bus -} - -#if AO_SPI_SLAVE -void -ao_spi_send_wait(void) -{ - __critical while (!ao_spi_dma_in_done[0]) - ao_sleep(&ao_spi_dma_in_done[0]); -} -#endif - -/* Receive bytes over SPI. - * - * This sets up tow DMA engines, one reading the data and another - * writing constant values to the SPI transmitter as that is what - * clocks the data coming in. - */ -#if MULTI_SPI -void -ao_spi_recv(void __xdata *block, uint16_t len, uint8_t bus) __reentrant -#else -void -ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant -#define bus 0 -#endif -{ - ao_dma_set_transfer(ao_spi_dma_in_id[bus], - SPI_BUF(bus), - block, - len, - DMA_CFG0_WORDSIZE_8 | - DMA_CFG0_TMODE_SINGLE | - SPI_DMA_RX(bus), - DMA_CFG1_SRCINC_0 | - DMA_CFG1_DESTINC_1 | - DMA_CFG1_PRIORITY_NORMAL); - - ao_spi_const = SPI_CONST; - -#if !AO_SPI_SLAVE - ao_dma_set_transfer(ao_spi_dma_out_id[bus], - &ao_spi_const, - SPI_BUF(bus), - len, - DMA_CFG0_WORDSIZE_8 | - DMA_CFG0_TMODE_SINGLE | - SPI_DMA_TX(bus), - DMA_CFG1_SRCINC_0 | - DMA_CFG1_DESTINC_0 | - DMA_CFG1_PRIORITY_NORMAL); -#endif - - ao_dma_start(ao_spi_dma_in_id[bus]); -#if !AO_SPI_SLAVE - ao_dma_start(ao_spi_dma_out_id[bus]); - ao_dma_trigger(ao_spi_dma_out_id[bus]); - __critical while (!ao_spi_dma_in_done[bus]) - ao_sleep(&ao_spi_dma_in_done[bus]); -#endif -} - -#if AO_SPI_SLAVE -void -ao_spi_recv_wait(void) -{ - __critical while (!ao_spi_dma_in_done[0]) - ao_sleep(&ao_spi_dma_in_done[0]); -} -#endif - -/* Set up the USART. - * - * SPI master/slave mode - */ -/* Set the baud rate and signal parameters - * - * The cc1111 is limited to a 24/8 MHz SPI clock. - * Every peripheral I've ever seen goes faster than that, - * so set the clock to 3MHz (BAUD_E 17, BAUD_M 0) - */ -#define SPI_INIT(bus,o) do { \ - /* Set up the USART pin assignment */ \ - PERCFG = (PERCFG & ~SPI_CFG_MASK(bus)) | SPI_CFG(bus); \ - \ - /* Make the SPI pins be controlled by the USART peripheral */ \ - SPI_SEL(bus) |= SPI_BITS(bus) | CSS(bus); \ - SPI_CSR(bus) = (UxCSR_MODE_SPI | UxCSR_RE | UxCSR_DIRECTION); \ - SPI_BAUD(bus) = 0; \ - SPI_GCR(bus) = (UxGCR_CPOL_NEGATIVE | \ - UxGCR_CPHA_FIRST_EDGE | \ - UxGCR_ORDER_MSB | \ - (17 << UxGCR_BAUD_E_SHIFT)); \ - /* Set up OUT DMA */ \ - ao_spi_dma_out_id[o] = ao_dma_alloc(&ao_spi_dma_out_done[o]); \ - \ - /* Set up IN DMA */ \ - ao_spi_dma_in_id[o] = ao_dma_alloc(&ao_spi_dma_in_done[o]); \ - } while (0) - -void -ao_spi_init(void) -{ - /* Ensure that SPI USART takes precidence over the other USART - * for pins that they share - */ -#ifdef SPI_PRI - P2SEL = (P2SEL & ~P2SEL_PRI3P1_MASK) | SPI_PRI; -#endif - -#if HAS_SPI_0 - SPI_INIT(0, 0); -#endif -#if HAS_SPI_1 - SPI_INIT(1, MULTI_SPI); -#endif -} diff --git a/src/cc1111/ao_string.c b/src/cc1111/ao_string.c deleted file mode 100644 index dd62ca3d..00000000 --- a/src/cc1111/ao_string.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -void -_ao_xmemcpy(__xdata void *dst, __xdata void *src, uint16_t count) -{ - while (count--) { - *(__xdata uint8_t *) dst = *(__xdata uint8_t *) src; - dst = (__xdata uint8_t *) dst + 1; - src = (__xdata uint8_t *) src + 1; - } -} - -void -_ao_xmemset(__xdata void *dst, uint8_t v, uint16_t count) -{ - while (count--) { - *(__xdata uint8_t *) dst = v; - dst = (__xdata uint8_t *) dst + 1; - } -} - -int8_t -_ao_xmemcmp(__xdata void *a, __xdata void *b, uint16_t count) -{ - while (count--) { - int8_t d = *(__xdata int8_t *) a - *(__xdata int8_t *) b; - if (d) - return d; - a = (__xdata int8_t *) a + 1; - b = (__xdata int8_t *) b + 1; - } - return 0; -} diff --git a/src/cc1111/ao_timer.c b/src/cc1111/ao_timer.c deleted file mode 100644 index a3d454da..00000000 --- a/src/cc1111/ao_timer.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright © 2009 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -volatile __data uint16_t ao_tick_count; - -uint16_t ao_time(void) __critical -{ - return ao_tick_count; -} - -#define T1_CLOCK_DIVISOR 8 /* 24e6/8 = 3e6 */ -#define T1_SAMPLE_TIME 30000 /* 3e6/30000 = 100 */ - -#if HAS_ADC -volatile __data uint8_t ao_adc_interval = 1; -volatile __data uint8_t ao_adc_count; -#endif - -void ao_timer_isr(void) __interrupt 9 -{ - ++ao_tick_count; -#if HAS_ADC - if (++ao_adc_count == ao_adc_interval) { - ao_adc_count = 0; - ao_adc_poll(); -#if (AO_DATA_ALL & ~(AO_DATA_ADC)) - ao_wakeup(DATA_TO_XDATA(&ao_adc_count)); -#endif - } -#endif -} - -#if HAS_ADC -void -ao_timer_set_adc_interval(uint8_t interval) __critical -{ - ao_adc_interval = interval; - ao_adc_count = 0; -} -#endif - -void -ao_timer_init(void) -{ - /* NOTE: This uses a timer only present on cc1111 architecture. */ - - /* disable timer 1 */ -/* T1CTL = 0; */ - - /* set the sample rate */ - T1CC0H = T1_SAMPLE_TIME >> 8; - T1CC0L = (uint8_t) T1_SAMPLE_TIME; - - T1CCTL0 = T1CCTL_MODE_COMPARE; - T1CCTL1 = 0; - T1CCTL2 = 0; - - /* clear timer value */ - T1CNTL = 0; - - /* enable overflow interrupt */ - OVFIM = 1; - /* enable timer 1 interrupt */ - T1IE = 1; - - /* enable timer 1 in module mode, dividing by 8 */ - T1CTL = T1CTL_MODE_MODULO | T1CTL_DIV_8; -} - -#ifndef NEEDS_CC1111_CLOCK_HACK -#define NEEDS_CC1111_CLOCK_HACK 1 -#endif - -#if NEEDS_CC1111_CLOCK_HACK -static void -ao_clock_delay(void) -{ - uint16_t i = 0; - - while (--i) - ao_arch_nop(); -} -#endif - -/* - * AltOS always cranks the clock to the max frequency - */ -void -ao_clock_init(void) -{ -#if NEEDS_CC1111_CLOCK_HACK - /* Power up both oscillators */ - SLEEP &= ~(SLEEP_OSC_PD); - - /* Switch to the HFRC oscillator */ - CLKCON = (CLKCON & ~CLKCON_OSC_MASK) | (CLKCON_OSC_RC); - - /* Wait for the HFRC oscillator to be stable */ - while (!(SLEEP & SLEEP_HFRC_STB)) - ; - - /* Delay for 'a while' waiting for the crystal to - * stabilize -- the XOSC_STB bit isn't reliable - * - * http://www.ti.com/lit/er/swrz022c/swrz022c.pdf - */ - - ao_clock_delay(); -#endif - - /* Switch system clock to crystal oscilator */ - CLKCON = (CLKCON & ~CLKCON_OSC_MASK) | (CLKCON_OSC_XTAL); - - /* Wait for the HFRC oscillator to be stable */ - while (!(SLEEP & SLEEP_XOSC_STB)) - ; - - /* Power down the unused HFRC oscillator */ - SLEEP |= SLEEP_OSC_PD; - - /* Crank up the timer tick and system clock speed */ - CLKCON = ((CLKCON & ~(CLKCON_TICKSPD_MASK | CLKCON_CLKSPD_MASK)) | - (CLKCON_TICKSPD_1 | CLKCON_CLKSPD_1)); - - while ((CLKCON & (CLKCON_TICKSPD_MASK|CLKCON_CLKSPD_MASK)) != - (CLKCON_TICKSPD_1 | CLKCON_CLKSPD_1)) - ; -} diff --git a/src/cc1111/ao_usb.c b/src/cc1111/ao_usb.c deleted file mode 100644 index 259f6512..00000000 --- a/src/cc1111/ao_usb.c +++ /dev/null @@ -1,489 +0,0 @@ -/* - * Copyright © 2009 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" -#include "ao_usb.h" - -struct ao_task __xdata ao_usb_task; - -static __xdata uint16_t ao_usb_in_bytes; -static __pdata uint16_t ao_usb_in_bytes_last; -static __xdata uint16_t ao_usb_out_bytes; -static __pdata uint8_t ao_usb_iif; -__pdata uint8_t ao_usb_running; - -static void -ao_usb_set_interrupts(void) -{ - /* IN interrupts on the control an IN endpoints */ - USBIIE = (1 << AO_USB_CONTROL_EP) | (1 << AO_USB_IN_EP); - - /* OUT interrupts on the OUT endpoint */ - USBOIE = (1 << AO_USB_OUT_EP); - - /* Only care about reset */ - USBCIE = USBCIE_RSTIE; -} - -/* This interrupt is shared with port 2, - * so when we hook that up, fix this - */ -void -ao_usb_isr(void) __interrupt 6 -{ - USBIF = 0; - ao_usb_iif |= USBIIF; - if (ao_usb_iif & 1) - ao_wakeup(&ao_usb_task); - if (ao_usb_iif & (1 << AO_USB_IN_EP)) - ao_wakeup(&ao_usb_in_bytes); - - if (USBOIF & (1 << AO_USB_OUT_EP)) - ao_wakeup(&ao_stdin_ready); - - if (USBCIF & USBCIF_RSTIF) - ao_usb_set_interrupts(); -#if HAS_BTM -#if BT_LINK_ON_P2 - ao_btm_isr(); -#endif -#endif -#if HAS_P2_ISR - ao_p2_isr(); -#endif -} - -struct ao_usb_setup { - uint8_t dir_type_recip; - uint8_t request; - uint16_t value; - uint16_t index; - uint16_t length; -} __xdata ao_usb_setup; - -__pdata uint8_t ao_usb_ep0_state; -uint8_t * __pdata ao_usb_ep0_in_data; -__pdata uint8_t ao_usb_ep0_in_len; -__pdata uint8_t ao_usb_ep0_in_buf[2]; -__pdata uint8_t ao_usb_ep0_out_len; -__xdata uint8_t *__pdata ao_usb_ep0_out_data; -__pdata uint8_t ao_usb_configuration; - -/* Send an IN data packet */ -static void -ao_usb_ep0_flush(void) -{ - __pdata uint8_t this_len; - __pdata uint8_t cs0; - - /* If the IN packet hasn't been picked up, just return */ - USBINDEX = 0; - cs0 = USBCS0; - if (cs0 & USBCS0_INPKT_RDY) - return; - - this_len = ao_usb_ep0_in_len; - if (this_len > AO_USB_CONTROL_SIZE) - this_len = AO_USB_CONTROL_SIZE; - cs0 = USBCS0_INPKT_RDY; - if (this_len != AO_USB_CONTROL_SIZE) { - cs0 = USBCS0_INPKT_RDY | USBCS0_DATA_END; - ao_usb_ep0_state = AO_USB_EP0_IDLE; - } - ao_usb_ep0_in_len -= this_len; - while (this_len--) - USBFIFO[0] = *ao_usb_ep0_in_data++; - USBINDEX = 0; - USBCS0 = cs0; -} - -__xdata struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8}; - -/* Walk through the list of descriptors and find a match - */ -static void -ao_usb_get_descriptor(uint16_t value) -{ - __code uint8_t *__pdata descriptor; - __pdata uint8_t type = value >> 8; - __pdata uint8_t index = value; - - descriptor = ao_usb_descriptors; - while (descriptor[0] != 0) { - if (descriptor[1] == type && index-- == 0) { - if (type == AO_USB_DESC_CONFIGURATION) - ao_usb_ep0_in_len = descriptor[2]; - else - ao_usb_ep0_in_len = descriptor[0]; - ao_usb_ep0_in_data = descriptor; - break; - } - descriptor += descriptor[0]; - } -} - -/* Read data from the ep0 OUT fifo - */ -static void -ao_usb_ep0_fill(void) -{ - __pdata uint8_t len; - - USBINDEX = 0; - len = USBCNT0; - if (len > ao_usb_ep0_out_len) - len = ao_usb_ep0_out_len; - ao_usb_ep0_out_len -= len; - while (len--) - *ao_usb_ep0_out_data++ = USBFIFO[0]; -} - -static void -ao_usb_ep0_queue_byte(uint8_t a) -{ - ao_usb_ep0_in_buf[ao_usb_ep0_in_len++] = a; -} - -static void -ao_usb_set_address(uint8_t address) -{ - ao_usb_running = 1; - USBADDR = address; -} - -static void -ao_usb_set_configuration(void) -{ - /* Set the IN max packet size, double buffered */ - USBINDEX = AO_USB_IN_EP; - USBMAXI = AO_USB_IN_SIZE >> 3; - USBCSIH |= USBCSIH_IN_DBL_BUF; - - /* Set the OUT max packet size, double buffered */ - USBINDEX = AO_USB_OUT_EP; - USBMAXO = AO_USB_OUT_SIZE >> 3; - USBCSOH = USBCSOH_OUT_DBL_BUF; -} - -static void -ao_usb_ep0_setup(void) -{ - /* Pull the setup packet out of the fifo */ - ao_usb_ep0_out_data = (__xdata uint8_t *) &ao_usb_setup; - ao_usb_ep0_out_len = 8; - ao_usb_ep0_fill(); - if (ao_usb_ep0_out_len != 0) - return; - - ao_usb_ep0_in_data = ao_usb_ep0_in_buf; - ao_usb_ep0_in_len = 0; - switch(ao_usb_setup.dir_type_recip & AO_USB_SETUP_TYPE_MASK) { - case AO_USB_TYPE_STANDARD: - switch(ao_usb_setup.dir_type_recip & AO_USB_SETUP_RECIP_MASK) { - case AO_USB_RECIP_DEVICE: - switch(ao_usb_setup.request) { - case AO_USB_REQ_GET_STATUS: - ao_usb_ep0_queue_byte(0); - ao_usb_ep0_queue_byte(0); - break; - case AO_USB_REQ_SET_ADDRESS: -#if USB_FORCE_FLIGHT_IDLE - /* Go to idle mode if USB is connected - */ - ao_flight_force_idle = 1; -#endif - ao_usb_set_address(ao_usb_setup.value); - break; - case AO_USB_REQ_GET_DESCRIPTOR: - ao_usb_get_descriptor(ao_usb_setup.value); - break; - case AO_USB_REQ_GET_CONFIGURATION: - ao_usb_ep0_queue_byte(ao_usb_configuration); - break; - case AO_USB_REQ_SET_CONFIGURATION: - ao_usb_configuration = ao_usb_setup.value; - ao_usb_set_configuration(); - break; - } - break; - case AO_USB_RECIP_INTERFACE: - #pragma disable_warning 110 - switch(ao_usb_setup.request) { - case AO_USB_REQ_GET_STATUS: - ao_usb_ep0_queue_byte(0); - ao_usb_ep0_queue_byte(0); - break; - case AO_USB_REQ_GET_INTERFACE: - ao_usb_ep0_queue_byte(0); - break; - case AO_USB_REQ_SET_INTERFACE: - break; - } - break; - case AO_USB_RECIP_ENDPOINT: - switch(ao_usb_setup.request) { - case AO_USB_REQ_GET_STATUS: - ao_usb_ep0_queue_byte(0); - ao_usb_ep0_queue_byte(0); - break; - } - break; - } - break; - case AO_USB_TYPE_CLASS: - switch (ao_usb_setup.request) { - case AO_USB_SET_LINE_CODING: - ao_usb_ep0_out_len = 7; - ao_usb_ep0_out_data = (__xdata uint8_t *) &ao_usb_line_coding; - break; - case AO_USB_GET_LINE_CODING: - ao_usb_ep0_in_len = 7; - ao_usb_ep0_in_data = (uint8_t *) &ao_usb_line_coding; - break; - case AO_USB_SET_CONTROL_LINE_STATE: - break; - } - break; - } - - /* Figure out how to ACK the setup packet and the - * next state - */ - USBINDEX = 0; - if (ao_usb_ep0_in_len) { - - /* Sending data back to the host - */ - ao_usb_ep0_state = AO_USB_EP0_DATA_IN; - USBCS0 = USBCS0_CLR_OUTPKT_RDY; - if (ao_usb_setup.length < ao_usb_ep0_in_len) - ao_usb_ep0_in_len = ao_usb_setup.length; - ao_usb_ep0_flush(); - } else if (ao_usb_ep0_out_len) { - - /* Receiving data from the host - */ - ao_usb_ep0_state = AO_USB_EP0_DATA_OUT; - USBCS0 = USBCS0_CLR_OUTPKT_RDY; - } else if (ao_usb_setup.length) { - - /* Uh-oh, the host expected to send or receive data - * and we don't know what to do. - */ - ao_usb_ep0_state = AO_USB_EP0_STALL; - USBCS0 = USBCS0_CLR_OUTPKT_RDY | USBCS0_SEND_STALL; - } else { - - /* Simple setup packet with no data - */ - ao_usb_ep0_state = AO_USB_EP0_IDLE; - USBCS0 = USBCS0_CLR_OUTPKT_RDY | USBCS0_DATA_END; - } -} - -/* End point 0 receives all of the control messages. */ -static void -ao_usb_ep0(void) -{ - __pdata uint8_t cs0; - - ao_usb_ep0_state = AO_USB_EP0_IDLE; - for (;;) { - __critical for (;;) { - if (ao_usb_iif & 1) { - ao_usb_iif &= ~1; - break; - } - ao_sleep(&ao_usb_task); - } - USBINDEX = 0; - cs0 = USBCS0; - if (cs0 & USBCS0_SETUP_END) { - USBCS0 = USBCS0_CLR_SETUP_END; - ao_usb_ep0_state = AO_USB_EP0_IDLE; - } - if (cs0 & USBCS0_SENT_STALL) { - USBCS0 = 0; - ao_usb_ep0_state = AO_USB_EP0_IDLE; - } - if (ao_usb_ep0_state == AO_USB_EP0_DATA_IN && - (cs0 & USBCS0_INPKT_RDY) == 0) - { - ao_usb_ep0_flush(); - } - if (cs0 & USBCS0_OUTPKT_RDY) { - switch (ao_usb_ep0_state) { - case AO_USB_EP0_IDLE: - ao_usb_ep0_setup(); - break; - case AO_USB_EP0_DATA_OUT: - ao_usb_ep0_fill(); - USBINDEX = 0; - if (ao_usb_ep0_out_len == 0) { - ao_usb_ep0_state = AO_USB_EP0_IDLE; - USBCS0 = USBCS0_CLR_OUTPKT_RDY | USBCS0_DATA_END; - } else - USBCS0 = USBCS0_CLR_OUTPKT_RDY; - break; - } - } - } -} - -/* Wait for a free IN buffer */ -static void -ao_usb_in_wait(void) -{ - for (;;) { - USBINDEX = AO_USB_IN_EP; - if ((USBCSIL & USBCSIL_INPKT_RDY) == 0) - break; - ao_sleep(&ao_usb_in_bytes); - } -} - -/* Send the current IN packet */ -static void -ao_usb_in_send(void) -{ - USBINDEX = AO_USB_IN_EP; - USBCSIL |= USBCSIL_INPKT_RDY; - ao_usb_in_bytes_last = ao_usb_in_bytes; - ao_usb_in_bytes = 0; -} - -void -ao_usb_flush(void) __critical -{ - if (!ao_usb_running) - return; - - /* If there are pending bytes, or if the last packet was full, - * send another IN packet - */ - if (ao_usb_in_bytes || (ao_usb_in_bytes_last == AO_USB_IN_SIZE)) { - ao_usb_in_wait(); - ao_usb_in_send(); - } -} - -void -ao_usb_putchar(char c) __critical __reentrant -{ - if (!ao_usb_running) - return; - - ao_usb_in_wait(); - - /* Queue a byte, sending the packet when full */ - USBFIFO[AO_USB_IN_EP << 1] = c; - if (++ao_usb_in_bytes == AO_USB_IN_SIZE) - ao_usb_in_send(); -} - -int -_ao_usb_pollchar(void) -{ - uint8_t c; - if (ao_usb_out_bytes == 0) { - USBINDEX = AO_USB_OUT_EP; - if ((USBCSOL & USBCSOL_OUTPKT_RDY) == 0) - return AO_READ_AGAIN; - ao_usb_out_bytes = (USBCNTH << 8) | USBCNTL; - if (ao_usb_out_bytes == 0) { - USBINDEX = AO_USB_OUT_EP; - USBCSOL &= ~USBCSOL_OUTPKT_RDY; - return AO_READ_AGAIN; - } - } - --ao_usb_out_bytes; - c = USBFIFO[AO_USB_OUT_EP << 1]; - if (ao_usb_out_bytes == 0) { - USBINDEX = AO_USB_OUT_EP; - USBCSOL &= ~USBCSOL_OUTPKT_RDY; - } - return c; -} - -char -ao_usb_getchar(void) -{ - int c; - - ao_arch_block_interrupts(); - while ((c = _ao_usb_pollchar()) == AO_READ_AGAIN) - ao_sleep(&ao_stdin_ready); - ao_arch_release_interrupts(); - return c; -} - -void -ao_usb_enable(void) -{ - /* Turn on the USB controller */ - SLEEP |= SLEEP_USB_EN; - - ao_usb_set_configuration(); - - ao_usb_set_interrupts(); - - /* enable USB interrupts */ - IEN2 |= IEN2_USBIE; - - /* Clear any pending interrupts */ - USBCIF = 0; - USBOIF = 0; - USBIIF = 0; -#if HAS_USB_PULLUP - ao_gpio_set(AO_USB_PULLUP_PORT, AO_USB_PULLUP_PIN, AO_USB_PULLUP, 0); -#endif -} - -void -ao_usb_disable(void) -{ - /* Disable USB interrupts */ - USBIIE = 0; - USBOIE = 0; - USBCIE = 0; - IEN2 &= ~IEN2_USBIE; - -#if HAS_USB_PULLUP - ao_gpio_set(AO_USB_PULLUP_PORT, AO_USB_PULLUP_PIN, AO_USB_PULLUP, 0); -#endif - - /* Clear any pending interrupts */ - USBCIF = 0; - USBOIF = 0; - USBIIF = 0; - - /* Turn off the USB controller */ - SLEEP &= ~SLEEP_USB_EN; -} - -void -ao_usb_init(void) -{ -#if HAS_USB_PULLUP - ao_enable_output(AO_USB_PULLUP_PORT, AO_USB_PULLUP_PIN, AO_USB_PULLUP, 0); -#endif - ao_usb_enable(); - - ao_add_task(&ao_usb_task, ao_usb_ep0, "usb"); - ao_add_stdio(_ao_usb_pollchar, ao_usb_putchar, ao_usb_flush); -} diff --git a/src/cc1111/cc1111.h b/src/cc1111/cc1111.h deleted file mode 100644 index 7d7c3a20..00000000 --- a/src/cc1111/cc1111.h +++ /dev/null @@ -1,1390 +0,0 @@ -/*------------------------------------------------------------------------- - Register Declarations for the ChipCon CC1111 Processor Range - - Copyright © 2008 Keith Packard - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - - Adapted from the Cygnal C8051F12x config file which is: - - Copyright (C) 2003 - Maarten Brock, sourceforge.brock@dse.nl - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --------------------------------------------------------------------------*/ - -#ifndef _CC1111_H_ -#define _CC1111_H_ -#include -#include - -__sfr __at 0xA8 IEN0; /* Interrupt Enable 0 Register */ - -__sbit __at 0xA8 RFTXRXIE; /* RF TX/RX done interrupt enable */ -__sbit __at 0xA9 ADCIE; /* ADC interrupt enable */ -__sbit __at 0xAA URX0IE; /* USART0 RX interrupt enable */ -__sbit __at 0xAB URX1IE; /* USART1 RX interrupt enable (shared with I2S RX) */ -__sbit __at 0xAB I2SRXIE; /* I2S RX interrupt enable (shared with USART1 RX) */ -__sbit __at 0xAC ENCIE; /* AES encryption/decryption interrupt enable */ -__sbit __at 0xAD STIE; /* Sleep Timer interrupt enable */ -__sbit __at 0xAF EA; /* Enable All */ - -#define IEN0_EA (1 << 7) -#define IEN0_STIE (1 << 5) -#define IEN0_ENCIE (1 << 4) -#define IEN0_URX1IE (1 << 3) -#define IEN0_I2SRXIE (1 << 3) -#define IEN0_URX0IE (1 << 2) -#define IEN0_ADCIE (1 << 1) -#define IEN0_RFTXRXIE (1 << 0) - -__sfr __at 0xB8 IEN1; /* Interrupt Enable 1 Register */ - -#define IEN1_P0IE (1 << 5) /* Port 0 interrupt enable */ -#define IEN1_T4IE (1 << 4) /* Timer 4 interrupt enable */ -#define IEN1_T3IE (1 << 3) /* Timer 3 interrupt enable */ -#define IEN1_T2IE (1 << 2) /* Timer 2 interrupt enable */ -#define IEN1_T1IE (1 << 1) /* Timer 1 interrupt enable */ -#define IEN1_DMAIE (1 << 0) /* DMA transfer interrupt enable */ - -/* IEN2 */ -__sfr __at 0x9A IEN2; /* Interrupt Enable 2 Register */ - -#define IEN2_WDTIE (1 << 5) /* Watchdog timer interrupt enable */ -#define IEN2_P1IE (1 << 4) /* Port 1 interrupt enable */ -#define IEN2_UTX1IE (1 << 3) /* USART1 TX interrupt enable */ -#define IEN2_I2STXIE (1 << 3) /* I2S TX interrupt enable */ -#define IEN2_UTX0IE (1 << 2) /* USART0 TX interrupt enable */ -#define IEN2_P2IE (1 << 1) /* Port 2 interrupt enable */ -#define IEN2_USBIE (1 << 1) /* USB interrupt enable */ -#define IEN2_RFIE (1 << 0) /* RF general interrupt enable */ - -/* CLKCON 0xC6 */ -__sfr __at 0xC6 CLKCON; /* Clock Control */ - -#define CLKCON_OSC32K_RC (1 << 7) -#define CLKCON_OSC32K_XTAL (0 << 7) -#define CLKCON_OSC32K_MASK (1 << 7) -#define CLKCON_OSC_RC (1 << 6) -#define CLKCON_OSC_XTAL (0 << 6) -#define CLKCON_OSC_MASK (1 << 6) -#define CLKCON_TICKSPD_MASK (7 << 3) -# define CLKCON_TICKSPD_1 (0 << 3) -# define CLKCON_TICKSPD_1_2 (1 << 3) -# define CLKCON_TICKSPD_1_4 (2 << 3) -# define CLKCON_TICKSPD_1_8 (3 << 3) -# define CLKCON_TICKSPD_1_16 (4 << 3) -# define CLKCON_TICKSPD_1_32 (5 << 3) -# define CLKCON_TICKSPD_1_64 (6 << 3) -# define CLKCON_TICKSPD_1_128 (7 << 3) - -#define CLKCON_CLKSPD_MASK (7 << 0) -# define CLKCON_CLKSPD_1 (0 << 0) -# define CLKCON_CLKSPD_1_2 (1 << 0) -# define CLKCON_CLKSPD_1_4 (2 << 0) -# define CLKCON_CLKSPD_1_8 (3 << 0) -# define CLKCON_CLKSPD_1_16 (4 << 0) -# define CLKCON_CLKSPD_1_32 (5 << 0) -# define CLKCON_CLKSPD_1_64 (6 << 0) -# define CLKCON_CLKSPD_1_128 (7 << 0) - -/* SLEEP 0xBE */ -#define SLEEP_USB_EN (1 << 7) -#define SLEEP_XOSC_STB (1 << 6) -#define SLEEP_HFRC_STB (1 << 5) -#define SLEEP_RST_POWER (0 << 3) -#define SLEEP_RST_EXTERNAL (1 << 3) -#define SLEEP_RST_WATCHDOG (2 << 3) -#define SLEEP_RST_MASK (3 << 3) -#define SLEEP_OSC_PD (1 << 2) -#define SLEEP_MODE_PM0 (0 << 0) -#define SLEEP_MODE_PM1 (1 << 0) -#define SLEEP_MODE_PM2 (2 << 0) -#define SLEEP_MODE_PM3 (3 << 0) -#define SLEEP_MODE_MASK (3 << 0) - -/* PCON 0x87 */ -__sfr __at 0x87 PCON; /* Power Mode Control Register */ - -#define PCON_IDLE (1 << 0) - -/* - * TCON - */ -__sfr __at 0x88 TCON; /* CPU Interrupt Flag 1 */ - -__sbit __at 0x8F URX1IF; /* USART1 RX interrupt flag. Automatically cleared */ -__sbit __at 0x8F I2SRXIF; /* I2S RX interrupt flag. Automatically cleared */ -__sbit __at 0x8D ADCIF; /* ADC interrupt flag. Automatically cleared */ -__sbit __at 0x8B URX0IF; /* USART0 RX interrupt flag. Automatically cleared */ -__sbit __at 0x89 RFTXRXIF; /* RF TX/RX complete interrupt flag. Automatically cleared */ - -#define TCON_URX1IF (1 << 7) -#define TCON_I2SRXIF (1 << 7) -#define TCON_ADCIF (1 << 5) -#define TCON_URX0IF (1 << 3) -#define TCON_RFTXRXIF (1 << 1) - -/* - * S0CON - */ -__sfr __at 0x98 S0CON; /* CPU Interrupt Flag 2 */ - -__sbit __at 0x98 ENCIF_0; /* AES interrupt 0. */ -__sbit __at 0x99 ENCIF_1; /* AES interrupt 1. */ - -#define S0CON_ENCIF_1 (1 << 1) -#define S0CON_ENCIF_0 (1 << 0) - -/* - * S1CON - */ -__sfr __at 0x9B S1CON; /* CPU Interrupt Flag 3 */ - -#define S1CON_RFIF_1 (1 << 1) -#define S1CON_RFIF_0 (1 << 0) - -/* - * IRCON - */ -__sfr __at 0xC0 IRCON; /* CPU Interrupt Flag 4 */ - -__sbit __at 0xC0 DMAIF; /* DMA complete interrupt flag */ -__sbit __at 0xC1 T1IF; /* Timer 1 interrupt flag. Automatically cleared */ -__sbit __at 0xC2 T2IF; /* Timer 2 interrupt flag. Automatically cleared */ -__sbit __at 0xC3 T3IF; /* Timer 3 interrupt flag. Automatically cleared */ -__sbit __at 0xC4 T4IF; /* Timer 4 interrupt flag. Automatically cleared */ -__sbit __at 0xC5 P0IF; /* Port0 interrupt flag */ -__sbit __at 0xC7 STIF; /* Sleep Timer interrupt flag */ - -#define IRCON_DMAIF (1 << 0) /* DMA complete interrupt flag */ -#define IRCON_T1IF (1 << 1) /* Timer 1 interrupt flag. Automatically cleared */ -#define IRCON_T2IF (1 << 2) /* Timer 2 interrupt flag. Automatically cleared */ -#define IRCON_T3IF (1 << 3) /* Timer 3 interrupt flag. Automatically cleared */ -#define IRCON_T4IF (1 << 4) /* Timer 4 interrupt flag. Automatically cleared */ -#define IRCON_P0IF (1 << 5) /* Port0 interrupt flag */ -#define IRCON_STIF (1 << 7) /* Sleep Timer interrupt flag */ - -/* - * IRCON2 - */ -__sfr __at 0xE8 IRCON2; /* CPU Interrupt Flag 5 */ - -__sbit __at 0xE8 USBIF; /* USB interrupt flag (shared with Port2) */ -__sbit __at 0xE8 P2IF; /* Port2 interrupt flag (shared with USB) */ -__sbit __at 0xE9 UTX0IF; /* USART0 TX interrupt flag */ -__sbit __at 0xEA UTX1IF; /* USART1 TX interrupt flag (shared with I2S TX) */ -__sbit __at 0xEA I2STXIF; /* I2S TX interrupt flag (shared with USART1 TX) */ -__sbit __at 0xEB P1IF; /* Port1 interrupt flag */ -__sbit __at 0xEC WDTIF; /* Watchdog timer interrupt flag */ - -#define IRCON2_USBIF (1 << 0) /* USB interrupt flag (shared with Port2) */ -#define IRCON2_P2IF (1 << 0) /* Port2 interrupt flag (shared with USB) */ -#define IRCON2_UTX0IF (1 << 1) /* USART0 TX interrupt flag */ -#define IRCON2_UTX1IF (1 << 2) /* USART1 TX interrupt flag (shared with I2S TX) */ -#define IRCON2_I2STXIF (1 << 2) /* I2S TX interrupt flag (shared with USART1 TX) */ -#define IRCON2_P1IF (1 << 3) /* Port1 interrupt flag */ -#define IRCON2_WDTIF (1 << 4) /* Watchdog timer interrupt flag */ - -/* - * IP1 - Interrupt Priority 1 - */ - -/* - * Interrupt priority groups: - * - * IPG0 RFTXRX RF DMA - * IPG1 ADC T1 P2INT/USB - * IPG2 URX0 T2 UTX0 - * IPG3 URX1/I2SRX T3 UTX1 / I2STX - * IPG4 ENC T4 P1INT - * IPG5 ST P0INT WDT - * - * Priority = (IP1 << 1) | IP0. Higher priority interrupts served first - */ - -__sfr __at 0xB9 IP1; /* Interrupt Priority 1 */ -__sfr __at 0xA9 IP0; /* Interrupt Priority 0 */ - -#define IP1_IPG5 (1 << 5) -#define IP1_IPG4 (1 << 4) -#define IP1_IPG3 (1 << 3) -#define IP1_IPG2 (1 << 2) -#define IP1_IPG1 (1 << 1) -#define IP1_IPG0 (1 << 0) - -#define IP0_IPG5 (1 << 5) -#define IP0_IPG4 (1 << 4) -#define IP0_IPG3 (1 << 3) -#define IP0_IPG2 (1 << 2) -#define IP0_IPG1 (1 << 1) -#define IP0_IPG0 (1 << 0) - -/* - * Timer 1 - */ -#define T1CTL_MODE_SUSPENDED (0 << 0) -#define T1CTL_MODE_FREE (1 << 0) -#define T1CTL_MODE_MODULO (2 << 0) -#define T1CTL_MODE_UP_DOWN (3 << 0) -#define T1CTL_MODE_MASK (3 << 0) -#define T1CTL_DIV_1 (0 << 2) -#define T1CTL_DIV_8 (1 << 2) -#define T1CTL_DIV_32 (2 << 2) -#define T1CTL_DIV_128 (3 << 2) -#define T1CTL_DIV_MASK (3 << 2) -#define T1CTL_OVFIF (1 << 4) -#define T1CTL_CH0IF (1 << 5) -#define T1CTL_CH1IF (1 << 6) -#define T1CTL_CH2IF (1 << 7) - -#define T1CCTL_NO_CAPTURE (0 << 0) -#define T1CCTL_CAPTURE_RISING (1 << 0) -#define T1CCTL_CAPTURE_FALLING (2 << 0) -#define T1CCTL_CAPTURE_BOTH (3 << 0) -#define T1CCTL_CAPTURE_MASK (3 << 0) - -#define T1CCTL_MODE_CAPTURE (0 << 2) -#define T1CCTL_MODE_COMPARE (1 << 2) - -#define T1CTL_CMP_SET (0 << 3) -#define T1CTL_CMP_CLEAR (1 << 3) -#define T1CTL_CMP_TOGGLE (2 << 3) -#define T1CTL_CMP_SET_CLEAR (3 << 3) -#define T1CTL_CMP_CLEAR_SET (4 << 3) - -#define T1CTL_IM_DISABLED (0 << 6) -#define T1CTL_IM_ENABLED (1 << 6) - -#define T1CTL_CPSEL_NORMAL (0 << 7) -#define T1CTL_CPSEL_RF (1 << 7) - -/* - * Timer 3 and Timer 4 - */ - -/* Timer count */ -__sfr __at 0xCA T3CNT; -__sfr __at 0xEA T4CNT; - -/* Timer control */ - -__sfr __at 0xCB T3CTL; -__sfr __at 0xEB T4CTL; - -#define TxCTL_DIV_1 (0 << 5) -#define TxCTL_DIV_2 (1 << 5) -#define TxCTL_DIV_4 (2 << 5) -#define TxCTL_DIV_8 (3 << 5) -#define TxCTL_DIV_16 (4 << 5) -#define TxCTL_DIV_32 (5 << 5) -#define TxCTL_DIV_64 (6 << 5) -#define TxCTL_DIV_128 (7 << 5) -#define TxCTL_START (1 << 4) -#define TxCTL_OVFIM (1 << 3) -#define TxCTL_CLR (1 << 2) -#define TxCTL_MODE_FREE (0 << 0) -#define TxCTL_MODE_DOWN (1 << 0) -#define TxCTL_MODE_MODULO (2 << 0) -#define TxCTL_MODE_UP_DOWN (3 << 0) - -/* Timer 4 channel 0 compare control */ - -__sfr __at 0xCC T3CCTL0; -__sfr __at 0xCE T3CCTL1; -__sfr __at 0xEC T4CCTL0; -__sfr __at 0xEE T4CCTL1; - -#define TxCCTLy_IM (1 << 6) -#define TxCCTLy_CMP_SET (0 << 3) -#define TxCCTLy_CMP_CLEAR (1 << 3) -#define TxCCTLy_CMP_TOGGLE (2 << 3) -#define TxCCTLy_CMP_SET_UP_CLEAR_DOWN (3 << 3) -#define TxCCTLy_CMP_CLEAR_UP_SET_DOWN (4 << 3) -#define TxCCTLy_CMP_SET_CLEAR_FF (5 << 3) -#define TxCCTLy_CMP_CLEAR_SET_00 (6 << 3) -#define TxCCTLy_CMP_MODE_ENABLE (1 << 2) - -/* Timer compare value */ -__sfr __at 0xCD T3CC0; -__sfr __at 0xCF T3CC1; -__sfr __at 0xED T4CC0; -__sfr __at 0xEF T4CC1; - -/* - * Peripheral control - */ - -__sfr __at 0xf1 PERCFG; -#define PERCFG_T1CFG_ALT_1 (0 << 6) -#define PERCFG_T1CFG_ALT_2 (1 << 6) -#define PERCFG_T1CFG_ALT_MASK (1 << 6) - -#define PERCFG_T3CFG_ALT_1 (0 << 5) -#define PERCFG_T3CFG_ALT_2 (1 << 5) -#define PERCFG_T3CFG_ALT_MASK (1 << 5) - -#define PERCFG_T4CFG_ALT_1 (0 << 4) -#define PERCFG_T4CFG_ALT_2 (1 << 4) -#define PERCFG_T4CFG_ALT_MASK (1 << 4) - -#define PERCFG_U1CFG_ALT_1 (0 << 1) -#define PERCFG_U1CFG_ALT_2 (1 << 1) -#define PERCFG_U1CFG_ALT_MASK (1 << 1) - -#define PERCFG_U0CFG_ALT_1 (0 << 0) -#define PERCFG_U0CFG_ALT_2 (1 << 0) -#define PERCFG_U0CFG_ALT_MASK (1 << 0) - -/* directly addressed USB registers */ -__xdata __at (0xde00) volatile uint8_t USBADDR; -__xdata __at (0xde01) volatile uint8_t USBPOW; -__xdata __at (0xde02) volatile uint8_t USBIIF; - -__xdata __at (0xde04) volatile uint8_t USBOIF; - -__xdata __at (0xde06) volatile uint8_t USBCIF; - -# define USBCIF_SOFIF (1 << 3) -# define USBCIF_RSTIF (1 << 2) -# define USBCIF_RESUMEIF (1 << 1) -# define USBCIF_SUSPENDIF (1 << 0) - -__xdata __at (0xde07) volatile uint8_t USBIIE; - -__xdata __at (0xde09) volatile uint8_t USBOIE; - -__xdata __at (0xde0b) volatile uint8_t USBCIE; - -# define USBCIE_SOFIE (1 << 3) -# define USBCIE_RSTIE (1 << 2) -# define USBCIE_RESUMEIE (1 << 1) -# define USBCIE_SUSPENDIE (1 << 0) - -__xdata __at (0xde0c) volatile uint8_t USBFRML; -__xdata __at (0xde0d) volatile uint8_t USBFRMH; -__xdata __at (0xde0e) volatile uint8_t USBINDEX; - -/* indexed USB registers, must set USBINDEX to 0-5 */ -__xdata __at (0xde10) volatile uint8_t USBMAXI; -__xdata __at (0xde11) volatile uint8_t USBCS0; - -# define USBCS0_CLR_SETUP_END (1 << 7) -# define USBCS0_CLR_OUTPKT_RDY (1 << 6) -# define USBCS0_SEND_STALL (1 << 5) -# define USBCS0_SETUP_END (1 << 4) -# define USBCS0_DATA_END (1 << 3) -# define USBCS0_SENT_STALL (1 << 2) -# define USBCS0_INPKT_RDY (1 << 1) -# define USBCS0_OUTPKT_RDY (1 << 0) - -__xdata __at (0xde11) volatile uint8_t USBCSIL; - -# define USBCSIL_CLR_DATA_TOG (1 << 6) -# define USBCSIL_SENT_STALL (1 << 5) -# define USBCSIL_SEND_STALL (1 << 4) -# define USBCSIL_FLUSH_PACKET (1 << 3) -# define USBCSIL_UNDERRUN (1 << 2) -# define USBCSIL_PKT_PRESENT (1 << 1) -# define USBCSIL_INPKT_RDY (1 << 0) - -__xdata __at (0xde12) volatile uint8_t USBCSIH; - -# define USBCSIH_AUTOSET (1 << 7) -# define USBCSIH_ISO (1 << 6) -# define USBCSIH_FORCE_DATA_TOG (1 << 3) -# define USBCSIH_IN_DBL_BUF (1 << 0) - -__xdata __at (0xde13) volatile uint8_t USBMAXO; -__xdata __at (0xde14) volatile uint8_t USBCSOL; - -# define USBCSOL_CLR_DATA_TOG (1 << 7) -# define USBCSOL_SENT_STALL (1 << 6) -# define USBCSOL_SEND_STALL (1 << 5) -# define USBCSOL_FLUSH_PACKET (1 << 4) -# define USBCSOL_DATA_ERROR (1 << 3) -# define USBCSOL_OVERRUN (1 << 2) -# define USBCSOL_FIFO_FULL (1 << 1) -# define USBCSOL_OUTPKT_RDY (1 << 0) - -__xdata __at (0xde15) volatile uint8_t USBCSOH; - -# define USBCSOH_AUTOCLEAR (1 << 7) -# define USBCSOH_ISO (1 << 6) -# define USBCSOH_OUT_DBL_BUF (1 << 0) - -__xdata __at (0xde16) volatile uint8_t USBCNT0; -__xdata __at (0xde16) volatile uint8_t USBCNTL; -__xdata __at (0xde17) volatile uint8_t USBCNTH; - -__xdata __at (0xde20) volatile uint8_t USBFIFO[12]; - -/* ADC Data register, low and high */ -__sfr __at 0xBA ADCL; -__sfr __at 0xBB ADCH; -__xdata __at (0xDFBA) volatile uint16_t ADCXDATA; - -/* ADC Control Register 1 */ -__sfr __at 0xB4 ADCCON1; - -# define ADCCON1_EOC (1 << 7) /* conversion complete */ -# define ADCCON1_ST (1 << 6) /* start conversion */ - -# define ADCCON1_STSEL_MASK (3 << 4) /* start select */ -# define ADCCON1_STSEL_EXTERNAL (0 << 4) /* P2_0 pin triggers */ -# define ADCCON1_STSEL_FULLSPEED (1 << 4) /* full speed, no waiting */ -# define ADCCON1_STSEL_TIMER1 (2 << 4) /* timer 1 channel 0 */ -# define ADCCON1_STSEL_START (3 << 4) /* set start bit */ - -# define ADCCON1_RCTRL_MASK (3 << 2) /* random number control */ -# define ADCCON1_RCTRL_COMPLETE (0 << 2) /* operation completed */ -# define ADCCON1_RCTRL_CLOCK_LFSR (1 << 2) /* Clock the LFSR once */ - -/* ADC Control Register 2 */ -__sfr __at 0xB5 ADCCON2; - -# define ADCCON2_SREF_MASK (3 << 6) /* reference voltage */ -# define ADCCON2_SREF_1_25V (0 << 6) /* internal 1.25V */ -# define ADCCON2_SREF_EXTERNAL (1 << 6) /* external on AIN7 cc1110 */ -# define ADCCON2_SREF_VDD (2 << 6) /* VDD on the AVDD pin */ -# define ADCCON2_SREF_EXTERNAL_DIFF (3 << 6) /* external on AIN6-7 cc1110 */ - -# define ADCCON2_SDIV_MASK (3 << 4) /* decimation rate */ -# define ADCCON2_SDIV_64 (0 << 4) /* 7 bits */ -# define ADCCON2_SDIV_128 (1 << 4) /* 9 bits */ -# define ADCCON2_SDIV_256 (2 << 4) /* 10 bits */ -# define ADCCON2_SDIV_512 (3 << 4) /* 12 bits */ - -# define ADCCON2_SCH_MASK (0xf << 0) /* Sequence channel select */ -# define ADCCON2_SCH_SHIFT 0 -# define ADCCON2_SCH_AIN0 (0 << 0) -# define ADCCON2_SCH_AIN1 (1 << 0) -# define ADCCON2_SCH_AIN2 (2 << 0) -# define ADCCON2_SCH_AIN3 (3 << 0) -# define ADCCON2_SCH_AIN4 (4 << 0) -# define ADCCON2_SCH_AIN5 (5 << 0) -# define ADCCON2_SCH_AIN6 (6 << 0) -# define ADCCON2_SCH_AIN7 (7 << 0) -# define ADCCON2_SCH_AIN0_AIN1 (8 << 0) -# define ADCCON2_SCH_AIN2_AIN3 (9 << 0) -# define ADCCON2_SCH_AIN4_AIN5 (0xa << 0) -# define ADCCON2_SCH_AIN6_AIN7 (0xb << 0) -# define ADCCON2_SCH_GND (0xc << 0) -# define ADCCON2_SCH_VREF (0xd << 0) -# define ADCCON2_SCH_TEMP (0xe << 0) -# define ADCCON2_SCH_VDD_3 (0xf << 0) - - -/* ADC Control Register 3 */ -__sfr __at 0xB6 ADCCON3; - -# define ADCCON3_EREF_MASK (3 << 6) /* extra conversion reference */ -# define ADCCON3_EREF_1_25 (0 << 6) /* internal 1.25V */ -# define ADCCON3_EREF_EXTERNAL (1 << 6) /* external AIN7 cc1110 */ -# define ADCCON3_EREF_VDD (2 << 6) /* VDD on the AVDD pin */ -# define ADCCON3_EREF_EXTERNAL_DIFF (3 << 6) /* external AIN6-7 cc1110 */ -# define ADCCON3_EDIV_MASK (3 << 4) /* extral decimation */ -# define ADCCON3_EDIV_64 (0 << 4) /* 7 bits */ -# define ADCCON3_EDIV_128 (1 << 4) /* 9 bits */ -# define ADCCON3_EDIV_256 (2 << 4) /* 10 bits */ -# define ADCCON3_EDIV_512 (3 << 4) /* 12 bits */ -# define ADCCON3_ECH_MASK (0xf << 0) /* Sequence channel select */ -# define ADCCON3_ECH_SHIFT 0 -# define ADCCON3_ECH_AIN0 (0 << 0) -# define ADCCON3_ECH_AIN1 (1 << 0) -# define ADCCON3_ECH_AIN2 (2 << 0) -# define ADCCON3_ECH_AIN3 (3 << 0) -# define ADCCON3_ECH_AIN4 (4 << 0) -# define ADCCON3_ECH_AIN5 (5 << 0) -# define ADCCON3_ECH_AIN6 (6 << 0) -# define ADCCON3_ECH_AIN7 (7 << 0) -# define ADCCON3_ECH_AIN0_AIN1 (8 << 0) -# define ADCCON3_ECH_AIN2_AIN3 (9 << 0) -# define ADCCON3_ECH_AIN4_AIN5 (0xa << 0) -# define ADCCON3_ECH_AIN6_AIN7 (0xb << 0) -# define ADCCON3_ECH_GND (0xc << 0) -# define ADCCON3_ECH_VREF (0xd << 0) -# define ADCCON3_ECH_TEMP (0xe << 0) -# define ADCCON3_ECH_VDD_3 (0xf << 0) - -/* - * ADC configuration register, this selects which - * GPIO pins are to be used as ADC inputs - */ -__sfr __at 0xF2 ADCCFG; - -/* - * Watchdog timer - */ - -__sfr __at 0xc9 WDCTL; - -#define WDCTL_CLEAR_FIRST (0xa << 4) -#define WDCTL_CLEAR_SECOND (0x5 << 4) -#define WDCTL_EN (1 << 3) -#define WDCTL_MODE_WATCHDOG (0 << 2) -#define WDCTL_MODE_TIMER (1 << 2) -#define WDCTL_MODE_MASK (1 << 2) -#define WDCTL_INT_32768 (0 << 0) -#define WDCTL_INT_8192 (1 << 0) -#define WDCTL_INT_512 (2 << 0) -#define WDCTL_INT_64 (3 << 0) - -/* - * Pin selectors, these set which pins are - * using their peripheral function - */ -__sfr __at 0xF3 P0SEL; -__sfr __at 0xF4 P1SEL; -__sfr __at 0xF5 P2SEL; - -#define P2SEL_PRI3P1_USART0 (0 << 6) -#define P2SEL_PRI3P1_USART1 (1 << 6) -#define P2SEL_PRI3P1_MASK (1 << 6) -#define P2SEL_PRI2P1_USART1 (0 << 5) -#define P2SEL_PRI2P1_TIMER3 (1 << 5) -#define P2SEL_PRI2P1_MASK (1 << 5) -#define P2SEL_PRI1P1_TIMER1 (0 << 4) -#define P2SEL_PRI1P1_TIMER4 (1 << 4) -#define P2SEL_PRI1P1_MASK (1 << 4) -#define P2SEL_PRI0P1_USART0 (0 << 3) -#define P2SEL_PRI0P1_TIMER1 (1 << 3) -#define P2SEL_PRI0P1_MASK (1 << 3) -#define P2SEL_SELP2_4_GPIO (0 << 2) -#define P2SEL_SELP2_4_PERIPHERAL (1 << 2) -#define P2SEL_SELP2_4_MASK (1 << 2) -#define P2SEL_SELP2_3_GPIO (0 << 1) -#define P2SEL_SELP2_3_PERIPHERAL (1 << 1) -#define P2SEL_SELP2_3_MASK (1 << 1) -#define P2SEL_SELP2_0_GPIO (0 << 0) -#define P2SEL_SELP2_0_PERIPHERAL (1 << 0) -#define P2SEL_SELP2_0_MASK (1 << 0) - -/* - * For pins used as GPIOs, these set which are used as outputs - */ -__sfr __at 0xFD P0DIR; -__sfr __at 0xFE P1DIR; -__sfr __at 0xFF P2DIR; - -#define P2DIR_PRIP0_USART0_USART1 (0 << 6) -#define P2DIR_PRIP0_USART1_USART0 (1 << 6) -#define P2DIR_PRIP0_TIMER1_01_USART1 (2 << 6) -#define P2DIR_PRIP0_TIMER1_2_USART0 (3 << 6) -#define P2DIR_PRIP0_MASK (3 << 6) - -__sfr __at 0x8F P0INP; - -/* Select between tri-state and pull up/down - * for pins P0_0 - P0_7. - */ -#define P0INP_MDP0_7_PULL (0 << 7) -#define P0INP_MDP0_7_TRISTATE (1 << 7) -#define P0INP_MDP0_6_PULL (0 << 6) -#define P0INP_MDP0_6_TRISTATE (1 << 6) -#define P0INP_MDP0_5_PULL (0 << 5) -#define P0INP_MDP0_5_TRISTATE (1 << 5) -#define P0INP_MDP0_4_PULL (0 << 4) -#define P0INP_MDP0_4_TRISTATE (1 << 4) -#define P0INP_MDP0_3_PULL (0 << 3) -#define P0INP_MDP0_3_TRISTATE (1 << 3) -#define P0INP_MDP0_2_PULL (0 << 2) -#define P0INP_MDP0_2_TRISTATE (1 << 2) -#define P0INP_MDP0_1_PULL (0 << 1) -#define P0INP_MDP0_1_TRISTATE (1 << 1) -#define P0INP_MDP0_0_PULL (0 << 0) -#define P0INP_MDP0_0_TRISTATE (1 << 0) - -__sfr __at 0xF6 P1INP; - -/* Select between tri-state and pull up/down - * for pins P1_2 - P1_7. Pins P1_0 and P1_1 are - * always tri-stated - */ -#define P1INP_MDP1_7_PULL (0 << 7) -#define P1INP_MDP1_7_TRISTATE (1 << 7) -#define P1INP_MDP1_6_PULL (0 << 6) -#define P1INP_MDP1_6_TRISTATE (1 << 6) -#define P1INP_MDP1_5_PULL (0 << 5) -#define P1INP_MDP1_5_TRISTATE (1 << 5) -#define P1INP_MDP1_4_PULL (0 << 4) -#define P1INP_MDP1_4_TRISTATE (1 << 4) -#define P1INP_MDP1_3_PULL (0 << 3) -#define P1INP_MDP1_3_TRISTATE (1 << 3) -#define P1INP_MDP1_2_PULL (0 << 2) -#define P1INP_MDP1_2_TRISTATE (1 << 2) - -__sfr __at 0xF7 P2INP; -/* P2INP has three extra bits which are used to choose - * between pull-up and pull-down when they are not tri-stated - */ -#define P2INP_PDUP2_PULL_UP (0 << 7) -#define P2INP_PDUP2_PULL_DOWN (1 << 7) -#define P2INP_PDUP1_PULL_UP (0 << 6) -#define P2INP_PDUP1_PULL_DOWN (1 << 6) -#define P2INP_PDUP0_PULL_UP (0 << 5) -#define P2INP_PDUP0_PULL_DOWN (1 << 5) - -/* For the P2 pins, choose between tri-state and pull up/down - * mode - */ -#define P2INP_MDP2_4_PULL (0 << 4) -#define P2INP_MDP2_4_TRISTATE (1 << 4) -#define P2INP_MDP2_3_PULL (0 << 3) -#define P2INP_MDP2_3_TRISTATE (1 << 3) -#define P2INP_MDP2_2_PULL (0 << 2) -#define P2INP_MDP2_2_TRISTATE (1 << 2) -#define P2INP_MDP2_1_PULL (0 << 1) -#define P2INP_MDP2_1_TRISTATE (1 << 1) -#define P2INP_MDP2_0_PULL (0 << 0) -#define P2INP_MDP2_0_TRISTATE (1 << 0) - -/* GPIO interrupt status flags */ -__sfr __at 0x89 P0IFG; -__sfr __at 0x8A P1IFG; -__sfr __at 0x8B P2IFG; - -#define P0IFG_USB_RESUME (1 << 7) - -__sfr __at 0x8C PICTL; -#define PICTL_P2IEN (1 << 5) -#define PICTL_P0IENH (1 << 4) -#define PICTL_P0IENL (1 << 3) -#define PICTL_P2ICON (1 << 2) -#define PICTL_P1ICON (1 << 1) -#define PICTL_P0ICON (1 << 0) - -/* GPIO pins */ -__sfr __at 0x80 P0; - -__sbit __at 0x80 P0_0; -__sbit __at 0x81 P0_1; -__sbit __at 0x82 P0_2; -__sbit __at 0x83 P0_3; -__sbit __at 0x84 P0_4; -__sbit __at 0x85 P0_5; -__sbit __at 0x86 P0_6; -__sbit __at 0x87 P0_7; - -__sfr __at 0x90 P1; - -__sbit __at 0x90 P1_0; -__sbit __at 0x91 P1_1; -__sbit __at 0x92 P1_2; -__sbit __at 0x93 P1_3; -__sbit __at 0x94 P1_4; -__sbit __at 0x95 P1_5; -__sbit __at 0x96 P1_6; -__sbit __at 0x97 P1_7; - -__sfr __at 0xa0 P2; - -__sbit __at 0xa0 P2_0; -__sbit __at 0xa1 P2_1; -__sbit __at 0xa2 P2_2; -__sbit __at 0xa3 P2_3; -__sbit __at 0xa4 P2_4; - -/* DMA controller */ -struct cc_dma_channel { - uint8_t src_high; - uint8_t src_low; - uint8_t dst_high; - uint8_t dst_low; - uint8_t len_high; - uint8_t len_low; - uint8_t cfg0; - uint8_t cfg1; -}; - -# define DMA_LEN_HIGH_VLEN_MASK (7 << 5) -# define DMA_LEN_HIGH_VLEN_LEN (0 << 5) -# define DMA_LEN_HIGH_VLEN_PLUS_1 (1 << 5) -# define DMA_LEN_HIGH_VLEN (2 << 5) -# define DMA_LEN_HIGH_VLEN_PLUS_2 (3 << 5) -# define DMA_LEN_HIGH_VLEN_PLUS_3 (4 << 5) -# define DMA_LEN_HIGH_MASK (0x1f) - -# define DMA_CFG0_WORDSIZE_8 (0 << 7) -# define DMA_CFG0_WORDSIZE_16 (1 << 7) -# define DMA_CFG0_TMODE_MASK (3 << 5) -# define DMA_CFG0_TMODE_SINGLE (0 << 5) -# define DMA_CFG0_TMODE_BLOCK (1 << 5) -# define DMA_CFG0_TMODE_REPEATED_SINGLE (2 << 5) -# define DMA_CFG0_TMODE_REPEATED_BLOCK (3 << 5) - -/* - * DMA triggers - */ -# define DMA_CFG0_TRIGGER_NONE 0 -# define DMA_CFG0_TRIGGER_PREV 1 -# define DMA_CFG0_TRIGGER_T1_CH0 2 -# define DMA_CFG0_TRIGGER_T1_CH1 3 -# define DMA_CFG0_TRIGGER_T1_CH2 4 -# define DMA_CFG0_TRIGGER_T2_OVFL 6 -# define DMA_CFG0_TRIGGER_T3_CH0 7 -# define DMA_CFG0_TRIGGER_T3_CH1 8 -# define DMA_CFG0_TRIGGER_T4_CH0 9 -# define DMA_CFG0_TRIGGER_T4_CH1 10 -# define DMA_CFG0_TRIGGER_IOC_0 12 -# define DMA_CFG0_TRIGGER_IOC_1 13 -# define DMA_CFG0_TRIGGER_URX0 14 -# define DMA_CFG0_TRIGGER_UTX0 15 -# define DMA_CFG0_TRIGGER_URX1 16 -# define DMA_CFG0_TRIGGER_UTX1 17 -# define DMA_CFG0_TRIGGER_FLASH 18 -# define DMA_CFG0_TRIGGER_RADIO 19 -# define DMA_CFG0_TRIGGER_ADC_CHALL 20 -# define DMA_CFG0_TRIGGER_ADC_CH0 21 -# define DMA_CFG0_TRIGGER_ADC_CH1 22 -# define DMA_CFG0_TRIGGER_ADC_CH2 23 -# define DMA_CFG0_TRIGGER_ADC_CH3 24 -# define DMA_CFG0_TRIGGER_ADC_CH4 25 -# define DMA_CFG0_TRIGGER_ADC_CH5 26 -# define DMA_CFG0_TRIGGER_ADC_CH6 27 -# define DMA_CFG0_TRIGGER_I2SRX 27 -# define DMA_CFG0_TRIGGER_ADC_CH7 28 -# define DMA_CFG0_TRIGGER_I2STX 28 -# define DMA_CFG0_TRIGGER_ENC_DW 29 -# define DMA_CFG0_TRIGGER_ENC_UP 30 - -# define DMA_CFG1_SRCINC_MASK (3 << 6) -# define DMA_CFG1_SRCINC_0 (0 << 6) -# define DMA_CFG1_SRCINC_1 (1 << 6) -# define DMA_CFG1_SRCINC_2 (2 << 6) -# define DMA_CFG1_SRCINC_MINUS_1 (3 << 6) - -# define DMA_CFG1_DESTINC_MASK (3 << 4) -# define DMA_CFG1_DESTINC_0 (0 << 4) -# define DMA_CFG1_DESTINC_1 (1 << 4) -# define DMA_CFG1_DESTINC_2 (2 << 4) -# define DMA_CFG1_DESTINC_MINUS_1 (3 << 4) - -# define DMA_CFG1_IRQMASK (1 << 3) -# define DMA_CFG1_M8 (1 << 2) - -# define DMA_CFG1_PRIORITY_MASK (3 << 0) -# define DMA_CFG1_PRIORITY_LOW (0 << 0) -# define DMA_CFG1_PRIORITY_NORMAL (1 << 0) -# define DMA_CFG1_PRIORITY_HIGH (2 << 0) - -/* - * DMAARM - DMA Channel Arm - */ - -__sfr __at 0xD6 DMAARM; - -# define DMAARM_ABORT (1 << 7) -# define DMAARM_DMAARM4 (1 << 4) -# define DMAARM_DMAARM3 (1 << 3) -# define DMAARM_DMAARM2 (1 << 2) -# define DMAARM_DMAARM1 (1 << 1) -# define DMAARM_DMAARM0 (1 << 0) - -/* - * DMAREQ - DMA Channel Start Request and Status - */ - -__sfr __at 0xD7 DMAREQ; - -# define DMAREQ_DMAREQ4 (1 << 4) -# define DMAREQ_DMAREQ3 (1 << 3) -# define DMAREQ_DMAREQ2 (1 << 2) -# define DMAREQ_DMAREQ1 (1 << 1) -# define DMAREQ_DMAREQ0 (1 << 0) - -/* - * DMA configuration 0 address - */ - -__sfr __at 0xD5 DMA0CFGH; -__sfr __at 0xD4 DMA0CFGL; - -/* - * DMA configuration 1-4 address - */ - -__sfr __at 0xD3 DMA1CFGH; -__sfr __at 0xD2 DMA1CFGL; - -/* - * DMAIRQ - DMA Interrupt Flag - */ - -__sfr __at 0xD1 DMAIRQ; - -# define DMAIRQ_DMAIF4 (1 << 4) -# define DMAIRQ_DMAIF3 (1 << 3) -# define DMAIRQ_DMAIF2 (1 << 2) -# define DMAIRQ_DMAIF1 (1 << 1) -# define DMAIRQ_DMAIF0 (1 << 0) - -/* - * UART registers - */ - -/* USART config/status registers */ -__sfr __at 0x86 U0CSR; -__sfr __at 0xF8 U1CSR; - -# define UxCSR_MODE_UART (1 << 7) -# define UxCSR_MODE_SPI (0 << 7) -# define UxCSR_RE (1 << 6) -# define UxCSR_SLAVE (1 << 5) -# define UxCSR_MASTER (0 << 5) -# define UxCSR_FE (1 << 4) -# define UxCSR_ERR (1 << 3) -# define UxCSR_RX_BYTE (1 << 2) -# define UxCSR_TX_BYTE (1 << 1) -# define UxCSR_ACTIVE (1 << 0) - -/* UART configuration registers */ -__sfr __at 0xc4 U0UCR; -__sfr __at 0xfb U1UCR; - -# define UxUCR_FLUSH (1 << 7) -# define UxUCR_FLOW_DISABLE (0 << 6) -# define UxUCR_FLOW_ENABLE (1 << 6) -# define UxUCR_D9_EVEN_PARITY (0 << 5) -# define UxUCR_D9_ODD_PARITY (1 << 5) -# define UxUCR_BIT9_8_BITS (0 << 4) -# define UxUCR_BIT9_9_BITS (1 << 4) -# define UxUCR_PARITY_DISABLE (0 << 3) -# define UxUCR_PARITY_ENABLE (1 << 3) -# define UxUCR_SPB_1_STOP_BIT (0 << 2) -# define UxUCR_SPB_2_STOP_BITS (1 << 2) -# define UxUCR_STOP_LOW (0 << 1) -# define UxUCR_STOP_HIGH (1 << 1) -# define UxUCR_START_LOW (0 << 0) -# define UxUCR_START_HIGH (1 << 0) - -/* USART General configuration registers (mostly SPI) */ -__sfr __at 0xc5 U0GCR; -__sfr __at 0xfc U1GCR; - -# define UxGCR_CPOL_NEGATIVE (0 << 7) -# define UxGCR_CPOL_POSITIVE (1 << 7) -# define UxGCR_CPHA_FIRST_EDGE (0 << 6) -# define UxGCR_CPHA_SECOND_EDGE (1 << 6) -# define UxGCR_ORDER_LSB (0 << 5) -# define UxGCR_ORDER_MSB (1 << 5) -# define UxGCR_BAUD_E_MASK (0x1f) -# define UxGCR_BAUD_E_SHIFT 0 - -/* USART data registers */ -__sfr __at 0xc1 U0DBUF; -__xdata __at (0xDFC1) volatile uint8_t U0DBUFXADDR; -__sfr __at 0xf9 U1DBUF; -__xdata __at (0xDFF9) volatile uint8_t U1DBUFXADDR; - -/* USART baud rate registers, M value */ -__sfr __at 0xc2 U0BAUD; -__sfr __at 0xfa U1BAUD; - -/* Flash controller */ - -__sfr __at 0xAE FCTL; -#define FCTL_BUSY (1 << 7) -#define FCTL_SWBSY (1 << 6) -#define FCTL_CONTRD_ENABLE (1 << 4) -#define FCTL_WRITE (1 << 1) -#define FCTL_ERASE (1 << 0) - -/* Flash write data. Write two bytes here */ -__sfr __at 0xAF FWDATA; -__xdata __at (0xDFAF) volatile uint8_t FWDATAXADDR; - -/* Flash write/erase address */ -__sfr __at 0xAD FADDRH; -__sfr __at 0xAC FADDRL; - -/* Flash timing */ -__sfr __at 0xAB FWT; - -/* Radio */ - -__sfr __at 0xD9 RFD; -__xdata __at (0xDFD9) volatile uint8_t RFDXADDR; - -__sfr __at 0xE9 RFIF; -#define RFIF_IM_TXUNF (1 << 7) -#define RFIF_IM_RXOVF (1 << 6) -#define RFIF_IM_TIMEOUT (1 << 5) -#define RFIF_IM_DONE (1 << 4) -#define RFIF_IM_CS (1 << 3) -#define RFIF_IM_PQT (1 << 2) -#define RFIF_IM_CCA (1 << 1) -#define RFIF_IM_SFD (1 << 0) - -__sfr __at 0x91 RFIM; -#define RFIM_IM_TXUNF (1 << 7) -#define RFIM_IM_RXOVF (1 << 6) -#define RFIM_IM_TIMEOUT (1 << 5) -#define RFIM_IM_DONE (1 << 4) -#define RFIM_IM_CS (1 << 3) -#define RFIM_IM_PQT (1 << 2) -#define RFIM_IM_CCA (1 << 1) -#define RFIM_IM_SFD (1 << 0) - -__sfr __at 0xE1 RFST; - -#define RFST_SFSTXON 0x00 -#define RFST_SCAL 0x01 -#define RFST_SRX 0x02 -#define RFST_STX 0x03 -#define RFST_SIDLE 0x04 - -__xdata __at (0xdf00) uint8_t RF[0x3c]; - -__xdata __at (0xdf2f) uint8_t RF_IOCFG2; -#define RF_IOCFG2_OFF 0x2f - -__xdata __at (0xdf30) uint8_t RF_IOCFG1; -#define RF_IOCFG1_OFF 0x30 - -__xdata __at (0xdf31) uint8_t RF_IOCFG0; -#define RF_IOCFG0_OFF 0x31 - -__xdata __at (0xdf00) uint8_t RF_SYNC1; -#define RF_SYNC1_OFF 0x00 - -__xdata __at (0xdf01) uint8_t RF_SYNC0; -#define RF_SYNC0_OFF 0x01 - -__xdata __at (0xdf02) uint8_t RF_PKTLEN; -#define RF_PKTLEN_OFF 0x02 - -__xdata __at (0xdf03) uint8_t RF_PKTCTRL1; -#define RF_PKTCTRL1_OFF 0x03 -#define PKTCTRL1_PQT_MASK (0x7 << 5) -#define PKTCTRL1_PQT_SHIFT 5 -#define PKTCTRL1_APPEND_STATUS (1 << 2) -#define PKTCTRL1_ADR_CHK_NONE (0 << 0) -#define PKTCTRL1_ADR_CHK_NO_BROADCAST (1 << 0) -#define PKTCTRL1_ADR_CHK_00_BROADCAST (2 << 0) -#define PKTCTRL1_ADR_CHK_00_FF_BROADCAST (3 << 0) - -/* If APPEND_STATUS is used, two bytes will be added to the packet data */ -#define PKT_APPEND_STATUS_0_RSSI_MASK (0xff) -#define PKT_APPEND_STATUS_0_RSSI_SHIFT 0 -#define PKT_APPEND_STATUS_1_CRC_OK (1 << 7) -#define PKT_APPEND_STATUS_1_LQI_MASK (0x7f) -#define PKT_APPEND_STATUS_1_LQI_SHIFT 0 - -__xdata __at (0xdf04) uint8_t RF_PKTCTRL0; -#define RF_PKTCTRL0_OFF 0x04 -#define RF_PKTCTRL0_WHITE_DATA (1 << 6) -#define RF_PKTCTRL0_PKT_FORMAT_NORMAL (0 << 4) -#define RF_PKTCTRL0_PKT_FORMAT_RANDOM (2 << 4) -#define RF_PKTCTRL0_CRC_EN (1 << 2) -#define RF_PKTCTRL0_LENGTH_CONFIG_FIXED (0 << 0) -#define RF_PKTCTRL0_LENGTH_CONFIG_VARIABLE (1 << 0) - -__xdata __at (0xdf05) uint8_t RF_ADDR; -#define RF_ADDR_OFF 0x05 - -__xdata __at (0xdf06) uint8_t RF_CHANNR; -#define RF_CHANNR_OFF 0x06 - -__xdata __at (0xdf07) uint8_t RF_FSCTRL1; -#define RF_FSCTRL1_OFF 0x07 - -#define RF_FSCTRL1_FREQ_IF_SHIFT (0) - -__xdata __at (0xdf08) uint8_t RF_FSCTRL0; -#define RF_FSCTRL0_OFF 0x08 - -#define RF_FSCTRL0_FREQOFF_SHIFT (0) - -__xdata __at (0xdf09) uint8_t RF_FREQ2; -#define RF_FREQ2_OFF 0x09 - -__xdata __at (0xdf0a) uint8_t RF_FREQ1; -#define RF_FREQ1_OFF 0x0a - -__xdata __at (0xdf0b) uint8_t RF_FREQ0; -#define RF_FREQ0_OFF 0x0b - -__xdata __at (0xdf0c) uint8_t RF_MDMCFG4; -#define RF_MDMCFG4_OFF 0x0c - -#define RF_MDMCFG4_CHANBW_E_SHIFT 6 -#define RF_MDMCFG4_CHANBW_M_SHIFT 4 -#define RF_MDMCFG4_DRATE_E_SHIFT 0 - -__xdata __at (0xdf0d) uint8_t RF_MDMCFG3; -#define RF_MDMCFG3_OFF 0x0d - -#define RF_MDMCFG3_DRATE_M_SHIFT 0 - -__xdata __at (0xdf0e) uint8_t RF_MDMCFG2; -#define RF_MDMCFG2_OFF 0x0e - -#define RF_MDMCFG2_DEM_DCFILT_OFF (1 << 7) -#define RF_MDMCFG2_DEM_DCFILT_ON (0 << 7) - -#define RF_MDMCFG2_MOD_FORMAT_MASK (7 << 4) -#define RF_MDMCFG2_MOD_FORMAT_2_FSK (0 << 4) -#define RF_MDMCFG2_MOD_FORMAT_GFSK (1 << 4) -#define RF_MDMCFG2_MOD_FORMAT_ASK_OOK (3 << 4) -#define RF_MDMCFG2_MOD_FORMAT_MSK (7 << 4) - -#define RF_MDMCFG2_MANCHESTER_EN (1 << 3) - -#define RF_MDMCFG2_SYNC_MODE_MASK (0x7 << 0) -#define RF_MDMCFG2_SYNC_MODE_NONE (0x0 << 0) -#define RF_MDMCFG2_SYNC_MODE_15_16 (0x1 << 0) -#define RF_MDMCFG2_SYNC_MODE_16_16 (0x2 << 0) -#define RF_MDMCFG2_SYNC_MODE_30_32 (0x3 << 0) -#define RF_MDMCFG2_SYNC_MODE_NONE_THRES (0x4 << 0) -#define RF_MDMCFG2_SYNC_MODE_15_16_THRES (0x5 << 0) -#define RF_MDMCFG2_SYNC_MODE_16_16_THRES (0x6 << 0) -#define RF_MDMCFG2_SYNC_MODE_30_32_THRES (0x7 << 0) - -__xdata __at (0xdf0f) uint8_t RF_MDMCFG1; -#define RF_MDMCFG1_OFF 0x0f - -#define RF_MDMCFG1_FEC_EN (1 << 7) -#define RF_MDMCFG1_FEC_DIS (0 << 7) - -#define RF_MDMCFG1_NUM_PREAMBLE_MASK (7 << 4) -#define RF_MDMCFG1_NUM_PREAMBLE_2 (0 << 4) -#define RF_MDMCFG1_NUM_PREAMBLE_3 (1 << 4) -#define RF_MDMCFG1_NUM_PREAMBLE_4 (2 << 4) -#define RF_MDMCFG1_NUM_PREAMBLE_6 (3 << 4) -#define RF_MDMCFG1_NUM_PREAMBLE_8 (4 << 4) -#define RF_MDMCFG1_NUM_PREAMBLE_12 (5 << 4) -#define RF_MDMCFG1_NUM_PREAMBLE_16 (6 << 4) -#define RF_MDMCFG1_NUM_PREAMBLE_24 (7 << 4) - -#define RF_MDMCFG1_CHANSPC_E_MASK (3 << 0) -#define RF_MDMCFG1_CHANSPC_E_SHIFT (0) - -__xdata __at (0xdf10) uint8_t RF_MDMCFG0; -#define RF_MDMCFG0_OFF 0x10 - -#define RF_MDMCFG0_CHANSPC_M_SHIFT (0) - -__xdata __at (0xdf11) uint8_t RF_DEVIATN; -#define RF_DEVIATN_OFF 0x11 - -#define RF_DEVIATN_DEVIATION_E_SHIFT 4 -#define RF_DEVIATN_DEVIATION_M_SHIFT 0 - -__xdata __at (0xdf12) uint8_t RF_MCSM2; -#define RF_MCSM2_OFF 0x12 -#define RF_MCSM2_RX_TIME_RSSI (1 << 4) -#define RF_MCSM2_RX_TIME_QUAL (1 << 3) -#define RF_MCSM2_RX_TIME_MASK (0x7) -#define RF_MCSM2_RX_TIME_SHIFT 0 -#define RF_MCSM2_RX_TIME_END_OF_PACKET (7) - -__xdata __at (0xdf13) uint8_t RF_MCSM1; -#define RF_MCSM1_OFF 0x13 -#define RF_MCSM1_CCA_MODE_ALWAYS (0 << 4) -#define RF_MCSM1_CCA_MODE_RSSI_BELOW (1 << 4) -#define RF_MCSM1_CCA_MODE_UNLESS_RECEIVING (2 << 4) -#define RF_MCSM1_CCA_MODE_RSSI_BELOW_UNLESS_RECEIVING (3 << 4) -#define RF_MCSM1_RXOFF_MODE_IDLE (0 << 2) -#define RF_MCSM1_RXOFF_MODE_FSTXON (1 << 2) -#define RF_MCSM1_RXOFF_MODE_TX (2 << 2) -#define RF_MCSM1_RXOFF_MODE_RX (3 << 2) -#define RF_MCSM1_TXOFF_MODE_IDLE (0 << 0) -#define RF_MCSM1_TXOFF_MODE_FSTXON (1 << 0) -#define RF_MCSM1_TXOFF_MODE_TX (2 << 0) -#define RF_MCSM1_TXOFF_MODE_RX (3 << 0) - -__xdata __at (0xdf14) uint8_t RF_MCSM0; -#define RF_MCSM0_OFF 0x14 -#define RF_MCSM0_FS_AUTOCAL_NEVER (0 << 4) -#define RF_MCSM0_FS_AUTOCAL_FROM_IDLE (1 << 4) -#define RF_MCSM0_FS_AUTOCAL_TO_IDLE (2 << 4) -#define RF_MCSM0_FS_AUTOCAL_TO_IDLE_EVERY_4 (3 << 4) -#define RF_MCSM0_MAGIC_3 (1 << 3) -#define RF_MCSM0_MAGIC_2 (1 << 2) -#define RF_MCSM0_CLOSE_IN_RX_0DB (0 << 0) -#define RF_MCSM0_CLOSE_IN_RX_6DB (1 << 0) -#define RF_MCSM0_CLOSE_IN_RX_12DB (2 << 0) -#define RF_MCSM0_CLOSE_IN_RX_18DB (3 << 0) - -__xdata __at (0xdf15) uint8_t RF_FOCCFG; -#define RF_FOCCFG_OFF 0x15 -#define RF_FOCCFG_FOC_BS_CS_GATE (1 << 5) -#define RF_FOCCFG_FOC_PRE_K_1K (0 << 3) -#define RF_FOCCFG_FOC_PRE_K_2K (1 << 3) -#define RF_FOCCFG_FOC_PRE_K_3K (2 << 3) -#define RF_FOCCFG_FOC_PRE_K_4K (3 << 3) -#define RF_FOCCFG_FOC_POST_K_PRE_K (0 << 2) -#define RF_FOCCFG_FOC_POST_K_PRE_K_OVER_2 (1 << 2) -#define RF_FOCCFG_FOC_LIMIT_0 (0 << 0) -#define RF_FOCCFG_FOC_LIMIT_BW_OVER_8 (1 << 0) -#define RF_FOCCFG_FOC_LIMIT_BW_OVER_4 (2 << 0) -#define RF_FOCCFG_FOC_LIMIT_BW_OVER_2 (3 << 0) - -__xdata __at (0xdf16) uint8_t RF_BSCFG; -#define RF_BSCFG_OFF 0x16 -#define RF_BSCFG_BS_PRE_K_1K (0 << 6) -#define RF_BSCFG_BS_PRE_K_2K (1 << 6) -#define RF_BSCFG_BS_PRE_K_3K (2 << 6) -#define RF_BSCFG_BS_PRE_K_4K (3 << 6) -#define RF_BSCFG_BS_PRE_KP_1KP (0 << 4) -#define RF_BSCFG_BS_PRE_KP_2KP (1 << 4) -#define RF_BSCFG_BS_PRE_KP_3KP (2 << 4) -#define RF_BSCFG_BS_PRE_KP_4KP (3 << 4) -#define RF_BSCFG_BS_POST_KI_PRE_KI (0 << 3) -#define RF_BSCFG_BS_POST_KI_PRE_KI_OVER_2 (1 << 3) -#define RF_BSCFG_BS_POST_KP_PRE_KP (0 << 2) -#define RF_BSCFG_BS_POST_KP_PRE_KP_OVER_2 (1 << 2) -#define RF_BSCFG_BS_LIMIT_0 (0 << 0) -#define RF_BSCFG_BS_LIMIT_3_125 (1 << 0) -#define RF_BSCFG_BS_LIMIT_6_25 (2 << 0) -#define RF_BSCFG_BS_LIMIT_12_5 (3 << 0) - -__xdata __at (0xdf17) uint8_t RF_AGCCTRL2; -#define RF_AGCCTRL2_OFF 0x17 - -#define RF_AGCCTRL2_MAX_DVGA_GAIN_ALL (0 << 6) -#define RF_AGCCTRL2_MAX_DVGA_GAIN_BUT_1 (1 << 6) -#define RF_AGCCTRL2_MAX_DVGA_GAIN_BUT_2 (2 << 6) -#define RF_AGCCTRL2_MAX_DVGA_GAIN_BUT_3 (3 << 6) -#define RF_AGCCTRL2_MAX_LNA_GAIN_0 (0 << 3) -#define RF_AGCCTRL2_MAX_LNA_GAIN_2_6 (1 << 3) -#define RF_AGCCTRL2_MAX_LNA_GAIN_6_1 (2 << 3) -#define RF_AGCCTRL2_MAX_LNA_GAIN_7_4 (3 << 3) -#define RF_AGCCTRL2_MAX_LNA_GAIN_9_2 (4 << 3) -#define RF_AGCCTRL2_MAX_LNA_GAIN_11_5 (5 << 3) -#define RF_AGCCTRL2_MAX_LNA_GAIN_14_6 (6 << 3) -#define RF_AGCCTRL2_MAX_LNA_GAIN_17_1 (7 << 3) -#define RF_AGCCTRL2_MAGN_TARGET_24dB (0 << 0) -#define RF_AGCCTRL2_MAGN_TARGET_27dB (1 << 0) -#define RF_AGCCTRL2_MAGN_TARGET_30dB (2 << 0) -#define RF_AGCCTRL2_MAGN_TARGET_33dB (3 << 0) -#define RF_AGCCTRL2_MAGN_TARGET_36dB (4 << 0) -#define RF_AGCCTRL2_MAGN_TARGET_38dB (5 << 0) -#define RF_AGCCTRL2_MAGN_TARGET_40dB (6 << 0) -#define RF_AGCCTRL2_MAGN_TARGET_42dB (7 << 0) - -__xdata __at (0xdf18) uint8_t RF_AGCCTRL1; -#define RF_AGCCTRL1_OFF 0x18 - -#define RF_AGCCTRL1_AGC_LNA_PRIORITY_0 (0 << 6) -#define RF_AGCCTRL1_AGC_LNA_PRIORITY_1 (1 << 6) -#define RF_AGCCTRL1_CARRIER_SENSE_REL_THR_DISABLE (0 << 4) -#define RF_AGCCTRL1_CARRIER_SENSE_REL_THR_6DB (1 << 4) -#define RF_AGCCTRL1_CARRIER_SENSE_REL_THR_10DB (2 << 4) -#define RF_AGCCTRL1_CARRIER_SENSE_REL_THR_14DB (3 << 4) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_DISABLE (0x8 << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_7DB_BELOW (0x9 << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_6DB_BELOW (0xa << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_5DB_BELOW (0xb << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_4DB_BELOW (0xc << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_3DB_BELOW (0xd << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_2DB_BELOW (0xe << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_1DB_BELOW (0xf << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_0DB (0x0 << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_1DB_ABOVE (0x1 << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_2DB_ABOVE (0x2 << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_3DB_ABOVE (0x3 << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_4DB_ABOVE (0x4 << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_5DB_ABOVE (0x5 << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_6DB_ABOVE (0x6 << 0) -#define RF_AGCCTRL1_CARRIER_SENSE_ABS_THR_7DB_ABOVE (0x7 << 0) - -__xdata __at (0xdf19) uint8_t RF_AGCCTRL0; -#define RF_AGCCTRL0_OFF 0x19 - -#define RF_AGCCTRL0_HYST_LEVEL_NONE (0 << 6) -#define RF_AGCCTRL0_HYST_LEVEL_LOW (1 << 6) -#define RF_AGCCTRL0_HYST_LEVEL_MEDIUM (2 << 6) -#define RF_AGCCTRL0_HYST_LEVEL_HIGH (3 << 6) -#define RF_AGCCTRL0_WAIT_TIME_8 (0 << 4) -#define RF_AGCCTRL0_WAIT_TIME_16 (1 << 4) -#define RF_AGCCTRL0_WAIT_TIME_24 (2 << 4) -#define RF_AGCCTRL0_WAIT_TIME_32 (3 << 4) -#define RF_AGCCTRL0_AGC_FREEZE_NORMAL (0 << 2) -#define RF_AGCCTRL0_AGC_FREEZE_SYNC (1 << 2) -#define RF_AGCCTRL0_AGC_FREEZE_MANUAL_ANALOG (2 << 2) -#define RF_AGCCTRL0_AGC_FREEZE_MANUAL_BOTH (3 << 2) -#define RF_AGCCTRL0_FILTER_LENGTH_8 (0 << 0) -#define RF_AGCCTRL0_FILTER_LENGTH_16 (1 << 0) -#define RF_AGCCTRL0_FILTER_LENGTH_32 (2 << 0) -#define RF_AGCCTRL0_FILTER_LENGTH_64 (3 << 0) - -__xdata __at (0xdf1a) uint8_t RF_FREND1; -#define RF_FREND1_OFF 0x1a - -#define RF_FREND1_LNA_CURRENT_SHIFT 6 -#define RF_FREND1_LNA2MIX_CURRENT_SHIFT 4 -#define RF_FREND1_LODIV_BUF_CURRENT_RX_SHIFT 2 -#define RF_FREND1_MIX_CURRENT_SHIFT 0 - -__xdata __at (0xdf1b) uint8_t RF_FREND0; -#define RF_FREND0_OFF 0x1b - -#define RF_FREND0_LODIV_BUF_CURRENT_TX_MASK (0x3 << 4) -#define RF_FREND0_LODIV_BUF_CURRENT_TX_SHIFT 4 -#define RF_FREND0_PA_POWER_MASK (0x7) -#define RF_FREND0_PA_POWER_SHIFT 0 - -__xdata __at (0xdf1c) uint8_t RF_FSCAL3; -#define RF_FSCAL3_OFF 0x1c - -__xdata __at (0xdf1d) uint8_t RF_FSCAL2; -#define RF_FSCAL2_OFF 0x1d - -__xdata __at (0xdf1e) uint8_t RF_FSCAL1; -#define RF_FSCAL1_OFF 0x1e - -__xdata __at (0xdf1f) uint8_t RF_FSCAL0; -#define RF_FSCAL0_OFF 0x1f - -__xdata __at (0xdf23) uint8_t RF_TEST2; -#define RF_TEST2_OFF 0x23 - -#define RF_TEST2_NORMAL_MAGIC 0x88 -#define RF_TEST2_RX_LOW_DATA_RATE_MAGIC 0x81 - -__xdata __at (0xdf24) uint8_t RF_TEST1; -#define RF_TEST1_OFF 0x24 - -#define RF_TEST1_TX_MAGIC 0x31 -#define RF_TEST1_RX_LOW_DATA_RATE_MAGIC 0x35 - -__xdata __at (0xdf25) uint8_t RF_TEST0; -#define RF_TEST0_OFF 0x25 - -#define RF_TEST0_7_2_MASK (0xfc) -#define RF_TEST0_VCO_SEL_CAL_EN (1 << 1) -#define RF_TEST0_0_MASK (1) - -/* These are undocumented, and must be computed - * using the provided tool. - */ -__xdata __at (0xdf27) uint8_t RF_PA_TABLE7; -#define RF_PA_TABLE7_OFF 0x27 - -__xdata __at (0xdf28) uint8_t RF_PA_TABLE6; -#define RF_PA_TABLE6_OFF 0x28 - -__xdata __at (0xdf29) uint8_t RF_PA_TABLE5; -#define RF_PA_TABLE5_OFF 0x29 - -__xdata __at (0xdf2a) uint8_t RF_PA_TABLE4; -#define RF_PA_TABLE4_OFF 0x2a - -__xdata __at (0xdf2b) uint8_t RF_PA_TABLE3; -#define RF_PA_TABLE3_OFF 0x2b - -__xdata __at (0xdf2c) uint8_t RF_PA_TABLE2; -#define RF_PA_TABLE2_OFF 0x2c - -__xdata __at (0xdf2d) uint8_t RF_PA_TABLE1; -#define RF_PA_TABLE1_OFF 0x2d - -__xdata __at (0xdf2e) uint8_t RF_PA_TABLE0; -#define RF_PA_TABLE0_OFF 0x2e - -__xdata __at (0xdf36) uint8_t RF_PARTNUM; -#define RF_PARTNUM_OFF 0x36 - -__xdata __at (0xdf37) uint8_t RF_VERSION; -#define RF_VERSION_OFF 0x37 - -__xdata __at (0xdf38) uint8_t RF_FREQEST; -#define RF_FREQEST_OFF 0x38 - -__xdata __at (0xdf39) uint8_t RF_LQI; -#define RF_LQI_OFF 0x39 - -#define RF_LQI_CRC_OK (1 << 7) -#define RF_LQI_LQI_EST_MASK (0x7f) - -__xdata __at (0xdf3a) uint8_t RF_RSSI; -#define RF_RSSI_OFF 0x3a - -__xdata __at (0xdf3b) uint8_t RF_MARCSTATE; -#define RF_MARCSTATE_OFF 0x3b - -#define RF_MARCSTATE_MASK 0x1f -#define RF_MARCSTATE_SLEEP 0x00 -#define RF_MARCSTATE_IDLE 0x01 -#define RF_MARCSTATE_VCOON_MC 0x03 -#define RF_MARCSTATE_REGON_MC 0x04 -#define RF_MARCSTATE_MANCAL 0x05 -#define RF_MARCSTATE_VCOON 0x06 -#define RF_MARCSTATE_REGON 0x07 -#define RF_MARCSTATE_STARTCAL 0x08 -#define RF_MARCSTATE_BWBOOST 0x09 -#define RF_MARCSTATE_FS_LOCK 0x0a -#define RF_MARCSTATE_IFADCON 0x0b -#define RF_MARCSTATE_ENDCAL 0x0c -#define RF_MARCSTATE_RX 0x0d -#define RF_MARCSTATE_RX_END 0x0e -#define RF_MARCSTATE_RX_RST 0x0f -#define RF_MARCSTATE_TXRX_SWITCH 0x10 -#define RF_MARCSTATE_RX_OVERFLOW 0x11 -#define RF_MARCSTATE_FSTXON 0x12 -#define RF_MARCSTATE_TX 0x13 -#define RF_MARCSTATE_TX_END 0x14 -#define RF_MARCSTATE_RXTX_SWITCH 0x15 -#define RF_MARCSTATE_TX_UNDERFLOW 0x16 - - -__xdata __at (0xdf3c) uint8_t RF_PKTSTATUS; -#define RF_PKTSTATUS_OFF 0x3c - -#define RF_PKTSTATUS_CRC_OK (1 << 7) -#define RF_PKTSTATUS_CS (1 << 6) -#define RF_PKTSTATUS_PQT_REACHED (1 << 5) -#define RF_PKTSTATUS_CCA (1 << 4) -#define RF_PKTSTATUS_SFD (1 << 3) - -__xdata __at (0xdf3d) uint8_t RF_VCO_VC_DAC; -#define RF_VCO_VC_DAC_OFF 0x3d - -/* AES engine */ - -__sfr __at 0xB1 ENCDI; -__sfr __at 0xB2 ENCDO; -__xdata __at (0xDFB1) volatile uint8_t ENCDIXADDR; -__xdata __at (0xDFB2) volatile uint8_t ENCDOXADDR; - -__sfr __at 0xB3 ENCCCS; - -#define ENCCCS_MODE_CBC (0 << 4) -#define ENCCCS_MODE_CFB (1 << 4) -#define ENCCCS_MODE_OFB (2 << 4) -#define ENCCCS_MODE_CTR (3 << 4) -#define ENCCCS_MODE_ECB (4 << 4) -#define ENCCCS_MODE_CBC_MAC (5 << 4) -#define ENCCCS_RDY (1 << 3) -#define ENCCCS_CMD_ENCRYPT (0 << 1) -#define ENCCCS_CMD_DECRYPT (1 << 1) -#define ENCCCS_CMD_LOAD_KEY (2 << 1) -#define ENCCCS_CMD_LOAD_IV (3 << 1) -#define ENCCCS_START (1 << 0) - -#endif diff --git a/src/product/Makefile.teledongle b/src/product/Makefile.teledongle deleted file mode 100644 index b7c28987..00000000 --- a/src/product/Makefile.teledongle +++ /dev/null @@ -1,98 +0,0 @@ -# -# TeleDongle build file -# -# The various teledongle versions differ only -# in minor pin variations -# so the per-board makefiles simply define -# TD_VER, TD_DEF and include -# this file - -vpath %.c ..:../kernel:../cc1111:../drivers:../product -vpath %.h ..:../kernel:../cc1111:../drivers:../product -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - ao_arch.h \ - ao_arch_funcs.h \ - cc1111.h \ - ao_product.h - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_gps_print.c \ - ao_monitor.c \ - ao_mutex.c \ - ao_panic.c \ - ao_rssi.c \ - ao_state.c \ - ao_stdio.c \ - ao_task.c \ - ao_freq.c - -CC1111_SRC = \ - ao_dbg.c \ - ao_dma.c \ - ao_led.c \ - ao_packet.c \ - ao_packet_master.c \ - ao_radio.c \ - ao_send_packet.c \ - ao_romconfig.c \ - ao_string.c \ - ao_timer.c \ - ao_usb.c \ - _bp.c - -DRIVER_SRC = - -PRODUCT_SRC = \ - ao_teledongle.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) - -PROGNAME = teledongle-v$(TD_VER) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TeleDongle-v$(TD_VER) -PRODUCT_DEF=-DTELEDONGLE_V_$(TD_DEF) -IDPRODUCT=0x000c - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: diff --git a/src/product/Makefile.telelaunch b/src/product/Makefile.telelaunch deleted file mode 100644 index 7311c21e..00000000 --- a/src/product/Makefile.telelaunch +++ /dev/null @@ -1,100 +0,0 @@ -# -# TeleLaunch build file -# -# define TELELAUNCH_VER, TELELAUNCH_DEF -# this file - -vpath %.c ..:../kernel:../cc1111:../drivers:../product -vpath %.h ..:../kernel:../cc1111:../drivers:../product -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - ao_arch.h \ - ao_arch_funcs.h \ - cc1111.h \ - ao_product.h - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_convert.c \ - ao_launch.c \ - ao_mutex.c \ - ao_panic.c \ - ao_stdio.c \ - ao_storage.c \ - ao_task.c \ - ao_freq.c - -CC1111_SRC = \ - ao_adc.c \ - ao_aes.c \ - ao_beep.c \ - ao_dbg.c \ - ao_dma.c \ - ao_ignite.c \ - ao_intflash.c \ - ao_led.c \ - ao_radio.c \ - ao_radio_cmac.c \ - ao_romconfig.c \ - ao_serial.c \ - ao_spi.c \ - ao_string.c \ - ao_timer.c \ - ao_usb.c \ - _bp.c - -DRIVER_SRC = - -PRODUCT_SRC = \ - ao_telelaunch.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) - -PROGNAME = telelaunch-v$(TELELAUNCH_VER) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TeleLaunch-v$(TELELAUNCH_VER) -PRODUCT_DEF=-DTELELAUNCH_V_$(TELELAUNCH_DEF) -IDPRODUCT=0x000f -CODESIZE=0x6700 - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: diff --git a/src/product/Makefile.telemetrum b/src/product/Makefile.telemetrum deleted file mode 100644 index e9b144c0..00000000 --- a/src/product/Makefile.telemetrum +++ /dev/null @@ -1,113 +0,0 @@ -# -# TeleMetrum build file -# -# The various telemetrum versions differ only -# in which flash and GPS drivers are included, -# so the per-board makefiles simply define -# TM_VER, TM_DEF, TM_INC and TM_SRC and include -# this file - -vpath %.c .:..:../kernel:../cc1111:../drivers:../product -vpath %.h .:..:../kernel:../cc1111:../drivers:../product -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - ao_arch.h \ - ao_arch_funcs.h \ - cc1111.h \ - altitude.h \ - ao_kalman.h \ - ao_product.h \ - ao_telemetry.h \ - $(TM_INC) - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_convert.c \ - ao_gps_report.c \ - ao_mutex.c \ - ao_panic.c \ - ao_stdio.c \ - ao_storage.c \ - ao_task.c \ - ao_flight.c \ - ao_sample.c \ - ao_kalman.c \ - ao_log.c \ - ao_log_big.c \ - ao_report.c \ - ao_telemetry.c \ - ao_freq.c - -CC1111_SRC = \ - ao_adc.c \ - ao_beep.c \ - ao_dbg.c \ - ao_dma.c \ - ao_ignite.c \ - ao_led.c \ - ao_packet.c \ - ao_packet_slave.c \ - ao_radio.c \ - ao_romconfig.c \ - ao_serial.c \ - ao_string.c \ - ao_spi.c \ - ao_timer.c \ - ao_usb.c \ - _bp.c - -DRIVER_SRC = \ - $(TM_SRC) - -PRODUCT_SRC = \ - ao_telemetrum.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) - -PROGNAME = telemetrum-v$(TM_VER)$(TM_EXTRA) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TeleMetrum-v$(TM_VER) -PRODUCT_DEF=-DTELEMETRUM_V_$(TM_DEF) -IDPRODUCT=0x000b - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: diff --git a/src/product/Makefile.telemini b/src/product/Makefile.telemini deleted file mode 100644 index ff8b9d56..00000000 --- a/src/product/Makefile.telemini +++ /dev/null @@ -1,101 +0,0 @@ -# -# TeleMini build file -# -# Define TELEMINI_VER and TELEMINI_DEF and then -# include this file - -vpath %.c ..:../kernel:../cc1111:../drivers:../product -vpath %.h ..:../kernel:../cc1111:../drivers:../product -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - ao_arch.h \ - ao_arch_funcs.h \ - cc1111.h \ - ao_product.h - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_convert.c \ - ao_flight.c \ - ao_kalman.c \ - ao_log.c \ - ao_log_tiny.c \ - ao_mutex.c \ - ao_panic.c \ - ao_report.c \ - ao_sample.c \ - ao_stdio.c \ - ao_storage.c \ - ao_task.c \ - ao_telemetry.c \ - ao_freq.c - -CC1111_SRC = \ - ao_adc.c \ - ao_dma.c \ - ao_ignite.c \ - ao_intflash.c \ - ao_led.c \ - ao_packet.c \ - ao_packet_slave.c \ - ao_radio.c \ - ao_romconfig.c \ - ao_string.c \ - ao_timer.c \ - _bp.c - -DRIVER_SRC = - -PRODUCT_SRC = \ - ao_telemini.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) - -PROGNAME = telemini-v$(TELEMINI_VER) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TeleMini-v$(TELEMINI_VER) -PRODUCT_DEF=-DTELEMINI_V_$(TELEMINI_DEF) -IDPRODUCT=0x000a -CODESIZE=0x6700 - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: diff --git a/src/product/Makefile.telenano b/src/product/Makefile.telenano deleted file mode 100644 index e1e350a6..00000000 --- a/src/product/Makefile.telenano +++ /dev/null @@ -1,100 +0,0 @@ -# -# TeleNano build file -# -# Define TELENANO_VER and TELENANO_DEF and then -# include this file - -vpath %.c ..:../kernel:../cc1111:../drivers:../product -vpath %.h ..:../kernel:../cc1111:../drivers:../product -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - ao_arch.h \ - ao_arch_funcs.h \ - cc1111.h \ - ao_product.h - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_convert.c \ - ao_flight_nano.c \ - ao_kalman.c \ - ao_log.c \ - ao_log_tiny.c \ - ao_mutex.c \ - ao_panic.c \ - ao_report.c \ - ao_sample.c \ - ao_stdio.c \ - ao_storage.c \ - ao_task.c \ - ao_telemetry.c \ - ao_freq.c - -CC1111_SRC = \ - ao_adc.c \ - ao_dma.c \ - ao_intflash.c \ - ao_led.c \ - ao_packet.c \ - ao_packet_slave.c \ - ao_radio.c \ - ao_romconfig.c \ - ao_string.c \ - ao_timer.c \ - _bp.c - -DRIVER_SRC = - -PRODUCT_SRC = \ - ao_telenano.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) - -PROGNAME = telenano-v$(TELENANO_VER) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TeleNano-v$(TELENANO_VER) -PRODUCT_DEF=-DTELENANO_V_$(TELENANO_DEF) -IDPRODUCT=0x000a -CODESIZE=0x6700 - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: diff --git a/src/spiradio-v0.1/.gitignore b/src/spiradio-v0.1/.gitignore deleted file mode 100644 index 8e39138e..00000000 --- a/src/spiradio-v0.1/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -spiradio-* -ao_product.h diff --git a/src/spiradio-v0.1/.sdcdbrc b/src/spiradio-v0.1/.sdcdbrc deleted file mode 100644 index 2c77e32b..00000000 --- a/src/spiradio-v0.1/.sdcdbrc +++ /dev/null @@ -1,2 +0,0 @@ ---directory=../cc1111:../product:../kernel:../drivers:. - diff --git a/src/spiradio-v0.1/Makefile b/src/spiradio-v0.1/Makefile deleted file mode 100644 index cd7a9cde..00000000 --- a/src/spiradio-v0.1/Makefile +++ /dev/null @@ -1,92 +0,0 @@ -# -# SpiRadio build file -# - -SPIRADIO_VER=0.1 -SPIRADIO_DEF=0_1 - -vpath %.c ..:../kernel:../cc1111:../drivers:../product -vpath %.h ..:../kernel:../cc1111:../drivers:../product -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - ao_arch.h \ - ao_arch_funcs.h \ - cc1111.h \ - ao_product.h \ - ao_radio_spi.h - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_mutex.c \ - ao_panic.c \ - ao_stdio.c \ - ao_task.c \ - ao_freq.c - -CC1111_SRC = \ - ao_aes.c \ - ao_dma.c \ - ao_led.c \ - ao_radio.c \ - ao_radio_cmac.c \ - ao_radio_slave.c \ - ao_romconfig.c \ - ao_serial.c \ - ao_spi.c \ - ao_string.c \ - ao_timer.c \ - _bp.c - -PRODUCT_SRC = \ - ao_spiradio.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(PRODUCT_SRC) - -PROGNAME = spiradio-v$(SPIRADIO_VER) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=SpiRadio-v$(SPIRADIO_VER) -PRODUCT_DEF=-DSPIRADIO_V_$(SPIRADIO_DEF) -IDPRODUCT=0x000f -CODESIZE=0x6700 - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: - diff --git a/src/spiradio-v0.1/ao_pins.h b/src/spiradio-v0.1/ao_pins.h deleted file mode 100644 index 472da16f..00000000 --- a/src/spiradio-v0.1/ao_pins.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_PINS_H_ -#define _AO_PINS_H_ - -#define HAS_RADIO 1 - -#define HAS_FLIGHT 0 -#define HAS_USB 0 -#define HAS_BEEP 0 -#define HAS_GPS 0 -#define HAS_SERIAL_0 0 -#define HAS_SERIAL_0_ALT_1 0 -#define HAS_SERIAL_0_HW_FLOW 0 -#define USE_SERIAL_0_STDIN 0 -#define HAS_SERIAL_1 1 -#define HAS_SERIAL_1_ALT_1 1 -#define HAS_SERIAL_1_HW_FLOW 0 -#define USE_SERIAL_1_STDIN 1 -#define DELAY_SERIAL_1_STDIN 0 -#define HAS_ADC 0 -#define HAS_DBG 0 -#define HAS_EEPROM 0 -#define HAS_LOG 0 -#define USE_INTERNAL_FLASH 0 -#define DBG_ON_P1 0 -#define PACKET_HAS_MASTER 0 -#define PACKET_HAS_SLAVE 0 -#define AO_LED_TX 1 -#define AO_LED_RX 2 -#define AO_LED_RED AO_LED_TX -#define LEDS_AVAILABLE (AO_LED_TX|AO_LED_RX) -#define HAS_EXTERNAL_TEMP 0 -#define HAS_ACCEL_REF 0 -#define SPI_CS_ON_P1 1 -#define HAS_AES 1 - -#define SPI_CS_PORT P1 -#define SPI_CS_SEL P1SEL -#define SPI_CS_DIR P1DIR -#define AO_SPI_SLAVE 1 -#define HAS_SPI_0 1 -#define SPI_0_ALT_2 1 -#define HAS_SPI_1 0 - -#define AO_RADIO_SLAVE_INT_PORT P1 -#define AO_RADIO_SLAVE_INT_BIT 6 -#define AO_RADIO_SLAVE_INT_PIN P1_6 - -#endif /* _AO_PINS_H_ */ diff --git a/src/spiradio-v0.1/ao_spiradio.c b/src/spiradio-v0.1/ao_spiradio.c deleted file mode 100644 index 07d33aa4..00000000 --- a/src/spiradio-v0.1/ao_spiradio.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include -#include - -void -main(void) -{ - ao_clock_init(); - - ao_led_init(LEDS_AVAILABLE); - - ao_task_init(); - - ao_serial_init(); - ao_timer_init(); - ao_cmd_init(); - ao_spi_init(); - ao_radio_init(); - ao_aes_init(); - ao_config_init(); - ao_radio_slave_init(); - ao_start_scheduler(); -} diff --git a/src/teleballoon-v1.1/.gitignore b/src/teleballoon-v1.1/.gitignore deleted file mode 100644 index 21b236c0..00000000 --- a/src/teleballoon-v1.1/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -teleballoon-* -ao_product.h diff --git a/src/teleballoon-v1.1/Makefile b/src/teleballoon-v1.1/Makefile deleted file mode 100644 index c6f6345a..00000000 --- a/src/teleballoon-v1.1/Makefile +++ /dev/null @@ -1,119 +0,0 @@ -# -# TeleBalloon build file -# -# The various telemetrum versions differ only -# in which flash and GPS drivers are included, -# so the per-board makefiles simply define -# TM_VER, TM_DEF, TM_INC and TM_SRC and include -# this file - -TELEBALLOON_VER=1.1 -TELEBALLOON_DEF=1_1 - -TELEBALLOON_INC = - -TELEBALLOON_SRC = \ - ao_companion.c \ - ao_gps_skytraq.c \ - ao_m25.c - -vpath %.c ..:../kernel:../cc1111:../drivers:../product:. -vpath %.h ..:../kernel:../cc1111:../drivers:../product:. -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - cc1111.h \ - altitude.h \ - ao_kalman.h \ - ao_product.h \ - $(TELEBALLOON_INC) - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_convert.c \ - ao_gps_report.c \ - ao_mutex.c \ - ao_panic.c \ - ao_stdio.c \ - ao_storage.c \ - ao_task.c \ - ao_balloon.c \ - ao_sample.c \ - ao_kalman.c \ - ao_log.c \ - ao_log_big.c \ - ao_report.c \ - ao_telemetry.c - -CC1111_SRC = \ - ao_adc.c \ - ao_beep.c \ - ao_dbg.c \ - ao_dma.c \ - ao_led.c \ - ao_packet.c \ - ao_packet_slave.c \ - ao_radio.c \ - ao_romconfig.c \ - ao_serial.c \ - ao_string.c \ - ao_spi.c \ - ao_timer.c \ - ao_usb.c \ - _bp.c - -DRIVER_SRC = \ - $(TELEBALLOON_SRC) - -PRODUCT_SRC = \ - ao_teleballoon.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) - -PROGNAME = teleballoon-v$(TELEBALLOON_VER) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TeleBalloon-v$(TELEBALLOON_VER) -PRODUCT_DEF=-DTELEBALLOON_V_$(TELEBALLOON_DEF) -IDPRODUCT=0x000b - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: - diff --git a/src/teleballoon-v1.1/ao_pins.h b/src/teleballoon-v1.1/ao_pins.h deleted file mode 100644 index 2bf4d593..00000000 --- a/src/teleballoon-v1.1/ao_pins.h +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_PINS_H_ -#define _AO_PINS_H_ - -#if defined(TELEBALLOON_V_1_1) - - #define AO_SENSOR_INTERVAL_ASCENT AO_MS_TO_TICKS(1000) - #define AO_SENSOR_INTERVAL_DESCENT AO_MS_TO_TICKS(1000) - #define AO_OTHER_INTERVAL AO_MS_TO_TICKS(1000) - #define AO_TELEMETRY_INTERVAL_BALLOON AO_MS_TO_TICKS(1000) - - #define HAS_FLIGHT 1 - #define HAS_USB 1 - #define HAS_BEEP 1 - #define HAS_BATTERY_REPORT 1 - #define HAS_GPS 1 - #define HAS_SERIAL_1 1 - #define HAS_ADC 1 - #define HAS_EEPROM 1 - #define HAS_LOG 1 - #define USE_INTERNAL_FLASH 0 - #define HAS_DBG 1 - #define DBG_ON_P1 1 - #define DBG_ON_P0 0 - #define IGNITE_ON_P2 1 - #define IGNITE_ON_P0 0 - #define PACKET_HAS_MASTER 0 - #define PACKET_HAS_SLAVE 1 - - #define HAS_COMPANION 1 - #define AO_COMPANION_CS_PORT P1 - #define AO_COMPANION_CS_PIN 2 - #define AO_COMPANION_CS P1_2 - - #define AO_LED_RED 1 - #define LEDS_AVAILABLE (AO_LED_RED) - #define HAS_EXTERNAL_TEMP 0 - #define HAS_ACCEL_REF 1 - #define SPI_CS_ON_P1 1 - #define SPI_CS_ON_P0 0 - #define AO_M25_SPI_CS_MASK 0x02 /* CS0 is P1_1 */ - #define M25_MAX_CHIPS 1 - #define HAS_ACCEL 1 - #define HAS_IGNITE 0 - #define HAS_MONITOR 0 -#endif - -#if DBG_ON_P1 - - #define DBG_CLOCK (1 << 4) /* mi0 */ - #define DBG_DATA (1 << 5) /* mo0 */ - #define DBG_RESET_N (1 << 3) /* c0 */ - - #define DBG_CLOCK_PIN (P1_4) - #define DBG_DATA_PIN (P1_5) - #define DBG_RESET_N_PIN (P1_3) - - #define DBG_PORT_NUM 1 - #define DBG_PORT P1 - #define DBG_PORT_SEL P1SEL - #define DBG_PORT_INP P1INP - #define DBG_PORT_DIR P1DIR - -#endif /* DBG_ON_P1 */ - -#if DBG_ON_P0 - - #define DBG_CLOCK (1 << 3) - #define DBG_DATA (1 << 4) - #define DBG_RESET_N (1 << 5) - - #define DBG_CLOCK_PIN (P0_3) - #define DBG_DATA_PIN (P0_4) - #define DBG_RESET_N_PIN (P0_5) - - #define DBG_PORT_NUM 0 - #define DBG_PORT P0 - #define DBG_PORT_SEL P0SEL - #define DBG_PORT_INP P0INP - #define DBG_PORT_DIR P0DIR - -#endif /* DBG_ON_P0 */ - -#if COMPANION_CS_ON_P1 - #define COMPANION_CS_PORT P1 - #define COMPANION_CS_SEL P1SEL - #define COMPANION_CS_DIR P1DIR -#endif - -#if SPI_CS_ON_P1 - #define SPI_CS_PORT P1 - #define SPI_CS_SEL P1SEL - #define SPI_CS_DIR P1DIR -#endif - -#if SPI_CS_ON_P0 - #define SPI_CS_PORT P0 - #define SPI_CS_SEL P0SEL - #define SPI_CS_DIR P0DIR -#endif - -#define AO_M25_SPI_CS_PORT SPI_CS_PORT - -#ifndef IGNITE_ON_P2 -#error Please define IGNITE_ON_P2 -#endif - -#ifndef IGNITE_ON_P0 -#error Please define IGNITE_ON_P0 -#endif - -#ifndef HAS_SERIAL_1 -#error Please define HAS_SERIAL_1 -#endif - -#ifndef HAS_ADC -#error Please define HAS_ADC -#endif - -#ifndef HAS_EEPROM -#error Please define HAS_EEPROM -#endif - -#ifndef HAS_LOG -#error Please define HAS_LOG -#endif - -#if HAS_EEPROM -#ifndef USE_INTERNAL_FLASH -#error Please define USE_INTERNAL_FLASH -#endif -#endif - -#ifndef HAS_DBG -#error Please define HAS_DBG -#endif - -#ifndef HAS_IGNITE -#error Please define HAS_IGNITE -#endif - -#if HAS_IGNITE -#define HAS_IGNITE_REPORT 1 -#endif - -#ifndef PACKET_HAS_MASTER -#error Please define PACKET_HAS_MASTER -#endif - -#ifndef PACKET_HAS_SLAVE -#error Please define PACKET_HAS_SLAVE -#endif - -#ifndef HAS_MONITOR -#error Please define HAS_MONITOR -#endif - -#if HAS_MONITOR -#ifndef HAS_RSSI -#error Please define HAS_RSSI -#endif -#endif - -#ifndef HAS_ADC -#error Please define HAS_ADC -#endif - -#if HAS_ADC - -#if HAS_ACCEL -#ifndef HAS_ACCEL_REF -#error Please define HAS_ACCEL_REF -#endif -#else -#define HAS_ACCEL_REF 0 -#endif - -#endif /* HAS_ADC */ - -#if IGNITE_ON_P2 -#define AO_IGNITER_DROGUE P2_3 -#define AO_IGNITER_MAIN P2_4 -#define AO_IGNITER_DIR P2DIR -#define AO_IGNITER_DROGUE_BIT (1 << 3) -#define AO_IGNITER_MAIN_BIT (1 << 4) -#endif - -#if IGNITE_ON_P0 -#define AO_IGNITER_DROGUE P0_5 -#define AO_IGNITER_MAIN P0_4 -#define AO_IGNITER_DIR P0DIR -#define AO_IGNITER_DROGUE_BIT (1 << 5) -#define AO_IGNITER_MAIN_BIT (1 << 4) -#endif - -/* test these values with real igniters */ -#define AO_IGNITER_OPEN 1000 -#define AO_IGNITER_CLOSED 7000 -#define AO_IGNITER_FIRE_TIME AO_MS_TO_TICKS(50) -#define AO_IGNITER_CHARGE_TIME AO_MS_TO_TICKS(2000) - -struct ao_adc { - int16_t accel; /* accelerometer */ - int16_t pres; /* pressure sensor */ - int16_t temp; /* temperature sensor */ - int16_t v_batt; /* battery voltage */ - int16_t sense_d; /* drogue continuity sense */ - int16_t sense_m; /* main continuity sense */ -#if HAS_ACCEL_REF - uint16_t accel_ref; /* acceleration reference */ -#endif -}; - -#endif /* _AO_PINS_H_ */ diff --git a/src/teleballoon-v1.1/ao_teleballoon.c b/src/teleballoon-v1.1/ao_teleballoon.c deleted file mode 100644 index bdbf91d4..00000000 --- a/src/teleballoon-v1.1/ao_teleballoon.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright © 2009 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" -#include "ao_pins.h" - -void -ao_ignite_set_pins(void) -{ - AO_IGNITER_DROGUE = 0; - AO_IGNITER_MAIN = 0; - AO_IGNITER_DIR |= AO_IGNITER_DROGUE_BIT | AO_IGNITER_MAIN_BIT; -} - -__pdata uint16_t ao_motor_number; - -void -main(void) -{ - /* - * Reduce the transient on the ignite pins at startup by - * pulling the pins low as soon as possible at power up - */ - ao_ignite_set_pins(); - - ao_clock_init(); - - /* Turn on the red LED until the system is stable */ - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_RED); - - /* A hack -- look at the SPI clock pin, if it's sitting at - * ground, then we force the computer to idle mode instead of - * flight mode - */ - if (P1_3 == 0) { - ao_flight_force_idle = 1; - while (P1_3 == 0) - ; - } - ao_task_init(); - - ao_timer_init(); - ao_adc_init(); - ao_beep_init(); - ao_cmd_init(); - ao_spi_init(); - ao_storage_init(); - ao_flight_init(); - ao_log_init(); - ao_report_init(); - ao_usb_init(); - ao_serial_init(); - ao_gps_init(); - ao_gps_report_init(); - ao_telemetry_init(); - ao_radio_init(); - ao_packet_slave_init(TRUE); -#if HAS_DBG - ao_dbg_init(); -#endif -#if HAS_COMPANION - ao_companion_init(); -#endif - ao_config_init(); - ao_start_scheduler(); -} diff --git a/src/telebt-v1.0/.gitignore b/src/telebt-v1.0/.gitignore deleted file mode 100644 index 1acfbfcc..00000000 --- a/src/telebt-v1.0/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -telebt-* -ao_product.h diff --git a/src/telebt-v1.0/.sdcdbrc b/src/telebt-v1.0/.sdcdbrc deleted file mode 100644 index 2c77e32b..00000000 --- a/src/telebt-v1.0/.sdcdbrc +++ /dev/null @@ -1,2 +0,0 @@ ---directory=../cc1111:../product:../kernel:../drivers:. - diff --git a/src/telebt-v1.0/Makefile b/src/telebt-v1.0/Makefile deleted file mode 100644 index a7797499..00000000 --- a/src/telebt-v1.0/Makefile +++ /dev/null @@ -1,97 +0,0 @@ -# -# TeleBT build file -# - -TELEBT_VER=1.0 -TELEBT_DEF=1_0 - -vpath %.c ..:../kernel:../cc1111:../drivers:../product -vpath %.h ..:../kernel:../cc1111:../drivers:../product -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - ao_arch.h \ - ao_arch_funcs.h \ - cc1111.h \ - ao_product.h - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_gps_print.c \ - ao_monitor.c \ - ao_mutex.c \ - ao_panic.c \ - ao_state.c \ - ao_stdio.c \ - ao_task.c \ - ao_freq.c - -CC1111_SRC = \ - ao_dbg.c \ - ao_adc.c \ - ao_dma.c \ - ao_led.c \ - ao_packet.c \ - ao_packet_master.c \ - ao_radio.c \ - ao_romconfig.c \ - ao_serial.c \ - ao_string.c \ - ao_timer.c \ - ao_usb.c \ - _bp.c - -DRIVER_SRC = \ - ao_btm.c - -PRODUCT_SRC = \ - ao_telebt.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) - -PROGNAME = telebt-v$(TELEBT_VER) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TeleBT-v$(TELEBT_VER) -PRODUCT_DEF=-DTELEBT_V_$(TELEBT_DEF) -IDPRODUCT=0x000e - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: diff --git a/src/telebt-v1.0/ao_pins.h b/src/telebt-v1.0/ao_pins.h deleted file mode 100644 index ca751be3..00000000 --- a/src/telebt-v1.0/ao_pins.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_PINS_H_ -#define _AO_PINS_H_ - -#define HAS_RADIO 1 -#define HAS_FLIGHT 0 -#define HAS_USB 1 -#define HAS_BEEP 0 -#define HAS_SERIAL_1 1 -#define HAS_SERIAL_1_ALT_1 1 -#define HAS_SERIAL_1_ALT_2 0 -#define HAS_SERIAL_1_HW_FLOW 1 -#define USE_SERIAL_1_STDIN 1 -#define DELAY_SERIAL_1_STDIN 1 -#define HAS_DBG 1 -#define HAS_EEPROM 0 -#define HAS_LOG 0 -#define USE_INTERNAL_FLASH 0 -#define HAS_BTM 1 -#define DBG_ON_P1 1 -#define DBG_ON_P0 0 -#define PACKET_HAS_MASTER 1 -#define PACKET_HAS_SLAVE 0 -#define AO_LED_RED 1 -#define AO_LED_BLUE 2 -#define LEDS_AVAILABLE (AO_LED_RED|AO_LED_BLUE) -#define AO_MONITOR_LED AO_LED_RED -#define AO_BT_LED AO_LED_BLUE -#define BT_LINK_ON_P2 0 -#define BT_LINK_ON_P1 1 -#define BT_LINK_PIN_INDEX 7 -#define BT_LINK_PIN P1_7 -#define HAS_MONITOR 1 -#define LEGACY_MONITOR 0 -#define HAS_TELEMETRY 0 -#define AO_RADIO_REG_TEST 1 - -#define HAS_ADC 1 -#define AO_PAD_ADC_BATT 0 -#define AO_ADC_PINS (1 << AO_PAD_ADC_BATT) - -struct ao_adc { - int16_t batt; -}; - -#define AO_ADC_DUMP(p) \ - printf ("tick: %5u batt %5d\n", \ - (p)->tick, \ - (p)->adc.batt) - -#if DBG_ON_P1 - - #define DBG_CLOCK (1 << 4) /* mi0 */ - #define DBG_DATA (1 << 5) /* mo0 */ - #define DBG_RESET_N (1 << 3) /* c0 */ - - #define DBG_CLOCK_PIN (P1_4) - #define DBG_DATA_PIN (P1_5) - #define DBG_RESET_N_PIN (P1_3) - - #define DBG_PORT_NUM 1 - #define DBG_PORT P1 - #define DBG_PORT_SEL P1SEL - #define DBG_PORT_INP P1INP - #define DBG_PORT_DIR P1DIR - -#endif /* DBG_ON_P1 */ - -#if DBG_ON_P0 - - #define DBG_CLOCK (1 << 3) - #define DBG_DATA (1 << 4) - #define DBG_RESET_N (1 << 5) - - #define DBG_CLOCK_PIN (P0_3) - #define DBG_DATA_PIN (P0_4) - #define DBG_RESET_N_PIN (P0_5) - - #define DBG_PORT_NUM 0 - #define DBG_PORT P0 - #define DBG_PORT_SEL P0SEL - #define DBG_PORT_INP P0INP - #define DBG_PORT_DIR P0DIR - -#endif /* DBG_ON_P0 */ - -#endif /* _AO_PINS_H_ */ diff --git a/src/telebt-v1.0/ao_telebt.c b/src/telebt-v1.0/ao_telebt.c deleted file mode 100644 index a56adc92..00000000 --- a/src/telebt-v1.0/ao_telebt.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -void -main(void) -{ - ao_clock_init(); - - /* Turn on the LED until the system is stable */ - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_RED); - - ao_task_init(); - - ao_timer_init(); - ao_cmd_init(); - ao_usb_init(); - ao_monitor_init(); - ao_radio_init(); - ao_packet_master_init(); - ao_adc_init(); - ao_btm_init(); -#if HAS_DBG - ao_dbg_init(); -#endif - ao_config_init(); - ao_start_scheduler(); -} diff --git a/src/teledongle-v0.1/.gitignore b/src/teledongle-v0.1/.gitignore deleted file mode 100644 index 9826814b..00000000 --- a/src/teledongle-v0.1/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -teledongle-v0.1* -ao_product.h diff --git a/src/teledongle-v0.1/.sdcdbrc b/src/teledongle-v0.1/.sdcdbrc deleted file mode 100644 index 710b4a2f..00000000 --- a/src/teledongle-v0.1/.sdcdbrc +++ /dev/null @@ -1 +0,0 @@ ---directory=.. diff --git a/src/teledongle-v0.1/Makefile b/src/teledongle-v0.1/Makefile deleted file mode 100644 index 48425107..00000000 --- a/src/teledongle-v0.1/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# -# TeleDongle v0.2 build -# - -TD_VER=0.1 -TD_DEF=0_1 - -include ../product/Makefile.teledongle diff --git a/src/teledongle-v0.2/.gitignore b/src/teledongle-v0.2/.gitignore deleted file mode 100644 index f6ea8c6c..00000000 --- a/src/teledongle-v0.2/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -teledongle-v0.2* -ao_product.h diff --git a/src/teledongle-v0.2/.sdcdbrc b/src/teledongle-v0.2/.sdcdbrc deleted file mode 100644 index 710b4a2f..00000000 --- a/src/teledongle-v0.2/.sdcdbrc +++ /dev/null @@ -1 +0,0 @@ ---directory=.. diff --git a/src/teledongle-v0.2/Makefile b/src/teledongle-v0.2/Makefile deleted file mode 100644 index ce4ab437..00000000 --- a/src/teledongle-v0.2/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# -# TeleDongle v0.2 build -# - -TD_VER=0.2 -TD_DEF=0_2 - -include ../product/Makefile.teledongle \ No newline at end of file diff --git a/src/telefire-v0.1/.gitignore b/src/telefire-v0.1/.gitignore deleted file mode 100644 index 4d4f4200..00000000 --- a/src/telefire-v0.1/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -telefire-* -ao_product.h diff --git a/src/telefire-v0.1/.sdcdbrc b/src/telefire-v0.1/.sdcdbrc deleted file mode 100644 index 2c77e32b..00000000 --- a/src/telefire-v0.1/.sdcdbrc +++ /dev/null @@ -1,2 +0,0 @@ ---directory=../cc1111:../product:../kernel:../drivers:. - diff --git a/src/telefire-v0.1/Makefile b/src/telefire-v0.1/Makefile deleted file mode 100644 index 99d29826..00000000 --- a/src/telefire-v0.1/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# -# TeleFire build file -# - -TELEFIRE_VER=0.1 -TELEFIRE_DEF=0_1 - -vpath %.c ..:../kernel:../cc1111:../drivers:../product -vpath %.h ..:../kernel:../cc1111:../drivers:../product -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - ao_arch.h \ - ao_arch_funcs.h \ - ao_pad.h \ - cc1111.h \ - ao_product.h - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_mutex.c \ - ao_panic.c \ - ao_stdio.c \ - ao_storage.c \ - ao_task.c \ - ao_freq.c - -CC1111_SRC = \ - ao_adc.c \ - ao_aes.c \ - ao_beep.c \ - ao_dma.c \ - ao_intflash.c \ - ao_radio.c \ - ao_radio_cmac.c \ - ao_romconfig.c \ - ao_serial.c \ - ao_spi.c \ - ao_string.c \ - ao_timer.c \ - ao_usb.c \ - _bp.c - -DRIVER_SRC = \ - ao_pca9922.c \ - ao_74hc497.c \ - ao_pad.c \ - ao_radio_cmac_cmd.c - -PRODUCT_SRC = \ - ao_telefire.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) - -PROGNAME = telefire-v$(TELEFIRE_VER) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TeleFire-v$(TELEFIRE_VER) -PRODUCT_DEF=-DTELEFIRE_V_$(TELEFIRE_DEF) -IDPRODUCT=0x000f -CODESIZE=0x6700 - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: - diff --git a/src/telefire-v0.1/ao_pins.h b/src/telefire-v0.1/ao_pins.h deleted file mode 100644 index 8266589e..00000000 --- a/src/telefire-v0.1/ao_pins.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_PINS_H_ -#define _AO_PINS_H_ - -#define HAS_RADIO 1 -#define HAS_TELEMETRY 0 - -#define HAS_FLIGHT 0 -#define HAS_USB 1 -#define HAS_BEEP 1 -#define HAS_GPS 0 -#define HAS_SERIAL_1 0 -#define HAS_ADC 1 -#define HAS_DBG 0 -#define HAS_EEPROM 1 -#define HAS_LOG 0 -#define HAS_PAD 1 -#define USE_INTERNAL_FLASH 1 -#define DBG_ON_P1 0 -#define IGNITE_ON_P2 0 -#define IGNITE_ON_P1 1 -#define IGNITE_ON_P0 0 -#define PACKET_HAS_MASTER 0 -#define PACKET_HAS_SLAVE 0 - -#define PAD_BOX 0 - -#define AO_LED_CONTINUITY(c) (1 << ((c) + 2)) -#define AO_LED_CONTINUITY_MASK (0xc) -#define AO_LED_ARMED 0x10 -#define AO_LED_RED 0x20 -#define AO_LED_AMBER 0x40 -#define AO_LED_GREEN 0x80 - -#define LEDS_AVAILABLE (0xff) -#define HAS_EXTERNAL_TEMP 0 -#define HAS_ACCEL_REF 0 -#define SPI_CS_ON_P1 1 -#define HAS_AES 1 -#define DMA_SHARE_AES_RADIO 1 - -#define SPI_CS_PORT P1 -#define SPI_CS_SEL P1SEL -#define SPI_CS_DIR P1DIR - -#define SPI_CONST 0x00 - -#define HAS_SPI_0 0 -#define HAS_SPI_1 1 -#define SPI_1_ALT_1 0 -#define SPI_1_ALT_2 1 - -#define AO_74HC497_CS_PORT P1 -#define AO_74HC497_CS_PIN 4 -#define AO_74HC497_CS P1_4 - -#define AO_PCA9922_CS_PORT P1 -#define AO_PCA9922_CS_PIN 4 -#define AO_PCA9922_CS P1_4 - -#define AO_PAD_NUM 2 -#define AO_PAD_PORT P1 -#define AO_PAD_DIR P1DIR - -#define AO_PAD_PIN_0 2 -#define AO_PAD_0 P1_2 -#define AO_PAD_ADC_0 2 - -#define AO_PAD_PIN_1 3 -#define AO_PAD_1 P1_3 -#define AO_PAD_ADC_1 3 - -#define AO_PAD_ALL_PINS ((1 << AO_PAD_PIN_0) | (1 << AO_PAD_PIN_1)) -#define AO_PAD_ALL_CHANNELS ((1 << 0) | (1 << 1)) - -#define AO_SIREN_PORT P1 -#define AO_SIREN_DIR P1DIR -#define AO_SIREN_PIN 0 -#define AO_SIREN P1_0 - -#define AO_STROBE_PORT P1 -#define AO_STROBE_DIR P1DIR -#define AO_STROBE_PIN 1 -#define AO_STROBE P1_1 - -#define AO_ADC_REFERENCE_DV 33 -#define AO_PAD_R_V_BATT_BATT_SENSE 100 -#define AO_PAD_R_BATT_SENSE_GND 27 - -#define AO_PAD_R_V_BATT_V_PYRO 100 -#define AO_PAD_R_V_PYRO_PYRO_SENSE 100 -#define AO_PAD_R_PYRO_SENSE_GND 27 - -#define AO_PAD_R_V_PYRO_IGNITER 100 -#define AO_PAD_R_IGNITER_IGNITER_SENSE 100 -#define AO_PAD_R_IGNITER_SENSE_GND 27 - -#define AO_PAD_ADC_PYRO 4 -#define AO_PAD_ADC_BATT 5 - -#define AO_ADC_FIRST_PIN 2 - -struct ao_adc { - int16_t sense[AO_PAD_NUM]; - int16_t pyro; - int16_t batt; -}; - -#define AO_ADC_DUMP(p) \ - printf ("tick: %5u 0: %5d 1: %5d pyro: %5d batt %5d\n", \ - (p)->tick, \ - (p)->adc.sense[0], \ - (p)->adc.sense[1], \ - (p)->adc.pyro, \ - (p)->adc.batt) - -#define AO_ADC_PINS ((1 << AO_PAD_ADC_0) | (1 << AO_PAD_ADC_1) | (1 << AO_PAD_ADC_PYRO) | (1 << AO_PAD_ADC_BATT)) - -#endif /* _AO_PINS_H_ */ diff --git a/src/telefire-v0.1/ao_telefire.c b/src/telefire-v0.1/ao_telefire.c deleted file mode 100644 index 706a23a6..00000000 --- a/src/telefire-v0.1/ao_telefire.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include -#include -#include -#include - -void -main(void) -{ - ao_clock_init(); - - ao_led_init(LEDS_AVAILABLE); - - ao_task_init(); - - ao_timer_init(); - ao_adc_init(); - ao_beep_init(); - ao_cmd_init(); - ao_spi_init(); - ao_74hc497_init(); - ao_storage_init(); - ao_usb_init(); - ao_radio_init(); - ao_aes_init(); - ao_pad_init(); -// ao_radio_cmac_cmd_init(); - ao_config_init(); - ao_start_scheduler(); -} diff --git a/src/telefire-v0.2/.gitignore b/src/telefire-v0.2/.gitignore deleted file mode 100644 index 4d4f4200..00000000 --- a/src/telefire-v0.2/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -telefire-* -ao_product.h diff --git a/src/telefire-v0.2/.sdcdbrc b/src/telefire-v0.2/.sdcdbrc deleted file mode 100644 index 2c77e32b..00000000 --- a/src/telefire-v0.2/.sdcdbrc +++ /dev/null @@ -1,2 +0,0 @@ ---directory=../cc1111:../product:../kernel:../drivers:. - diff --git a/src/telefire-v0.2/Makefile b/src/telefire-v0.2/Makefile deleted file mode 100644 index 944543c5..00000000 --- a/src/telefire-v0.2/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# -# TeleFire build file -# - -TELEFIRE_VER=0.2 -TELEFIRE_DEF=0_2 - -vpath %.c ..:../kernel:../cc1111:../drivers:../product -vpath %.h ..:../kernel:../cc1111:../drivers:../product -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - ao_arch.h \ - ao_arch_funcs.h \ - ao_pad.h \ - cc1111.h \ - ao_product.h - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_mutex.c \ - ao_panic.c \ - ao_stdio.c \ - ao_storage.c \ - ao_task.c \ - ao_freq.c - -CC1111_SRC = \ - ao_adc.c \ - ao_aes.c \ - ao_beep.c \ - ao_dma.c \ - ao_intflash.c \ - ao_radio.c \ - ao_radio_cmac.c \ - ao_romconfig.c \ - ao_serial.c \ - ao_spi.c \ - ao_string.c \ - ao_timer.c \ - ao_usb.c \ - _bp.c - -DRIVER_SRC = \ - ao_pca9922.c \ - ao_74hc165.c \ - ao_pad.c \ - ao_radio_cmac_cmd.c - -PRODUCT_SRC = \ - ao_telefire.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) - -PROGNAME = telefire-v$(TELEFIRE_VER) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TeleFire-v$(TELEFIRE_VER) -PRODUCT_DEF=-DTELEFIRE_V_$(TELEFIRE_DEF) -IDPRODUCT=0x000f -CODESIZE=0x6700 - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: - diff --git a/src/telefire-v0.2/ao_pins.h b/src/telefire-v0.2/ao_pins.h deleted file mode 100644 index 65f5bdcc..00000000 --- a/src/telefire-v0.2/ao_pins.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_PINS_H_ -#define _AO_PINS_H_ - -#define HAS_RADIO 1 -#define HAS_RADIO_RATE 1 -#define HAS_TELEMETRY 0 - -#define HAS_FLIGHT 0 -#define HAS_USB 1 -#define HAS_BEEP 0 -#define HAS_GPS 0 -#define HAS_SERIAL_1 0 -#define HAS_ADC 1 -#define HAS_DBG 0 -#define HAS_EEPROM 1 -#define HAS_LOG 0 -#define HAS_PAD 1 -#define USE_INTERNAL_FLASH 1 -#define DBG_ON_P1 0 -#define IGNITE_ON_P2 0 -#define IGNITE_ON_P1 1 -#define IGNITE_ON_P0 0 -#define PACKET_HAS_MASTER 0 -#define PACKET_HAS_SLAVE 0 - -#define AO_LED_CONTINUITY(c) (1 << (c)) -#define AO_LED_CONTINUITY_MASK (0xf) -#define AO_LED_ARMED 0x10 -#define AO_LED_RED 0x20 -#define AO_LED_AMBER 0x40 -#define AO_LED_GREEN 0x80 - -#define LEDS_AVAILABLE (0xff) -#define HAS_EXTERNAL_TEMP 0 -#define HAS_ACCEL_REF 0 -#define SPI_CS_ON_P1 1 -#define HAS_AES 1 -#define DMA_SHARE_AES_RADIO 1 - -#define SPI_CS_PORT P1 -#define SPI_CS_SEL P1SEL -#define SPI_CS_DIR P1DIR - -#define SPI_CONST 0x00 - -#define HAS_SPI_0 0 -#define HAS_SPI_1 1 -#define SPI_1_ALT_1 0 -#define SPI_1_ALT_2 1 - -#define HAS_74HC165 1 -#define AO_74HC165_CS_PORT P1 -#define AO_74HC165_CS_PIN 4 -#define AO_74HC165_CS P1_4 - -#define AO_PCA9922_CS_PORT P2 -#define AO_PCA9922_CS_PIN 0 -#define AO_PCA9922_CS P2_0 - -#define AO_PAD_NUM 4 -#define AO_PAD_PORT P1 -#define AO_PAD_DIR P1DIR - -#define AO_PAD_PIN_0 0 -#define AO_PAD_0 P1_0 -#define AO_PAD_ADC_0 0 - -#define AO_PAD_PIN_1 1 -#define AO_PAD_1 P1_1 -#define AO_PAD_ADC_1 1 - -#define AO_PAD_PIN_2 2 -#define AO_PAD_2 P1_2 -#define AO_PAD_ADC_2 2 - -#define AO_PAD_PIN_3 3 -#define AO_PAD_3 P1_3 -#define AO_PAD_ADC_3 3 - -#define AO_PAD_ALL_PINS ((1 << AO_PAD_PIN_0) | (1 << AO_PAD_PIN_1) | (1 << AO_PAD_PIN_2) | (1 << AO_PAD_PIN_3)) -#define AO_PAD_ALL_CHANNELS ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)) - -/* Alarm 2 */ -#define AO_SIREN_PORT P2 -#define AO_SIREN_DIR P2DIR -#define AO_SIREN_PIN 3 -#define AO_SIREN P2_3 - -/* Alarm 1 */ -#define AO_STROBE_PORT P2 -#define AO_STROBE_DIR P2DIR -#define AO_STROBE_PIN 4 -#define AO_STROBE P2_4 - -/* test these values with real igniters */ -#define AO_PAD_ADC_PYRO 4 -#define AO_PAD_ADC_BATT 5 - -#define AO_ADC_FIRST_PIN 0 - -#define AO_ADC_REFERENCE_DV 33 -#define AO_PAD_R_V_BATT_BATT_SENSE 100 -#define AO_PAD_R_BATT_SENSE_GND 27 - -#define AO_PAD_R_V_BATT_V_PYRO 100 -#define AO_PAD_R_V_PYRO_PYRO_SENSE 100 -#define AO_PAD_R_PYRO_SENSE_GND 27 - -#define AO_PAD_R_V_PYRO_IGNITER 100 -#define AO_PAD_R_IGNITER_IGNITER_SENSE 100 -#define AO_PAD_R_IGNITER_SENSE_GND 27 - - -struct ao_adc { - int16_t sense[AO_PAD_NUM]; - int16_t pyro; - int16_t batt; -}; - -#define AO_ADC_DUMP(p) \ - printf ("tick: %5u 0: %5d 1: %5d 2: %5d 3: %5d pyro: %5d batt %5d\n", \ - (p)->tick, \ - (p)->adc.sense[0], \ - (p)->adc.sense[1], \ - (p)->adc.sense[2], \ - (p)->adc.sense[3], \ - (p)->adc.pyro, \ - (p)->adc.batt) - -#define AO_ADC_PINS ((1 << AO_PAD_ADC_0) | \ - (1 << AO_PAD_ADC_1) | \ - (1 << AO_PAD_ADC_2) | \ - (1 << AO_PAD_ADC_3) | \ - (1 << AO_PAD_ADC_PYRO) | \ - (1 << AO_PAD_ADC_BATT)) - -#endif /* _AO_PINS_H_ */ diff --git a/src/telefire-v0.2/ao_telefire.c b/src/telefire-v0.2/ao_telefire.c deleted file mode 100644 index 5187d5b9..00000000 --- a/src/telefire-v0.2/ao_telefire.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include -#include -#include -#include - -void -main(void) -{ - ao_clock_init(); - - ao_led_init(LEDS_AVAILABLE); - - ao_task_init(); - - ao_timer_init(); - ao_adc_init(); - ao_cmd_init(); - ao_spi_init(); - ao_74hc165_init(); - ao_storage_init(); - ao_usb_init(); - ao_radio_init(); - ao_aes_init(); - ao_pad_init(); -// ao_radio_cmac_cmd_init(); - ao_config_init(); - ao_start_scheduler(); -} diff --git a/src/telelco-v0.1/.gitignore b/src/telelco-v0.1/.gitignore deleted file mode 100644 index 54267ec1..00000000 --- a/src/telelco-v0.1/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -ao_product.h -telelco-* diff --git a/src/telelco-v0.1/Makefile b/src/telelco-v0.1/Makefile deleted file mode 100644 index f7628c30..00000000 --- a/src/telelco-v0.1/Makefile +++ /dev/null @@ -1,99 +0,0 @@ -# -# AltOS build for TeleLCO -# -# - -include ../stm/Makefile.defs - -INC = \ - ao.h \ - ao_arch.h \ - ao_arch_funcs.h \ - ao_boot.h \ - ao_companion.h \ - ao_data.h \ - ao_sample.h \ - ao_pins.h \ - ao_product.h \ - ao_seven_segment.h \ - ao_lco.h \ - ao_lco_cmd.h \ - ao_lco_func.h \ - ao_radio_spi.h \ - ao_radio_cmac.h \ - stm32l.h - -# -# Common AltOS sources -# - -#PROFILE=ao_profile.c -#PROFILE_DEF=-DAO_PROFILE=1 - -ALTOS_SRC = \ - ao_boot_chain.c \ - ao_interrupt.c \ - ao_product.c \ - ao_romconfig.c \ - ao_cmd.c \ - ao_config.c \ - ao_task.c \ - ao_led.c \ - ao_stdio.c \ - ao_panic.c \ - ao_timer.c \ - ao_mutex.c \ - ao_freq.c \ - ao_dma_stm.c \ - ao_spi_stm.c \ - ao_beep_stm.c \ - ao_storage.c \ - ao_eeprom_stm.c \ - ao_lcd_stm.c \ - ao_usb_stm.c \ - ao_exti_stm.c \ - ao_radio_master.c \ - ao_seven_segment.c \ - ao_quadrature.c \ - ao_button.c \ - ao_event.c \ - ao_lco.c \ - ao_lco_cmd.c \ - ao_lco_func.c \ - ao_radio_cmac_cmd.c - -PRODUCT=TeleLCO-v0.1 -PRODUCT_DEF=-DTELEMEGA -IDPRODUCT=0x0023 - -CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) $(PROFILE_DEF) -Os -g - -PROGNAME=telelco-v0.1 -PROG=$(PROGNAME)-$(VERSION).elf -HEX=$(PROGNAME)-$(VERSION).ihx - -SRC=$(ALTOS_SRC) ao_telelco.c -OBJ=$(SRC:.c=.o) - -all: $(PROG) $(HEX) - -$(PROG): Makefile $(OBJ) altos.ld - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS) - -../altitude.h: make-altitude - nickle $< > $@ - -$(OBJ): $(INC) - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: - rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx - rm -f ao_product.h - -install: - -uninstall: diff --git a/src/telelco-v0.1/ao_lco.c b/src/telelco-v0.1/ao_lco.c deleted file mode 100644 index 649bf586..00000000 --- a/src/telelco-v0.1/ao_lco.c +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG 1 - -#if DEBUG -static uint8_t ao_lco_debug; -#define PRINTD(...) do { if (!ao_lco_debug) break; printf ("\r%5u %s: ", ao_tick_count, __func__); printf(__VA_ARGS__); flush(); } while(0) -#else -#define PRINTD(...) -#endif - -#define AO_LCO_PAD_DIGIT 0 -#define AO_LCO_BOX_DIGIT_1 1 -#define AO_LCO_BOX_DIGIT_10 2 - -static uint8_t ao_lco_min_box, ao_lco_max_box; -static uint8_t ao_lco_mutex; -static uint8_t ao_lco_pad; -static uint8_t ao_lco_box; -static uint8_t ao_lco_armed; -static uint8_t ao_lco_firing; -static uint8_t ao_lco_valid; -static uint8_t ao_lco_got_channels; -static uint16_t ao_lco_tick_offset; - -static struct ao_pad_query ao_pad_query; - -static void -ao_lco_set_pad(void) -{ - ao_seven_segment_set(AO_LCO_PAD_DIGIT, ao_lco_pad + 1); -} - -static void -ao_lco_set_box(void) -{ - ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, ao_lco_box % 10); - ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, ao_lco_box / 10); -} - -#define MASK_SIZE(n) (((n) + 7) >> 3) -#define MASK_ID(n) ((n) >> 3) -#define MASK_SHIFT(n) ((n) & 7) - -static uint8_t ao_lco_box_mask[MASK_SIZE(AO_PAD_MAX_BOXES)]; - -static uint8_t -ao_lco_box_present(uint8_t box) -{ - if (box >= AO_PAD_MAX_BOXES) - return 0; - return (ao_lco_box_mask[MASK_ID(box)] >> MASK_SHIFT(box)) & 1; -} - -static uint8_t -ao_lco_pad_present(uint8_t pad) -{ - if (!ao_lco_got_channels || !ao_pad_query.channels) - return pad == 0; - if (pad >= AO_PAD_MAX_CHANNELS) - return 0; - return (ao_pad_query.channels >> pad) & 1; -} - -static uint8_t -ao_lco_pad_first(void) -{ - uint8_t pad; - - for (pad = 0; pad < AO_PAD_MAX_CHANNELS; pad++) - if (ao_lco_pad_present(pad)) - return pad; - return 0; -} - -static void -ao_lco_input(void) -{ - static struct ao_event event; - int8_t dir, new_box, new_pad; - - ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200)); - ao_lco_set_pad(); - ao_lco_set_box(); - for (;;) { - ao_event_get(&event); - PRINTD("event type %d unit %d value %d\n", - event.type, event.unit, event.value); - switch (event.type) { - case AO_EVENT_QUADRATURE: - switch (event.unit) { - case AO_QUADRATURE_PAD: - if (!ao_lco_armed) { - if (event.value == ao_lco_pad) - break; - dir = ((int8_t) event.value - (int8_t) ao_lco_pad) > 0 ? 1 : -1; - new_pad = event.value; - while (!ao_lco_pad_present(new_pad)) { - new_pad += dir; - if (new_pad > AO_PAD_MAX_CHANNELS) - new_pad = 0; - else if (new_pad < 0) - new_pad = AO_PAD_MAX_CHANNELS - 1; - if (new_pad == ao_lco_pad) - break; - } - if (new_pad != ao_lco_pad) { - ao_lco_pad = new_pad; - ao_quadrature_count[AO_QUADRATURE_PAD] = ao_lco_pad; - ao_lco_set_pad(); - } - } - break; - case AO_QUADRATURE_BOX: - if (!ao_lco_armed) { - if (event.value == ao_lco_box) - break; - dir = ((int8_t) event.value - (int8_t) ao_lco_box) > 0 ? 1 : -1; - new_box = event.value; - while (!ao_lco_box_present(new_box)) { - new_box += dir; - if (new_box > ao_lco_max_box) - new_box = ao_lco_min_box; - else if (new_box < ao_lco_min_box) - new_box = ao_lco_min_box; - if (new_box == ao_lco_box) - break; - } - ao_quadrature_count[AO_QUADRATURE_PAD] = new_box; - if (ao_lco_box != new_box) { - ao_lco_box = new_box; - ao_lco_got_channels = 0; - ao_lco_set_box(); - } - } - break; - } - break; - case AO_EVENT_BUTTON: - switch (event.unit) { - case AO_BUTTON_ARM: - ao_lco_armed = event.value; - PRINTD("Armed %d\n", ao_lco_armed); - ao_wakeup(&ao_lco_armed); - break; - case AO_BUTTON_FIRE: - if (ao_lco_armed) { - ao_lco_firing = event.value; - PRINTD("Firing %d\n", ao_lco_firing); - ao_wakeup(&ao_lco_armed); - } - break; - } - break; - } - } -} - -static AO_LED_TYPE continuity_led[AO_LED_CONTINUITY_NUM] = { -#ifdef AO_LED_CONTINUITY_0 - AO_LED_CONTINUITY_0, -#endif -#ifdef AO_LED_CONTINUITY_1 - AO_LED_CONTINUITY_1, -#endif -#ifdef AO_LED_CONTINUITY_2 - AO_LED_CONTINUITY_2, -#endif -#ifdef AO_LED_CONTINUITY_3 - AO_LED_CONTINUITY_3, -#endif -#ifdef AO_LED_CONTINUITY_4 - AO_LED_CONTINUITY_4, -#endif -#ifdef AO_LED_CONTINUITY_5 - AO_LED_CONTINUITY_5, -#endif -#ifdef AO_LED_CONTINUITY_6 - AO_LED_CONTINUITY_6, -#endif -#ifdef AO_LED_CONTINUITY_7 - AO_LED_CONTINUITY_7, -#endif -}; - -static void -ao_lco_update(void) -{ - int8_t r; - uint8_t c; - - r = ao_lco_query(ao_lco_box, &ao_pad_query, &ao_lco_tick_offset); - if (r == AO_RADIO_CMAC_OK) { - c = ao_lco_got_channels; - ao_lco_got_channels = 1; - ao_lco_valid = 1; - if (!c) { - ao_lco_pad = ao_lco_pad_first(); - ao_lco_set_pad(); - } - } else - ao_lco_valid = 0; - -#if 0 - PRINTD("lco_query success arm_status %d i0 %d i1 %d i2 %d i3 %d\n", - query.arm_status, - query.igniter_status[0], - query.igniter_status[1], - query.igniter_status[2], - query.igniter_status[3]); -#endif - - ao_wakeup(&ao_pad_query); -} - -static void -ao_lco_box_set_present(uint8_t box) -{ - if (box >= AO_PAD_MAX_BOXES) - return; - ao_lco_box_mask[MASK_ID(box)] |= 1 << MASK_SHIFT(box); -} - -static void -ao_lco_search(void) -{ - uint16_t tick_offset; - int8_t r; - - ao_lco_min_box = 0xff; - ao_lco_max_box = 0x00; - for (ao_lco_box = 0; ao_lco_box < AO_PAD_MAX_BOXES; ao_lco_box++) { - if ((ao_lco_box % 10) == 0) - ao_lco_set_box(); - r = ao_lco_query(ao_lco_box, &ao_pad_query, &ao_lco_tick_offset); - if (r == AO_RADIO_CMAC_OK) { - if (ao_lco_box < ao_lco_min_box) - ao_lco_min_box = ao_lco_box; - if (ao_lco_box > ao_lco_max_box) - ao_lco_max_box = ao_lco_box; - ao_lco_box_set_present(ao_lco_box); - } - } - if (ao_lco_min_box <= ao_lco_max_box) - ao_lco_box = ao_lco_min_box; - else - ao_lco_min_box = ao_lco_max_box = ao_lco_box = 0; - ao_lco_valid = 0; - ao_lco_got_channels = 0; - ao_lco_pad = 0; -} - -static void -ao_lco_igniter_status(void) -{ - uint8_t c; - uint16_t delay; - - for (;;) { - ao_sleep(&ao_pad_query); - if (!ao_lco_valid) { - ao_led_on(AO_LED_RED); - ao_led_off(AO_LED_GREEN); - continue; - } - PRINTD("RSSI %d\n", ao_radio_cmac_rssi); - if (ao_radio_cmac_rssi < -90) - ao_led_on(AO_LED_RED|AO_LED_GREEN); - else { - ao_led_on(AO_LED_GREEN); - ao_led_off(AO_LED_RED); - } - if (ao_pad_query.arm_status) - ao_led_on(AO_LED_REMOTE_ARM); - else - ao_led_off(AO_LED_REMOTE_ARM); - for (c = 0; c < AO_LED_CONTINUITY_NUM; c++) { - uint8_t status; - - if (ao_pad_query.channels & (1 << c)) - status = ao_pad_query.igniter_status[c]; - else - status = AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_OPEN; - if (status == AO_PAD_IGNITER_STATUS_GOOD_IGNITER_RELAY_OPEN) - ao_led_on(continuity_led[c]); - else - ao_led_off(continuity_led[c]); - } - } -} - -static void -ao_lco_arm_warn(void) -{ - for (;;) { - while (!ao_lco_armed) - ao_sleep(&ao_lco_armed); - ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200)); - ao_delay(AO_MS_TO_TICKS(200)); - } -} - -static struct ao_task ao_lco_input_task; -static struct ao_task ao_lco_monitor_task; -static struct ao_task ao_lco_arm_warn_task; -static struct ao_task ao_lco_igniter_status_task; - -static void -ao_lco_monitor(void) -{ - uint16_t delay; - - ao_lco_search(); - ao_add_task(&ao_lco_input_task, ao_lco_input, "lco input"); - ao_add_task(&ao_lco_arm_warn_task, ao_lco_arm_warn, "lco arm warn"); - ao_add_task(&ao_lco_igniter_status_task, ao_lco_igniter_status, "lco igniter status"); - for (;;) { - PRINTD("monitor armed %d firing %d offset %d\n", - ao_lco_armed, ao_lco_firing, ao_lco_tick_offset); - - if (ao_lco_armed && ao_lco_firing) { - PRINTD("Firing box %d pad %d: valid %d\n", - ao_lco_box, ao_lco_pad, ao_lco_valid); - if (!ao_lco_valid) - ao_lco_update(); - if (ao_lco_valid) - ao_lco_ignite(ao_lco_box, 1 << ao_lco_pad, ao_lco_tick_offset); - } else if (ao_lco_armed) { - PRINTD("Arming box %d pad %d\n", - ao_lco_box, ao_lco_pad); - if (!ao_lco_valid) - ao_lco_update(); - ao_lco_arm(ao_lco_box, 1 << ao_lco_pad, ao_lco_tick_offset); - ao_lco_update(); - } else { - ao_lco_update(); - } - if (ao_lco_armed && ao_lco_firing) - delay = AO_MS_TO_TICKS(100); - else - delay = AO_SEC_TO_TICKS(1); - ao_sleep_for(&ao_lco_armed, delay); - } -} - -#if DEBUG -void -ao_lco_set_debug(void) -{ - ao_cmd_decimal(); - if (ao_cmd_status == ao_cmd_success) - ao_lco_debug = ao_cmd_lex_i != 0; -} - -__code struct ao_cmds ao_lco_cmds[] = { - { ao_lco_set_debug, "D <0 off, 1 on>\0Debug" }, - { 0, NULL } -}; -#endif - -void -ao_lco_init(void) -{ - ao_add_task(&ao_lco_monitor_task, ao_lco_monitor, "lco monitor"); -#if DEBUG - ao_cmd_register(&ao_lco_cmds[0]); -#endif -} diff --git a/src/telelco-v0.1/ao_lco.h b/src/telelco-v0.1/ao_lco.h deleted file mode 100644 index 5721eed5..00000000 --- a/src/telelco-v0.1/ao_lco.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_LCO_H_ -#define _AO_LCO_H_ - -void -ao_lco_init(void); - -#endif /* _AO_LCO_H_ */ diff --git a/src/telelco-v0.1/ao_pins.h b/src/telelco-v0.1/ao_pins.h deleted file mode 100644 index 23115997..00000000 --- a/src/telelco-v0.1/ao_pins.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_PINS_H_ -#define _AO_PINS_H_ - -/* 8MHz High speed external crystal */ -#define AO_HSE 8000000 - -/* PLLVCO = 96MHz (so that USB will work) */ -#define AO_PLLMUL 12 -#define AO_RCC_CFGR_PLLMUL (STM_RCC_CFGR_PLLMUL_12) - -/* SYSCLK = 32MHz (no need to go faster than CPU) */ -#define AO_PLLDIV 3 -#define AO_RCC_CFGR_PLLDIV (STM_RCC_CFGR_PLLDIV_3) - -/* HCLK = 32MHz (CPU clock) */ -#define AO_AHB_PRESCALER 1 -#define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1 - -/* Run APB1 at 16MHz (HCLK/2) */ -#define AO_APB1_PRESCALER 2 -#define AO_RCC_CFGR_PPRE1_DIV STM_RCC_CFGR_PPRE2_DIV_2 - -/* Run APB2 at 16MHz (HCLK/2) */ -#define AO_APB2_PRESCALER 2 -#define AO_RCC_CFGR_PPRE2_DIV STM_RCC_CFGR_PPRE2_DIV_2 - -#define HAS_EEPROM 1 -#define USE_INTERNAL_FLASH 1 -#define HAS_USB 1 -#define HAS_BEEP 1 -#define HAS_RADIO 1 -#define HAS_TELEMETRY 0 -#define HAS_AES 1 - -#define HAS_SPI_1 0 -#define SPI_1_PA5_PA6_PA7 0 -#define SPI_1_PB3_PB4_PB5 0 -#define SPI_1_PE13_PE14_PE15 0 - -#define HAS_SPI_2 1 /* CC1111 */ -#define SPI_2_PB13_PB14_PB15 1 -#define SPI_2_PD1_PD3_PD4 0 -#define SPI_2_GPIO (&stm_gpiob) -#define SPI_2_SCK 13 -#define SPI_2_MISO 14 -#define SPI_2_MOSI 15 -#define SPI_2_OSPEEDR STM_OSPEEDR_10MHz - -#define HAS_I2C_1 0 - -#define HAS_I2C_2 0 - -#define PACKET_HAS_SLAVE 0 -#define PACKET_HAS_MASTER 0 - -/* - * Radio is a cc1111 connected via SPI - */ -#define AO_RADIO_CAL_DEFAULT 1186611 - -#define AO_RADIO_SPI_BUS AO_SPI_2_PB13_PB14_PB15 -#define AO_RADIO_CS_PORT (&stm_gpiob) -#define AO_RADIO_CS_PIN 12 - -#define AO_RADIO_INT_PORT (&stm_gpioc) -#define AO_RADIO_INT_PIN 14 - -#define LOW_LEVEL_DEBUG 0 - -#define LED_PORT_ENABLE STM_RCC_AHBENR_GPIOCEN -#define LED_PORT (&stm_gpioc) -#define LED_PIN_RED 7 -#define LED_PIN_GREEN 8 -#define LED_PIN_CONTINUITY_3 9 -#define LED_PIN_CONTINUITY_2 10 -#define LED_PIN_CONTINUITY_1 11 -#define LED_PIN_CONTINUITY_0 12 -#define LED_PIN_REMOTE_ARM 13 -#define AO_LED_RED (1 << LED_PIN_RED) -#define AO_LED_GREEN (1 << LED_PIN_GREEN) -#define AO_LED_CONTINUITY_3 (1 << LED_PIN_CONTINUITY_3) -#define AO_LED_CONTINUITY_2 (1 << LED_PIN_CONTINUITY_2) -#define AO_LED_CONTINUITY_1 (1 << LED_PIN_CONTINUITY_1) -#define AO_LED_CONTINUITY_0 (1 << LED_PIN_CONTINUITY_0) - -#define AO_LED_CONTINUITY_NUM 4 - -#define AO_LED_REMOTE_ARM (1 << LED_PIN_REMOTE_ARM) - -#define LEDS_AVAILABLE (AO_LED_RED | \ - AO_LED_GREEN | \ - AO_LED_CONTINUITY_3 | \ - AO_LED_CONTINUITY_2 | \ - AO_LED_CONTINUITY_1 | \ - AO_LED_CONTINUITY_0 | \ - AO_LED_REMOTE_ARM) - -/* LCD displays */ - -#define AO_LCD_STM_SEG_ENABLED_0 ( \ - (1 << 0) | /* PA1 */ \ - (1 << 1) | /* PA2 */ \ - (1 << 2) | /* PA3 */ \ - (1 << 3) | /* PA6 */ \ - (1 << 4) | /* PA7 */ \ - (1 << 5) | /* PB0 */ \ - (1 << 6) | /* PB1 */ \ - (1 << 7) | /* PB3 */ \ - (0 << 8) | /* PB4 */ \ - (0 << 9) | /* PB5 */ \ - (0 << 10) | /* PB10 */ \ - (0 << 11) | /* PB11 */ \ - (0 << 12) | /* PB12 */ \ - (0 << 13) | /* PB13 */ \ - (0 << 14) | /* PB14 */ \ - (0 << 15) | /* PB15 */ \ - (0 << 16) | /* PB8 */ \ - (0 << 17) | /* PA15 */ \ - (0 << 18) | /* PC0 */ \ - (0 << 19) | /* PC1 */ \ - (0 << 20) | /* PC2 */ \ - (0 << 21) | /* PC3 */ \ - (0 << 22) | /* PC4 */ \ - (0 << 23) | /* PC5 */ \ - (0 << 24) | /* PC6 */ \ - (0 << 25) | /* PC7 */ \ - (0 << 26) | /* PC8 */ \ - (0 << 27) | /* PC9 */ \ - (0 << 28) | /* PC10 or PD8 */ \ - (0 << 29) | /* PC11 or PD9 */ \ - (0 << 30) | /* PC12 or PD10 */ \ - (0 << 31)) /* PD2 or PD11 */ - -#define AO_LCD_STM_SEG_ENABLED_1 ( \ - (0 << 0) | /* PD12 */ \ - (0 << 1) | /* PD13 */ \ - (0 << 2) | /* PD14 */ \ - (0 << 3) | /* PD15 */ \ - (0 << 4) | /* PE0 */ \ - (0 << 5) | /* PE1 */ \ - (0 << 6) | /* PE2 */ \ - (0 << 7)) /* PE3 */ - -#define AO_LCD_STM_COM_ENABLED ( \ - (1 << 0) | /* PA8 */ \ - (1 << 1) | /* PA9 */ \ - (1 << 2) | /* PA10 */ \ - (0 << 3) | /* PB9 */ \ - (0 << 4) | /* PC10 */ \ - (0 << 5) | /* PC11 */ \ - (0 << 6)) /* PC12 */ - -#define AO_LCD_28_ON_C 0 - -#define AO_LCD_DUTY STM_LCD_CR_DUTY_1_4 - -#define AO_SEGMENT_0 0 -#define AO_SEGMENT_1 5 -#define AO_SEGMENT_2 1 -#define AO_SEGMENT_3 6 -#define AO_SEGMENT_4 4 -#define AO_SEGMENT_5 2 -#define AO_SEGMENT_6 3 -#define AO_SEGMENT_7 7 - -/* - * Use event queue for input devices - */ - -#define AO_EVENT 1 - -/* - * Knobs - */ - -#define AO_QUADRATURE_COUNT 2 -#define AO_QUADRATURE_MODE 0 - -#define AO_QUADRATURE_0_PORT &stm_gpioc -#define AO_QUADRATURE_0_A 3 -#define AO_QUADRATURE_0_B 2 - -#define AO_QUADRATURE_PAD 0 - -#define AO_QUADRATURE_1_PORT &stm_gpioc -#define AO_QUADRATURE_1_A 1 -#define AO_QUADRATURE_1_B 0 - -#define AO_QUADRATURE_BOX 1 - -/* - * Buttons - */ - -#define AO_BUTTON_COUNT 2 -#define AO_BUTTON_MODE AO_EXTI_MODE_PULL_UP - -#define AO_BUTTON_0_PORT &stm_gpioc -#define AO_BUTTON_0 4 - -#define AO_BUTTON_ARM 0 - -#define AO_BUTTON_1_PORT &stm_gpioc -#define AO_BUTTON_1 5 - -#define AO_BUTTON_FIRE 1 - -#endif /* _AO_PINS_H_ */ diff --git a/src/telelco-v0.1/ao_telelco.c b/src/telelco-v0.1/ao_telelco.c deleted file mode 100644 index 608f093d..00000000 --- a/src/telelco-v0.1/ao_telelco.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int -main(void) -{ - ao_clock_init(); - - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_GREEN); - ao_task_init(); - - ao_timer_init(); - - ao_spi_init(); - ao_dma_init(); - ao_exti_init(); - - ao_beep_init(); - ao_cmd_init(); - - ao_lcd_stm_init(); - ao_seven_segment_init(); - ao_quadrature_init(); - ao_button_init(); - - ao_storage_init(); - - ao_radio_init(); - - ao_usb_init(); - - ao_config_init(); - - ao_quadrature_init(); - ao_button_init(); - ao_lco_init(); - ao_lco_cmd_init(); -// ao_radio_cmac_cmd_init(); - - ao_start_scheduler(); - return 0; -} diff --git a/src/telemetrum-v0.1-sirf/.gitignore b/src/telemetrum-v0.1-sirf/.gitignore deleted file mode 100644 index 7698f5aa..00000000 --- a/src/telemetrum-v0.1-sirf/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -telemetrum-v0.1-sirf* -ao_product.h diff --git a/src/telemetrum-v0.1-sirf/Makefile b/src/telemetrum-v0.1-sirf/Makefile deleted file mode 100644 index d138b5ef..00000000 --- a/src/telemetrum-v0.1-sirf/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# -# TeleMetrum v0.1 with SkyTraq GPS build -# - -TM_VER=0.1 -TM_DEF=0_1 -TM_EXTRA=-sirf - -TM_INC = \ - ao_25lc1024.h - -TM_SRC = \ - ao_gps_sirf.c \ - ao_25lc1024.c - -include ../product/Makefile.telemetrum - diff --git a/src/telemetrum-v0.1-sky/.gitignore b/src/telemetrum-v0.1-sky/.gitignore deleted file mode 100644 index d25d7ad9..00000000 --- a/src/telemetrum-v0.1-sky/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -telemetrum-v0.1-sky* -ao_product.h diff --git a/src/telemetrum-v0.1-sky/.sdcdbrc b/src/telemetrum-v0.1-sky/.sdcdbrc deleted file mode 100644 index 710b4a2f..00000000 --- a/src/telemetrum-v0.1-sky/.sdcdbrc +++ /dev/null @@ -1 +0,0 @@ ---directory=.. diff --git a/src/telemetrum-v0.1-sky/Makefile b/src/telemetrum-v0.1-sky/Makefile deleted file mode 100644 index a6634c29..00000000 --- a/src/telemetrum-v0.1-sky/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# -# TeleMetrum v0.1 with SkyTraq GPS build -# - -TM_VER=0.1 -TM_DEF=0_1 -TM_EXTRA=-sky - -TM_INC = \ - ao_25lc1024.h - -TM_SRC = \ - ao_gps_skytraq.c \ - ao_gps_show.c \ - ao_25lc1024.c - -include ../product/Makefile.telemetrum - diff --git a/src/telemetrum-v1.0/.gitignore b/src/telemetrum-v1.0/.gitignore deleted file mode 100644 index c2212151..00000000 --- a/src/telemetrum-v1.0/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -telemetrum-* -ao_product.h diff --git a/src/telemetrum-v1.0/.sdcdbrc b/src/telemetrum-v1.0/.sdcdbrc deleted file mode 100644 index e9a51ea6..00000000 --- a/src/telemetrum-v1.0/.sdcdbrc +++ /dev/null @@ -1 +0,0 @@ ---directory=../cc1111:../product:../kernel:../drivers:. diff --git a/src/telemetrum-v1.0/Makefile b/src/telemetrum-v1.0/Makefile deleted file mode 100644 index 476a3b0a..00000000 --- a/src/telemetrum-v1.0/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# -# TeleMetrum v1.0 build -# - -TM_VER=1.0 -TM_DEF=1_0 - -TM_INC = \ - ao_at45db161d.h - -TM_SRC = \ - ao_companion.c \ - ao_gps_skytraq.c \ - ao_gps_show.c \ - ao_at45db161d.c - -include ../product/Makefile.telemetrum diff --git a/src/telemetrum-v1.1/.gitignore b/src/telemetrum-v1.1/.gitignore deleted file mode 100644 index c2212151..00000000 --- a/src/telemetrum-v1.1/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -telemetrum-* -ao_product.h diff --git a/src/telemetrum-v1.1/.sdcdbrc b/src/telemetrum-v1.1/.sdcdbrc deleted file mode 100644 index e9a51ea6..00000000 --- a/src/telemetrum-v1.1/.sdcdbrc +++ /dev/null @@ -1 +0,0 @@ ---directory=../cc1111:../product:../kernel:../drivers:. diff --git a/src/telemetrum-v1.1/Makefile b/src/telemetrum-v1.1/Makefile deleted file mode 100644 index 61e9273b..00000000 --- a/src/telemetrum-v1.1/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# -# AltOS build -# -# - -TM_VER=1.1 -TM_DEF=1_1 - -TM_INC = - -TM_SRC = \ - ao_companion.c \ - ao_gps_skytraq.c \ - ao_gps_show.c \ - ao_convert_volt.c \ - ao_m25.c - -include ../product/Makefile.telemetrum diff --git a/src/telemetrum-v1.2/.gitignore b/src/telemetrum-v1.2/.gitignore deleted file mode 100644 index c2212151..00000000 --- a/src/telemetrum-v1.2/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -telemetrum-* -ao_product.h diff --git a/src/telemetrum-v1.2/.sdcdbrc b/src/telemetrum-v1.2/.sdcdbrc deleted file mode 100644 index 710b4a2f..00000000 --- a/src/telemetrum-v1.2/.sdcdbrc +++ /dev/null @@ -1 +0,0 @@ ---directory=.. diff --git a/src/telemetrum-v1.2/Makefile b/src/telemetrum-v1.2/Makefile deleted file mode 100644 index 38ba6d49..00000000 --- a/src/telemetrum-v1.2/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# -# AltOS build -# -# - -TM_VER=1.2 -TM_DEF=1_2 - -TM_INC = - -TM_SRC = \ - ao_companion.c \ - ao_gps_skytraq.c \ - ao_gps_show.c \ - ao_convert_volt.c \ - ao_m25.c - -include ../product/Makefile.telemetrum diff --git a/src/telemini-v1.0/.gitignore b/src/telemini-v1.0/.gitignore deleted file mode 100644 index 82868aac..00000000 --- a/src/telemini-v1.0/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -telemini-* -ao_product.h diff --git a/src/telemini-v1.0/.sdcdbrc b/src/telemini-v1.0/.sdcdbrc deleted file mode 100644 index 2c77e32b..00000000 --- a/src/telemini-v1.0/.sdcdbrc +++ /dev/null @@ -1,2 +0,0 @@ ---directory=../cc1111:../product:../kernel:../drivers:. - diff --git a/src/telemini-v1.0/Makefile b/src/telemini-v1.0/Makefile deleted file mode 100644 index 4f1c8b51..00000000 --- a/src/telemini-v1.0/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# -# TeleMini build file -# - -TELEMINI_VER=1.0 -TELEMINI_DEF=1_0 - -include ../product/Makefile.telemini diff --git a/src/telemini-v2.0/.gitignore b/src/telemini-v2.0/.gitignore deleted file mode 100644 index 568925a2..00000000 --- a/src/telemini-v2.0/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -ao_product.h -telemini-v2.0* diff --git a/src/telemini-v2.0/.sdcdbrc b/src/telemini-v2.0/.sdcdbrc deleted file mode 100644 index 2c77e32b..00000000 --- a/src/telemini-v2.0/.sdcdbrc +++ /dev/null @@ -1,2 +0,0 @@ ---directory=../cc1111:../product:../kernel:../drivers:. - diff --git a/src/telemini-v2.0/Makefile b/src/telemini-v2.0/Makefile deleted file mode 100644 index 8657e9a9..00000000 --- a/src/telemini-v2.0/Makefile +++ /dev/null @@ -1,116 +0,0 @@ -# -# TeleMini build file -# - -TELEMINI_VER=2.0 -TELEMINI_DEF=2_0 - -vpath %.c ..:../kernel:../cc1111:../drivers:../product -vpath %.h ..:../kernel:../cc1111:../drivers:../product -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - ao_arch.h \ - ao_arch_funcs.h \ - cc1111.h \ - ao_ms5607.h \ - ao_ms5607_convert_8051.c \ - ao_product.h \ - ao_int64.h \ - ao_sample.h \ - ao_exti.h \ - ao_task.h \ - altitude-pa-small.h - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_flight.c \ - ao_kalman.c \ - ao_log.c \ - ao_log_mini.c \ - ao_mutex.c \ - ao_panic.c \ - ao_report.c \ - ao_sample.c \ - ao_stdio.c \ - ao_storage.c \ - ao_task.c \ - ao_telemetry.c \ - ao_freq.c \ - ao_int64.c - -CC1111_SRC = \ - ao_adc.c \ - ao_dma.c \ - ao_ignite.c \ - ao_led.c \ - ao_packet.c \ - ao_packet_slave.c \ - ao_radio.c \ - ao_romconfig.c \ - ao_string.c \ - ao_spi.c \ - ao_usb.c \ - ao_convert_pa.c \ - ao_convert_volt.c \ - ao_beep.c \ - ao_timer.c \ - ao_exti.c \ - _bp.c - -DRIVER_SRC = \ - ao_ms5607.c \ - ao_m25.c - -PRODUCT_SRC = \ - ao_telemini.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) - -PROGNAME = telemini-v$(TELEMINI_VER) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TeleMini-v$(TELEMINI_VER) -PRODUCT_DEF=-DTELEMINI_V_$(TELEMINI_DEF) -IDPRODUCT=0x0027 - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: - diff --git a/src/telemini-v2.0/ao_pins.h b/src/telemini-v2.0/ao_pins.h deleted file mode 100644 index d2aa4c2d..00000000 --- a/src/telemini-v2.0/ao_pins.h +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_PINS_H_ -#define _AO_PINS_H_ - -#define HAS_RADIO 1 - -#define HAS_FLIGHT 1 -#define HAS_USB 1 -#define AO_VALUE_32 0 - -#define HAS_USB_PULLUP 1 -#define AO_USB_PULLUP_PORT P1 -#define AO_USB_PULLUP_PIN 0 -#define AO_USB_PULLUP P1_0 - -#define AO_SMALL_ALTITUDE_TABLE 1 - -#define USB_FORCE_FLIGHT_IDLE 1 -#define HAS_BEEP 1 -#define HAS_BEEP_CONFIG 1 -#define HAS_BATTERY_REPORT 1 -#define HAS_GPS 0 -#define HAS_SERIAL_1 0 -#define HAS_EEPROM 1 -#define HAS_LOG 1 -#define USE_INTERNAL_FLASH 0 -#define HAS_DBG 0 -#define PACKET_HAS_SLAVE 1 -#define HAS_RADIO_RATE 1 -#define HAS_TELEMETRY 1 -#define HAS_TASK_INFO 0 - -#define AO_LED_RED 2 -#define LEDS_AVAILABLE AO_LED_RED -#define HAS_EXTERNAL_TEMP 0 -#define HAS_ACCEL 0 -#define HAS_IGNITE 1 -#define HAS_IGNITE_REPORT 1 -#define HAS_MONITOR 0 - -/* - * SPI - */ - -#define HAS_SPI_0 1 -#define SPI_0_ALT_1 1 -#define HAS_SPI_1 1 -#define SPI_1_ALT_2 1 -#define SPI_CS_PORT P1 -#define SPI_CS_SEL P1SEL -#define SPI_CS_DIR P1DIR - -/* - * Flash - */ -#define AO_M25_SPI_BUS 1 -#define AO_M25_SPI_CS_PORT SPI_CS_PORT -#define AO_M25_SPI_CS_MASK 0x04 /* cs_flash is P1_2 */ -#define M25_MAX_CHIPS 1 - -/* - * MS5607 - */ - -#define HAS_MS5607 1 -#define HAS_MS5611 0 -#define AO_MS5607_PRIVATE_PINS 0 -#define AO_MS5607_CS_PORT P1 -#define AO_MS5607_CS_PIN 3 -#define AO_MS5607_CS P1_3 -#define AO_MS5607_CS_MASK (1 << AO_MS5607_CS_PIN) -#define AO_MS5607_MISO_PORT P0 -#define AO_MS5607_MISO_PIN 2 -#define AO_MS5607_MISO P0_2 -#define AO_MS5607_MISO_MASK (1 << AO_MS5607_MISO_PIN) -#define AO_MS5607_SPI_INDEX 0 -#define HAS_EXTI_0 1 - -/* - * Igniters - */ -#define AO_IGNITER_PORT P2 -#define AO_IGNITER_DROGUE_PORT AO_IGNITER_PORT -#define AO_IGNITER_DROGUE P2_3 -#define AO_IGNITER_MAIN P2_4 -#define AO_IGNITER_DIR P2DIR -#define AO_IGNITER_DROGUE_BIT (1 << 3) -#define AO_IGNITER_MAIN_BIT (1 << 4) -#define AO_IGNITER_DROGUE_PIN 3 -#define AO_IGNITER_MAIN_PIN 4 - -#define AO_IGNITER_DROGUE_PORT AO_IGNITER_PORT -#define AO_IGNITER_MAIN_PORT AO_IGNITER_PORT - -/* test these values with real igniters */ -#define AO_IGNITER_OPEN 1000 -#define AO_IGNITER_CLOSED 7000 -#define AO_IGNITER_FIRE_TIME AO_MS_TO_TICKS(50) -#define AO_IGNITER_CHARGE_TIME AO_MS_TO_TICKS(2000) - -#define AO_SEND_MINI AO_TELEMETRY_MINI2 -#define AO_LOG_FORMAT AO_LOG_FORMAT_TELEMINI2 - -/* - * ADC - */ - -#define HAS_ADC 1 -#define AO_ADC_FIRST_PIN 0 - -struct ao_adc { - int16_t sense_a; /* apogee continuity sense */ - int16_t sense_m; /* main continuity sense */ - int16_t v_batt; /* battery voltage */ -}; - -#define ao_data_count ao_adc_count - -#define AO_SENSE_DROGUE(p) ((p)->adc.sense_a) -#define AO_SENSE_MAIN(p) ((p)->adc.sense_m) - -#define AO_NUM_TASKS 10 - -#define AO_ADC_DUMP(p) \ - printf("tick: %5u apogee: %5d main: %5d batt: %5d\n", \ - (p)->tick, (p)->adc.sense_a, (p)->adc.sense_m, (p)->adc.v_batt) - -#define AO_ADC_PINS ((1 << 0) | (1 << 1) | (1 << 4)) - -#define FETCH_ADC() do { \ - a = (uint8_t __xdata *) (&ao_data_ring[ao_data_head].adc); \ - switch (sequence) { \ - case 4: \ - a += 4; \ - sequence = 0; \ - break; \ - case 1: \ - a += 2; \ - sequence = 4; \ - break; \ - case 0: \ - sequence = 1; \ - break; \ - } \ - a[0] = ADCL; \ - a[1] = ADCH; \ - if (sequence) { \ - ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | sequence; \ - return; \ - } \ - AO_DATA_PRESENT(AO_DATA_ADC); \ - if (ao_data_present != AO_DATA_ALL) \ - return; \ - ao_data_ring[ao_data_head].ms5607_raw.pres = ao_ms5607_current.pres; \ - ao_data_ring[ao_data_head].ms5607_raw.temp = ao_ms5607_current.temp; \ - } while (0) - -/* - * Voltage divider on ADC battery sampler - */ -#define AO_BATTERY_DIV_PLUS 100 /* 100k */ -#define AO_BATTERY_DIV_MINUS 27 /* 27k */ - -/* - * Voltage divider on ADC igniter samplers - */ -#define AO_IGNITE_DIV_PLUS 100 /* 100k */ -#define AO_IGNITE_DIV_MINUS 27 /* 27k */ - -/* - * ADC reference in decivolts - */ -#define AO_ADC_REFERENCE_DV 33 - -#endif /* _AO_PINS_H_ */ diff --git a/src/telemini-v2.0/ao_telemini.c b/src/telemini-v2.0/ao_telemini.c deleted file mode 100644 index a9ee423c..00000000 --- a/src/telemini-v2.0/ao_telemini.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" -#include "ao_pins.h" -#include - -void -main(void) -{ - ao_clock_init(); - -#if HAS_STACK_GUARD - ao_mpu_init(); -#endif - ao_task_init(); - - /* Turn on the red LED until the system is stable */ - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_RED); - - ao_timer_init(); - - ao_spi_init(); - ao_exti_init(); - ao_adc_init(); -#if HAS_BEEP - ao_beep_init(); -#endif - ao_cmd_init(); -#if HAS_MS5607 - ao_ms5607_init(); -#endif - ao_storage_init(); - - ao_flight_init(); - ao_log_init(); - ao_report_init(); - - ao_usb_init(); - ao_telemetry_init(); - ao_radio_init(); - ao_packet_slave_init(TRUE); - - ao_igniter_init(); - - ao_config_init(); - ao_start_scheduler(); -} diff --git a/src/telenano-v0.1/.gitignore b/src/telenano-v0.1/.gitignore deleted file mode 100644 index 0412f7df..00000000 --- a/src/telenano-v0.1/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -telenano-* -ao_product.h diff --git a/src/telenano-v0.1/.sdcdbrc b/src/telenano-v0.1/.sdcdbrc deleted file mode 100644 index 710b4a2f..00000000 --- a/src/telenano-v0.1/.sdcdbrc +++ /dev/null @@ -1 +0,0 @@ ---directory=.. diff --git a/src/telenano-v0.1/Makefile b/src/telenano-v0.1/Makefile deleted file mode 100644 index 2714c1e9..00000000 --- a/src/telenano-v0.1/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# -# TeleNano build file -# - -TELENANO_VER=0.1 -TELENANO_DEF=0_1 - -include ../product/Makefile.telenano - diff --git a/src/telerepeat-v1.0/.gitignore b/src/telerepeat-v1.0/.gitignore deleted file mode 100644 index 4bb125bc..00000000 --- a/src/telerepeat-v1.0/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -telerepeat-* -ao_product.h diff --git a/src/telerepeat-v1.0/.sdcdbrc b/src/telerepeat-v1.0/.sdcdbrc deleted file mode 100644 index 2c77e32b..00000000 --- a/src/telerepeat-v1.0/.sdcdbrc +++ /dev/null @@ -1,2 +0,0 @@ ---directory=../cc1111:../product:../kernel:../drivers:. - diff --git a/src/telerepeat-v1.0/Makefile b/src/telerepeat-v1.0/Makefile deleted file mode 100644 index 17f68377..00000000 --- a/src/telerepeat-v1.0/Makefile +++ /dev/null @@ -1,100 +0,0 @@ -# -# TeleRepeat build file -# - -TELEREPEAT_VER=1.0 -TELEREPEAT_DEF=1_0 - -vpath %.c ..:../kernel:../cc1111:../drivers:../product -vpath %.h ..:../kernel:../cc1111:../drivers:../product -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - ao_arch.h \ - ao_arch_funcs.h \ - cc1111.h \ - ao_product.h - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_monitor.c \ - ao_mutex.c \ - ao_panic.c \ - ao_state.c \ - ao_stdio.c \ - ao_task.c \ - ao_forward.c \ - ao_storage.c \ - ao_freq.c - -CC1111_SRC = \ - ao_dbg.c \ - ao_adc.c \ - ao_dma.c \ - ao_led.c \ - ao_packet.c \ - ao_intflash.c \ - ao_packet_master.c \ - ao_radio.c \ - ao_romconfig.c \ - ao_serial.c \ - ao_string.c \ - ao_timer.c \ - ao_usb.c \ - _bp.c - -DRIVER_SRC = \ - ao_btm.c - -PRODUCT_SRC = \ - ao_telerepeat.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) - -PROGNAME = telerepeat-v$(TELEREPEAT_VER) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TeleRepeat-v$(TELEREPEAT_VER) -PRODUCT_DEF=-DTELEREPEAT_V_$(TELEREPEAT_DEF) -IDPRODUCT=0x000e -CODESIZE=0x7800 - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: diff --git a/src/telerepeat-v1.0/ao_pins.h b/src/telerepeat-v1.0/ao_pins.h deleted file mode 100644 index e47d368c..00000000 --- a/src/telerepeat-v1.0/ao_pins.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_PINS_H_ -#define _AO_PINS_H_ - -#define HAS_RADIO 1 -#define HAS_RADIO_FORWARD 1 -#define HAS_FLIGHT 0 -#define HAS_USB 1 -#define HAS_BEEP 0 -#define HAS_SERIAL_1 1 -#define HAS_SERIAL_1_ALT_1 1 -#define HAS_SERIAL_1_ALT_2 0 -#define HAS_SERIAL_1_HW_FLOW 1 -#define USE_SERIAL_1_STDIN 1 -#define DELAY_SERIAL_1_STDIN 1 -#define HAS_DBG 1 -#define HAS_EEPROM 1 -#define HAS_LOG 0 -#define USE_INTERNAL_FLASH 1 -#define HAS_BTM 1 -#define DBG_ON_P1 1 -#define DBG_ON_P0 0 -#define PACKET_HAS_MASTER 1 -#define PACKET_HAS_SLAVE 0 -#define AO_LED_RED 1 -#define AO_LED_BLUE 2 -#define LEDS_AVAILABLE (AO_LED_RED|AO_LED_BLUE) -#define AO_MONITOR_LED AO_LED_RED -#define AO_BT_LED AO_LED_BLUE -#define BT_LINK_ON_P2 0 -#define BT_LINK_ON_P1 1 -#define BT_LINK_PIN_INDEX 7 -#define BT_LINK_PIN P1_7 -#define HAS_MONITOR 1 -#define HAS_MONITOR_PUT 1 -#define LEGACY_MONITOR 0 -#define HAS_TELEMETRY 0 -#define AO_RADIO_REG_TEST 1 - -#define HAS_ADC 1 -#define AO_PAD_ADC_BATT 0 -#define AO_ADC_PINS (1 << AO_PAD_ADC_BATT) - -struct ao_adc { - int16_t batt; -}; - -#define AO_ADC_DUMP(p) \ - printf ("tick: %5u batt %5d\n", \ - (p)->tick, \ - (p)->adc.batt) - -#define FETCH_ADC() do { \ - a = (uint8_t __xdata *) (&ao_data_ring[ao_data_head].adc.batt); \ - a[0] = ADCL; \ - a[1] = ADCH; \ - } while (0) - -#if DBG_ON_P1 - - #define DBG_CLOCK (1 << 4) /* mi0 */ - #define DBG_DATA (1 << 5) /* mo0 */ - #define DBG_RESET_N (1 << 3) /* c0 */ - - #define DBG_CLOCK_PIN (P1_4) - #define DBG_DATA_PIN (P1_5) - #define DBG_RESET_N_PIN (P1_3) - - #define DBG_PORT_NUM 1 - #define DBG_PORT P1 - #define DBG_PORT_SEL P1SEL - #define DBG_PORT_INP P1INP - #define DBG_PORT_DIR P1DIR - -#endif /* DBG_ON_P1 */ - -#if DBG_ON_P0 - - #define DBG_CLOCK (1 << 3) - #define DBG_DATA (1 << 4) - #define DBG_RESET_N (1 << 5) - - #define DBG_CLOCK_PIN (P0_3) - #define DBG_DATA_PIN (P0_4) - #define DBG_RESET_N_PIN (P0_5) - - #define DBG_PORT_NUM 0 - #define DBG_PORT P0 - #define DBG_PORT_SEL P0SEL - #define DBG_PORT_INP P0INP - #define DBG_PORT_DIR P0DIR - -#endif /* DBG_ON_P0 */ - -#endif /* _AO_PINS_H_ */ diff --git a/src/telerepeat-v1.0/ao_telerepeat.c b/src/telerepeat-v1.0/ao_telerepeat.c deleted file mode 100644 index 43a5ed42..00000000 --- a/src/telerepeat-v1.0/ao_telerepeat.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" -#include "ao_forward.h" - -void -main(void) -{ - ao_clock_init(); - - /* Turn on the LED until the system is stable */ - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_RED); - - ao_task_init(); - - ao_timer_init(); - ao_cmd_init(); - ao_usb_init(); - ao_monitor_init(); - ao_radio_init(); - ao_packet_master_init(); - ao_adc_init(); - ao_btm_init(); - ao_monitor_forward_init(); - ao_storage_init(); -#if HAS_DBG - ao_dbg_init(); -#endif - ao_config_init(); - ao_start_scheduler(); -} diff --git a/src/teleshield-v0.1/.gitignore b/src/teleshield-v0.1/.gitignore deleted file mode 100644 index 3ae78d33..00000000 --- a/src/teleshield-v0.1/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -teleshield-* -ao_product.h diff --git a/src/teleshield-v0.1/Makefile b/src/teleshield-v0.1/Makefile deleted file mode 100644 index f54488a2..00000000 --- a/src/teleshield-v0.1/Makefile +++ /dev/null @@ -1,111 +0,0 @@ -# -# TeleShield build file -# -# The various telemetrum versions differ only -# in which flash and GPS drivers are included, -# so the per-board makefiles simply define -# TM_VER, TM_DEF, TM_INC and TM_SRC and include -# this file - -TELESHIELD_VER=0.1 -TELESHIELD_DEF=0_1 - -TELESHIELD_INC = - -TELESHIELD_SRC = \ - ao_beep.c \ - ao_btm.c \ - ao_spi.c - -vpath %.c ..:../kernel:../cc1111:../drivers:../product:. -vpath %.h ..:../kernel:../cc1111:../drivers:../product:. -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - cc1111.h \ - ao_product.h \ - $(TELESHIELD_INC) - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_monitor.c \ - ao_mutex.c \ - ao_panic.c \ - ao_state.c \ - ao_storage.c \ - ao_stdio.c \ - ao_task.c \ - ao_freq.c - -CC1111_SRC = \ - ao_dbg.c \ - ao_dma.c \ - ao_led.c \ - ao_intflash.c \ - ao_packet.c \ - ao_packet_slave.c \ - ao_radio.c \ - ao_romconfig.c \ - ao_serial.c \ - ao_string.c \ - ao_timer.c \ - ao_usb.c \ - _bp.c - -DRIVER_SRC = \ - $(TELESHIELD_SRC) - -PRODUCT_SRC = \ - ao_teleshield.c \ - ao_ardu_serial.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) - -PROGNAME = teleshield-v$(TELESHIELD_VER) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TeleShield-v$(TELESHIELD_VER) -PRODUCT_DEF=-DTELESHIELD_V_$(TELESHIELD_DEF) -IDPRODUCT=0x0013 -CODESIZE=0x7800 - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: - diff --git a/src/teleshield-v0.1/ao_ardu_serial.c b/src/teleshield-v0.1/ao_ardu_serial.c deleted file mode 100644 index 535cc624..00000000 --- a/src/teleshield-v0.1/ao_ardu_serial.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -static void -ao_ardu_serial_recv(void) -{ - char c; - - for (;;) { - if (ao_fifo_empty(ao_serial0_rx_fifo)) - flush(); - c = ao_serial0_getchar(); - putchar (c); - } -} - -static __xdata struct ao_task ao_ardu_serial_recv_task; - -void -ao_ardu_serial_init (void) -{ - ao_add_task(&ao_ardu_serial_recv_task, ao_ardu_serial_recv, "recv"); -} diff --git a/src/teleshield-v0.1/ao_pins.h b/src/teleshield-v0.1/ao_pins.h deleted file mode 100644 index 6baa88c8..00000000 --- a/src/teleshield-v0.1/ao_pins.h +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_PINS_H_ -#define _AO_PINS_H_ - -#if defined(TELESHIELD_V_0_1) - #define HAS_FLIGHT 0 - #define HAS_USB 1 - #define HAS_BEEP 0 - #define HAS_SERIAL_1 1 - #define HAS_SERIAL_1_ALT_1 1 - #define HAS_SERIAL_1_ALT_2 0 - #define HAS_SERIAL_1_HW_FLOW 1 - #define USE_SERIAL_1_STDIN 1 - #define HAS_SERIAL_0 1 - #define HAS_SERIAL_0_ALT_1 0 - #define HAS_SERIAL_0_ALT_2 1 - #define HAS_SERIAL_0_HW_FLOW 0 - #define HAS_ADC 0 - #define HAS_DBG 1 - #define HAS_EEPROM 1 - #define HAS_LOG 0 - #define USE_INTERNAL_FLASH 1 - #define HAS_BTM 1 - #define DBG_ON_P1 1 - #define DBG_ON_P0 0 - #define IGNITE_ON_P2 0 - #define IGNITE_ON_P0 0 - #define PACKET_HAS_MASTER 0 - #define PACKET_HAS_SLAVE 1 - #define AO_LED_RED 1 - #define AO_LED_GREEN 2 - #define AO_MONITOR_LED AO_LED_RED - #define AO_BT_LED AO_LED_GREEN - #define LEDS_AVAILABLE (AO_LED_RED|AO_LED_GREEN) - #define SPI_CS_ON_P1 1 - #define SPI_CS_ON_P0 0 - #define HAS_ACCEL 0 - #define HAS_IGNITE 0 - #define HAS_IGNITE_REPORT 0 - #define BT_LINK_ON_P2 0 - #define BT_LINK_ON_P1 1 - #define BT_LINK_PIN_INDEX 7 - #define BT_LINK_PIN P1_7 - #define HAS_MONITOR 1 - #define LEGACY_MONITOR 0 - #define HAS_RSSI 0 - #define HAS_AES 0 - #define HAS_RADIO 1 - #define HAS_TELEMETRY 0 -#endif - -#if DBG_ON_P1 - - #define DBG_CLOCK (1 << 4) /* mi0 */ - #define DBG_DATA (1 << 5) /* mo0 */ - #define DBG_RESET_N (1 << 3) /* c0 */ - - #define DBG_CLOCK_PIN (P1_4) - #define DBG_DATA_PIN (P1_5) - #define DBG_RESET_N_PIN (P1_3) - - #define DBG_PORT_NUM 1 - #define DBG_PORT P1 - #define DBG_PORT_SEL P1SEL - #define DBG_PORT_INP P1INP - #define DBG_PORT_DIR P1DIR - -#endif /* DBG_ON_P1 */ - -#if DBG_ON_P0 - - #define DBG_CLOCK (1 << 3) - #define DBG_DATA (1 << 4) - #define DBG_RESET_N (1 << 5) - - #define DBG_CLOCK_PIN (P0_3) - #define DBG_DATA_PIN (P0_4) - #define DBG_RESET_N_PIN (P0_5) - - #define DBG_PORT_NUM 0 - #define DBG_PORT P0 - #define DBG_PORT_SEL P0SEL - #define DBG_PORT_INP P0INP - #define DBG_PORT_DIR P0DIR - -#endif /* DBG_ON_P0 */ - -#if COMPANION_CS_ON_P1 - #define COMPANION_CS_PORT P1 - #define COMPANION_CS_SEL P1SEL - #define COMPANION_CS_DIR P1DIR -#endif - -#if SPI_CS_ON_P1 - #define SPI_CS_PORT P1 - #define SPI_CS_SEL P1SEL - #define SPI_CS_DIR P1DIR -#endif - -#if SPI_CS_ON_P0 - #define SPI_CS_PORT P0 - #define SPI_CS_SEL P0SEL - #define SPI_CS_DIR P0DIR -#endif - -#ifndef IGNITE_ON_P2 -#error Please define IGNITE_ON_P2 -#endif - -#ifndef IGNITE_ON_P0 -#error Please define IGNITE_ON_P0 -#endif - -#ifndef HAS_SERIAL_1 -#error Please define HAS_SERIAL_1 -#endif - -#ifndef HAS_ADC -#error Please define HAS_ADC -#endif - -#ifndef HAS_EEPROM -#error Please define HAS_EEPROM -#endif - -#ifndef HAS_LOG -#error Please define HAS_LOG -#endif - -#if HAS_EEPROM -#ifndef USE_INTERNAL_FLASH -#error Please define USE_INTERNAL_FLASH -#endif -#endif - -#ifndef HAS_DBG -#error Please define HAS_DBG -#endif - -#ifndef HAS_IGNITE -#error Please define HAS_IGNITE -#endif - -#if HAS_IGNITE -#define HAS_IGNITE_REPORT 1 -#endif - -#ifndef PACKET_HAS_MASTER -#error Please define PACKET_HAS_MASTER -#endif - -#ifndef PACKET_HAS_SLAVE -#error Please define PACKET_HAS_SLAVE -#endif - -#ifndef HAS_MONITOR -#error Please define HAS_MONITOR -#endif - -#if HAS_MONITOR -#ifndef HAS_RSSI -#error Please define HAS_RSSI -#endif -#endif - -#ifndef HAS_ADC -#error Please define HAS_ADC -#endif - -#if HAS_ADC - -#if HAS_ACCEL -#ifndef HAS_ACCEL_REF -#error Please define HAS_ACCEL_REF -#endif -#else -#define HAS_ACCEL_REF 0 -#endif - -#endif /* HAS_ADC */ - -#if IGNITE_ON_P2 -#define AO_IGNITER_DROGUE P2_3 -#define AO_IGNITER_MAIN P2_4 -#define AO_IGNITER_DIR P2DIR -#define AO_IGNITER_DROGUE_BIT (1 << 3) -#define AO_IGNITER_MAIN_BIT (1 << 4) -#endif - -#if IGNITE_ON_P0 -#define AO_IGNITER_DROGUE P0_5 -#define AO_IGNITER_MAIN P0_4 -#define AO_IGNITER_DIR P0DIR -#define AO_IGNITER_DROGUE_BIT (1 << 5) -#define AO_IGNITER_MAIN_BIT (1 << 4) -#endif - -/* test these values with real igniters */ -#define AO_IGNITER_OPEN 1000 -#define AO_IGNITER_CLOSED 7000 -#define AO_IGNITER_FIRE_TIME AO_MS_TO_TICKS(50) -#define AO_IGNITER_CHARGE_TIME AO_MS_TO_TICKS(2000) - -void -ao_ardu_serial_init (void); - - -#endif /* _AO_PINS_H_ */ diff --git a/src/teleshield-v0.1/ao_teleshield.c b/src/teleshield-v0.1/ao_teleshield.c deleted file mode 100644 index 713c49f9..00000000 --- a/src/teleshield-v0.1/ao_teleshield.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include "ao.h" - -#if 0 -__code uint8_t ao_log_format = AO_LOG_FORMAT_NONE; /* until we actually log stuff */ -#endif - -void -main(void) -{ - ao_clock_init(); - - /* Turn on the LED until the system is stable */ - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_RED); - ao_task_init(); - ao_timer_init(); - ao_cmd_init(); - ao_spi_init(); - ao_storage_init(); - ao_usb_init(); - ao_monitor_init(); - ao_radio_init(); - ao_packet_slave_init(1); - ao_btm_init(); -#if HAS_DBG - ao_dbg_init(); -#endif -#if HAS_AES - ao_aes_init(); - ao_radio_cmac_init(); -#endif - ao_serial_init(); - ao_ardu_serial_init(); - ao_config_init(); - ao_start_scheduler(); -} diff --git a/src/teleterra-v0.2/.gitignore b/src/teleterra-v0.2/.gitignore deleted file mode 100644 index 9daebc3e..00000000 --- a/src/teleterra-v0.2/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -teleterra-v0.2* -ao_product.h diff --git a/src/teleterra-v0.2/.sdcdbrc b/src/teleterra-v0.2/.sdcdbrc deleted file mode 100644 index e9a51ea6..00000000 --- a/src/teleterra-v0.2/.sdcdbrc +++ /dev/null @@ -1 +0,0 @@ ---directory=../cc1111:../product:../kernel:../drivers:. diff --git a/src/teleterra-v0.2/Makefile b/src/teleterra-v0.2/Makefile deleted file mode 100644 index 826c52e5..00000000 --- a/src/teleterra-v0.2/Makefile +++ /dev/null @@ -1,105 +0,0 @@ -# -# TeleTerra build file -# - -vpath %.c ..:../kernel:../cc1111:../drivers:../product -vpath %.h ..:../kernel:../cc1111:../drivers:../product -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - cc1111.h \ - ao_product.h - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_monitor.c \ - ao_log_single.c \ - ao_log_telem.c \ - ao_mutex.c \ - ao_panic.c \ - ao_report.c \ - ao_sqrt.c \ - ao_stdio.c \ - ao_storage.c \ - ao_task.c \ - ao_freq.c - -CC1111_SRC = \ - ao_battery.c \ - ao_beep.c \ - ao_button.c \ - ao_dbg.c \ - ao_dma.c \ - ao_packet.c \ - ao_packet_master.c \ - ao_radio.c \ - ao_romconfig.c \ - ao_serial.c \ - ao_spi.c \ - ao_string.c \ - ao_timer.c \ - ao_usb.c \ - ao_lcd_port.c \ - _bp.c - -DRIVER_SRC = \ - ao_m25.c \ - ao_lcd.c \ - ao_gps_skytraq.c \ - ao_gps_show.c - -PRODUCT_SRC = \ - ao_teleterra_0_2.c \ - ao_terraui.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) - -TELETERRA_VER=0.2 -TELETERRA_DEF=0_2 -PROGNAME = teleterra-v$(TELETERRA_VER) -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TeleTerra-v$(TELETERRA_VER) -PRODUCT_DEF=-DTELETERRA_V_$(TELETERRA_DEF) -IDPRODUCT=0x000d - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: - diff --git a/src/teleterra-v0.2/ao_pins.h b/src/teleterra-v0.2/ao_pins.h deleted file mode 100644 index 5bcf2c8a..00000000 --- a/src/teleterra-v0.2/ao_pins.h +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_PINS_H_ -#define _AO_PINS_H_ - -#ifdef TELETERRA_V_0_2 - #define HAS_FLIGHT 0 - #define HAS_USB 1 - #define HAS_RADIO 1 - #define HAS_BEEP 1 - #define HAS_GPS 1 - #define HAS_SERIAL_1 1 - #define HAS_ADC 0 - #define HAS_LCD 1 - #define HAS_EEPROM 1 - #define HAS_LOG 1 - #define USE_INTERNAL_FLASH 0 - #define HAS_DBG 1 - #define DBG_ON_P1 1 - #define DBG_ON_P0 0 - #define IGNITE_ON_P2 0 - #define IGNITE_ON_P0 0 - #define PACKET_HAS_MASTER 1 - #define PACKET_HAS_SLAVE 0 - #define HAS_RADIO_CHANNELS 1 - - #define HAS_COMPANION 0 - - #define AO_MONITOR_LED 0 - #define LEDS_AVAILABLE 0 - #define HAS_EXTERNAL_TEMP 0 - #define HAS_ACCEL_REF 0 - #define HAS_ACCEL 0 - #define HAS_IGNITE 0 - #define HAS_MONITOR 1 - #define HAS_MONITOR_PUT 1 - #define LEGACY_MONITOR 0 - #define HAS_RSSI 0 - #define HAS_AES 0 - - #define SPI_CS_ON_P1 1 - #define SPI_CS_ON_P0 0 - #define M25_CS_MASK 0x04 - #define M25_MAX_CHIPS 1 - - #define HAS_BUTTON 1 - #define BUTTON_1_REG 0 - #define BUTTON_1_MASK (1 << 4) /* P0_4 */ - - #define BUTTON_2_REG 2 - #define BUTTON_2_MASK (1 << 3) /* P2_3 */ - - #define BUTTON_3_REG 2 - #define BUTTON_3_MASK (1 << 4) /* P2_4 */ - - #define HAS_P2_ISR 1 - - #define BATTERY_PIN 5 - #define HAS_TELEMETRY 0 - - #define AO_VALUE_32 0 - - #define AO_LOG_FORMAT AO_LOG_FORMAT_TELEMETRY -#endif - -#if DBG_ON_P1 - - #define DBG_CLOCK (1 << 4) /* mi0 */ - #define DBG_DATA (1 << 5) /* mo0 */ - #define DBG_RESET_N (1 << 3) /* c0 */ - - #define DBG_CLOCK_PIN (P1_4) - #define DBG_DATA_PIN (P1_5) - #define DBG_RESET_N_PIN (P1_3) - - #define DBG_PORT_NUM 1 - #define DBG_PORT P1 - #define DBG_PORT_SEL P1SEL - #define DBG_PORT_INP P1INP - #define DBG_PORT_DIR P1DIR - -#endif /* DBG_ON_P1 */ - -#if DBG_ON_P0 - - #define DBG_CLOCK (1 << 3) - #define DBG_DATA (1 << 4) - #define DBG_RESET_N (1 << 5) - - #define DBG_CLOCK_PIN (P0_3) - #define DBG_DATA_PIN (P0_4) - #define DBG_RESET_N_PIN (P0_5) - - #define DBG_PORT_NUM 0 - #define DBG_PORT P0 - #define DBG_PORT_SEL P0SEL - #define DBG_PORT_INP P0INP - #define DBG_PORT_DIR P0DIR - -#endif /* DBG_ON_P0 */ - -#if COMPANION_CS_ON_P1 - #define COMPANION_CS_PORT P1 - #define COMPANION_CS_SEL P1SEL - #define COMPANION_CS_DIR P1DIR -#endif - -#if SPI_CS_ON_P1 - #define SPI_CS_PORT P1 - #define SPI_CS_SEL P1SEL - #define SPI_CS_DIR P1DIR -#endif - -#if SPI_CS_ON_P0 - #define SPI_CS_PORT P0 - #define SPI_CS_SEL P0SEL - #define SPI_CS_DIR P0DIR -#endif - -#ifndef IGNITE_ON_P2 -#error Please define IGNITE_ON_P2 -#endif - -#ifndef IGNITE_ON_P0 -#error Please define IGNITE_ON_P0 -#endif - -#ifndef HAS_SERIAL_1 -#error Please define HAS_SERIAL_1 -#endif - -#ifndef HAS_ADC -#error Please define HAS_ADC -#endif - -#ifndef HAS_EEPROM -#error Please define HAS_EEPROM -#endif - -#ifndef HAS_LOG -#error Please define HAS_LOG -#endif - -#if HAS_EEPROM -#ifndef USE_INTERNAL_FLASH -#error Please define USE_INTERNAL_FLASH -#endif -#endif - -#ifndef HAS_DBG -#error Please define HAS_DBG -#endif - -#ifndef HAS_IGNITE -#error Please define HAS_IGNITE -#endif - -#if HAS_IGNITE -#define HAS_IGNITE_REPORT 1 -#endif - -#ifndef PACKET_HAS_MASTER -#error Please define PACKET_HAS_MASTER -#endif - -#ifndef PACKET_HAS_SLAVE -#error Please define PACKET_HAS_SLAVE -#endif - -#ifndef HAS_MONITOR -#error Please define HAS_MONITOR -#endif - -#if HAS_MONITOR -#ifndef HAS_RSSI -#error Please define HAS_RSSI -#endif -#endif - -#ifndef HAS_ADC -#error Please define HAS_ADC -#endif - -#if HAS_ADC - -#if HAS_ACCEL -#ifndef HAS_ACCEL_REF -#error Please define HAS_ACCEL_REF -#endif -#else -#define HAS_ACCEL_REF 0 -#endif - -#endif /* HAS_ADC */ - -#if IGNITE_ON_P2 -#define AO_IGNITER_DROGUE P2_3 -#define AO_IGNITER_MAIN P2_4 -#define AO_IGNITER_DIR P2DIR -#define AO_IGNITER_DROGUE_BIT (1 << 3) -#define AO_IGNITER_MAIN_BIT (1 << 4) -#endif - -#if IGNITE_ON_P0 -#define AO_IGNITER_DROGUE P0_5 -#define AO_IGNITER_MAIN P0_4 -#define AO_IGNITER_DIR P0DIR -#define AO_IGNITER_DROGUE_BIT (1 << 5) -#define AO_IGNITER_MAIN_BIT (1 << 4) -#endif - -/* test these values with real igniters */ -#define AO_IGNITER_OPEN 1000 -#define AO_IGNITER_CLOSED 7000 -#define AO_IGNITER_FIRE_TIME AO_MS_TO_TICKS(50) -#define AO_IGNITER_CHARGE_TIME AO_MS_TO_TICKS(2000) - -#define AO_M25_SPI_CS_PORT SPI_CS_PORT -#define AO_M25_SPI_CS_MASK M25_CS_MASK - -#endif /* _AO_PINS_H_ */ diff --git a/src/tidongle/.gitignore b/src/tidongle/.gitignore deleted file mode 100644 index 3888a0f9..00000000 --- a/src/tidongle/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -tidongle* -ao_product.h diff --git a/src/tidongle/Makefile b/src/tidongle/Makefile deleted file mode 100644 index 0e90d744..00000000 --- a/src/tidongle/Makefile +++ /dev/null @@ -1,91 +0,0 @@ -# -# TIDongle build file -# - -vpath %.c ..:../kernel:../cc1111:../drivers:../product -vpath %.h ..:../kernel:../cc1111:../drivers:../product -vpath ao-make-product.5c ../util - -ifndef VERSION -include ../Version -endif - -INC = \ - ao.h \ - ao_pins.h \ - cc1111.h \ - ao_product.h - -CORE_SRC = \ - ao_cmd.c \ - ao_config.c \ - ao_gps_print.c \ - ao_monitor.c \ - ao_mutex.c \ - ao_panic.c \ - ao_rssi.c \ - ao_state.c \ - ao_stdio.c \ - ao_task.c \ - ao_freq.c - -CC1111_SRC = \ - ao_dbg.c \ - ao_dma.c \ - ao_led.c \ - ao_packet.c \ - ao_packet_master.c \ - ao_radio.c \ - ao_romconfig.c \ - ao_string.c \ - ao_timer.c \ - ao_usb.c \ - _bp.c - -DRIVER_SRC = - -PRODUCT_SRC = \ - ao_tidongle.c - -SRC = \ - $(CORE_SRC) \ - $(CC1111_SRC) \ - $(DRIVER_SRC) \ - $(PRODUCT_SRC) - -PROGNAME = tidongle -PROG = $(PROGNAME)-$(VERSION).ihx -PRODUCT=TIDongle -PRODUCT_DEF=-DTIDONGLE -IDPRODUCT=0x000a - -include ../cc1111/Makefile.cc1111 - -NICKLE=nickle -CHECK_STACK=sh ../util/check-stack - -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -all: $(PROG) - -$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) - $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: clean-cc1111 - -install: - -uninstall: - diff --git a/telegps/Makefile.am b/telegps/Makefile.am index 106ce55a..3443b288 100644 --- a/telegps/Makefile.am +++ b/telegps/Makefile.am @@ -102,14 +102,12 @@ LINUX_MIMETYPE =\ $(ICONDIR)/org-altusmetrum-mimetypes.xml # Firmware -FIRMWARE_TD_0_2=$(top_srcdir)/src/teledongle-v0.2/teledongle-v0.2-$(VERSION).ihx FIRMWARE_TD_3_0=$(top_srcdir)/src/teledongle-v3.0/teledongle-v3.0-$(VERSION).ihx -FIRMWARE_TD=$(FIRMWARE_TD_0_2) $(FIRMWARE_TD_3_0) +FIRMWARE_TD=$(FIRMWARE_TD_3_0) -FIRMWARE_TBT_1_0=$(top_srcdir)/src/telebt-v1.0/telebt-v1.0-$(VERSION).ihx FIRMWARE_TBT_3_0=$(top_srcdir)/src/telebt-v3.0/telebt-v3.0-$(VERSION).ihx FIRMWARE_TBT_4_0=$(top_srcdir)/src/telebt-v4.0/telebt-v4.0-$(VERSION).ihx -FIRMWARE_TBT=$(FIRMWARE_TBT_1_0) $(FIRMWARE_TBT_3_0) $(FIRMWARE_TBT_4_0) +FIRMWARE_TBT=$(FIRMWARE_TBT_3_0) $(FIRMWARE_TBT_4_0) FIRMWARE_TG_1_0=$(top_srcdir)/src/telegps-v1.0/telegps-v1.0-$(VERSION).ihx FIRMWARE_TG_2_0=$(top_srcdir)/src/telegps-v2.0/telegps-v2.0-$(VERSION).ihx diff --git a/telegps/telegps-windows.nsi.in b/telegps/telegps-windows.nsi.in index e6ce9f84..c83b21c5 100644 --- a/telegps/telegps-windows.nsi.in +++ b/telegps/telegps-windows.nsi.in @@ -122,9 +122,7 @@ Section "TeleGPS, TeleDongle and TeleBT Firmware" File "../src/telegps-v1.0/telegps-v1.0-${VERSION}.ihx" File "../src/telegps-v2.0/telegps-v2.0-${VERSION}.ihx" - File "../src/teledongle-v0.2/teledongle-v0.2-${VERSION}.ihx" File "../src/teledongle-v3.0/teledongle-v3.0-${VERSION}.ihx" - File "../src/telebt-v1.0/telebt-v1.0-${VERSION}.ihx" File "../src/telebt-v3.0/telebt-v3.0-${VERSION}.ihx" File "../src/telebt-v4.0/telebt-v4.0-${VERSION}.ihx"