summaryrefslogtreecommitdiff
path: root/src/stmf0
diff options
context:
space:
mode:
Diffstat (limited to 'src/stmf0')
-rw-r--r--src/stmf0/Makefile-stmf0.defs7
-rw-r--r--src/stmf0/altos-loader.ld4
-rw-r--r--src/stmf0/altos-raw.ld4
-rw-r--r--src/stmf0/altos.ld4
-rw-r--r--src/stmf0/ao_adc_stm.c23
-rw-r--r--src/stmf0/ao_arch.h19
-rw-r--r--src/stmf0/ao_arch_funcs.h14
-rw-r--r--src/stmf0/ao_beep_stm.c4
-rw-r--r--src/stmf0/ao_interrupt.c4
-rw-r--r--src/stmf0/ao_led_stmf0.c (renamed from src/stmf0/ao_led.c)45
-rw-r--r--src/stmf0/ao_romconfig.c28
-rw-r--r--src/stmf0/ao_storage_stm.c6
-rw-r--r--src/stmf0/ao_timer.c4
-rw-r--r--src/stmf0/ao_usb_stm.c2
14 files changed, 52 insertions, 116 deletions
diff --git a/src/stmf0/Makefile-stmf0.defs b/src/stmf0/Makefile-stmf0.defs
index 4e9fa551..447ddf13 100644
--- a/src/stmf0/Makefile-stmf0.defs
+++ b/src/stmf0/Makefile-stmf0.defs
@@ -28,15 +28,16 @@ CC=$(ARM_CC)
WARN_FLAGS=-Wall -Wextra -Werror -Wcast-align
AO_CFLAGS=-I. -I$(TOPDIR)/stmf0 -I$(TOPDIR)/kernel -I$(TOPDIR)/drivers \
- -I$(TOPDIR)/product -I$(TOPDIR) -I$(TOPDIR)/math -I$(TOPDIR)/lisp \
- $(PDCLIB_INCLUDES)
+ -DNEWLIB_INTEGER_PRINTF_SCANF \
+ -I$(TOPDIR)/product -I$(TOPDIR) -I$(TOPDIR)/math \
+ -isystem $(NEWLIB_NANO)/arm-none-eabi/include
STMF0_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m0 -mthumb\
-ffreestanding -nostdlib $(AO_CFLAGS) $(WARN_FLAGS)
NICKLE=nickle
-LIBS=$(PDCLIB_LIBS_M0) -lgcc
+LIBS=-L$(NEWLIB_NANO)/arm-none-eabi/lib/thumb/v6-m -lc -lm -lgcc
V=0
# The user has explicitly enabled quiet compilation.
diff --git a/src/stmf0/altos-loader.ld b/src/stmf0/altos-loader.ld
index 05887d0e..4d9b81ae 100644
--- a/src/stmf0/altos-loader.ld
+++ b/src/stmf0/altos-loader.ld
@@ -66,7 +66,7 @@ SECTIONS {
*/
.textram BLOCK(8): {
- __data_start__ = .;
+ _start__ = .;
__text_ram_start__ = .;
*(.ramtext)
__text_ram_end = .;
@@ -77,7 +77,7 @@ SECTIONS {
*/
.data BLOCK(8): {
*(.data) /* initialized data */
- __data_end__ = .;
+ _end__ = .;
} >ram AT>rom
diff --git a/src/stmf0/altos-raw.ld b/src/stmf0/altos-raw.ld
index eb285e07..90c42ad2 100644
--- a/src/stmf0/altos-raw.ld
+++ b/src/stmf0/altos-raw.ld
@@ -61,10 +61,10 @@ SECTIONS {
/* Data -- relocated to RAM, but written to ROM
*/
.data : {
- __data_start__ = .;
+ _start__ = .;
*(.data) /* initialized data */
. = ALIGN(4);
- __data_end__ = .;
+ _end__ = .;
} >ram AT>rom
.bss : {
diff --git a/src/stmf0/altos.ld b/src/stmf0/altos.ld
index 74fdf3ea..64e1d00c 100644
--- a/src/stmf0/altos.ld
+++ b/src/stmf0/altos.ld
@@ -81,10 +81,10 @@ SECTIONS {
/* Data -- relocated to RAM, but written to ROM
*/
.data : {
- __data_start__ = .;
+ _start__ = .;
*(.data) /* initialized data */
. = ALIGN(4);
- __data_end__ = .;
+ _end__ = .;
} >ram AT>rom
.bss : {
diff --git a/src/stmf0/ao_adc_stm.c b/src/stmf0/ao_adc_stm.c
index 2b23dc50..d48726a1 100644
--- a/src/stmf0/ao_adc_stm.c
+++ b/src/stmf0/ao_adc_stm.c
@@ -38,23 +38,7 @@ static void ao_adc_done(int index)
AO_DATA_PRESENT(AO_DATA_ADC);
ao_dma_done_transfer(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC_1));
- if (ao_data_present == AO_DATA_ALL) {
-#if HAS_MS5607
- ao_data_ring[ao_data_head].ms5607_raw = ao_ms5607_current;
-#endif
-#if HAS_MMA655X
- ao_data_ring[ao_data_head].mma655x = ao_mma655x_current;
-#endif
-#if HAS_HMC5883
- ao_data_ring[ao_data_head].hmc5883 = ao_hmc5883_current;
-#endif
-#if HAS_MPU6000
- ao_data_ring[ao_data_head].mpu6000 = ao_mpu6000_current;
-#endif
- ao_data_ring[ao_data_head].tick = ao_tick_count;
- ao_data_head = ao_data_ring_next(ao_data_head);
- ao_wakeup((void *) &ao_data_head);
- }
+ ao_data_fill(ao_data_head);
ao_adc_ready = 1;
}
@@ -103,10 +87,9 @@ ao_adc_one(void)
int ch;
uint16_t value;
- ao_cmd_decimal();
+ ch = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- ch = ao_cmd_lex_i;
if (ch < 0 || AO_NUM_ADC <= ch) {
ao_cmd_status = ao_cmd_syntax_error;
return;
@@ -180,7 +163,7 @@ ao_adc_one(void)
}
#endif
-__code struct ao_cmds ao_adc_cmds[] = {
+const struct ao_cmds ao_adc_cmds[] = {
{ ao_adc_dump, "a\0Display current ADC values" },
#if AO_ADC_DEBUG
{ ao_adc_one, "A ch\0Display one ADC channel" },
diff --git a/src/stmf0/ao_arch.h b/src/stmf0/ao_arch.h
index 5c5085d9..22e706b2 100644
--- a/src/stmf0/ao_arch.h
+++ b/src/stmf0/ao_arch.h
@@ -43,11 +43,6 @@
#define ao_arch_naked_declare __attribute__((naked))
#define ao_arch_naked_define
-#define __pdata
-#define __data
-#define __xdata
-#define __code const
-#define __reentrant
#define __interrupt(n)
#define __at(n)
@@ -59,23 +54,11 @@
#define ao_arch_interrupt(n) /* nothing */
-#undef putchar
-#undef getchar
-#define putchar(c) ao_putchar(c)
-#define getchar ao_getchar
-
-extern void putchar(char c);
-extern char getchar(void);
-extern void ao_avr_stdio_init(void);
-
-
/*
* ao_romconfig.c
*/
-#define AO_ROMCONFIG_VERSION 2
-
-#define AO_ROMCONFIG_SYMBOL(a) __attribute__((section(".romconfig"))) const
+#define AO_ROMCONFIG_SYMBOL __attribute__((section(".romconfig"))) const
extern const uint16_t ao_romconfig_version;
extern const uint16_t ao_romconfig_check;
diff --git a/src/stmf0/ao_arch_funcs.h b/src/stmf0/ao_arch_funcs.h
index 96c033f9..70f273d3 100644
--- a/src/stmf0/ao_arch_funcs.h
+++ b/src/stmf0/ao_arch_funcs.h
@@ -168,8 +168,8 @@ ao_spi_try_get_mask(struct stm_gpio *reg, uint16_t mask, uint8_t bus, uint32_t s
ao_spi_put(bus); \
} while (0)
-#define ao_spi_get_bit(reg,bit,pin,bus,speed) ao_spi_get_mask(reg,(1<<bit),bus,speed)
-#define ao_spi_put_bit(reg,bit,pin,bus) ao_spi_put_mask(reg,(1<<bit),bus)
+#define ao_spi_get_bit(reg,bit,bus,speed) ao_spi_get_mask(reg,(1<<bit),bus,speed)
+#define ao_spi_put_bit(reg,bit,bus) ao_spi_put_mask(reg,(1<<bit),bus)
#if AO_POWER_MANAGEMENT
extern struct ao_power ao_power_gpioa;
@@ -212,13 +212,13 @@ static inline void ao_disable_port(struct stm_gpio *port)
}
}
-#define ao_gpio_set(port, bit, pin, v) stm_gpio_set(port, bit, v)
+#define ao_gpio_set(port, bit, v) stm_gpio_set(port, bit, v)
-#define ao_gpio_get(port, bit, pin) stm_gpio_get(port, bit)
+#define ao_gpio_get(port, bit) stm_gpio_get(port, bit)
-#define ao_enable_output(port,bit,pin,v) do { \
+#define ao_enable_output(port,bit,v) do { \
ao_enable_port(port); \
- ao_gpio_set(port, bit, pin, v); \
+ ao_gpio_set(port, bit, v); \
stm_moder_set(port, bit, STM_MODER_OUTPUT);\
} while (0)
@@ -238,7 +238,7 @@ static inline void ao_disable_port(struct stm_gpio *port)
} while (0)
#define ao_enable_cs(port,bit) do { \
- ao_enable_output(port, bit, pin, 1); \
+ ao_enable_output(port, bit, 1); \
} while (0)
#define ao_spi_init_cs(port, mask) do { \
diff --git a/src/stmf0/ao_beep_stm.c b/src/stmf0/ao_beep_stm.c
index 15137230..31af7f4a 100644
--- a/src/stmf0/ao_beep_stm.c
+++ b/src/stmf0/ao_beep_stm.c
@@ -376,7 +376,7 @@ ao_beep(uint8_t beep)
}
void
-ao_beep_for(uint8_t beep, uint16_t ticks) __reentrant
+ao_beep_for(uint8_t beep, uint16_t ticks)
{
ao_beep(beep);
ao_delay(ticks);
@@ -386,7 +386,7 @@ ao_beep_for(uint8_t beep, uint16_t ticks) __reentrant
void
ao_beep_init(void)
{
- ao_enable_output(BEEPER_PORT, BEEPER_PIN, BEEPER, 0);
+ ao_enable_output(BEEPER_PORT, BEEPER_PIN, 0);
/* Leave the timer off until requested */
stm_rcc_enr &= ~(1 << STM_RCC_TIMER);
diff --git a/src/stmf0/ao_interrupt.c b/src/stmf0/ao_interrupt.c
index a67f6f1a..81878d89 100644
--- a/src/stmf0/ao_interrupt.c
+++ b/src/stmf0/ao_interrupt.c
@@ -35,7 +35,7 @@
extern void main(void);
extern char __stack__;
extern char __text_start__, __text_end__;
-extern char __data_start__, __data_end__;
+extern char _start__, _end__;
extern char __bss_start__, __bss_end__;
#if RELOCATE_INTERRUPT
extern char __interrupt_rom__, __interrupt_start__, __interrupt_end__;
@@ -88,7 +88,7 @@ void start(void)
stm_syscfg.cfgr1 = (stm_syscfg.cfgr1 & ~(STM_SYSCFG_CFGR1_MEM_MODE_MASK << STM_SYSCFG_CFGR1_MEM_MODE)) |
(STM_SYSCFG_CFGR1_MEM_MODE_MAIN_FLASH << STM_SYSCFG_CFGR1_MEM_MODE);
#endif
- memcpy(&__data_start__, &__text_end__, &__data_end__ - &__data_start__);
+ memcpy(&_start__, &__text_end__, &_end__ - &_start__);
memset(&__bss_start__, '\0', &__bss_end__ - &__bss_start__);
main();
}
diff --git a/src/stmf0/ao_led.c b/src/stmf0/ao_led_stmf0.c
index 0f39befb..1564535e 100644
--- a/src/stmf0/ao_led.c
+++ b/src/stmf0/ao_led_stmf0.c
@@ -18,65 +18,63 @@
#include "ao.h"
-__pdata uint16_t ao_led_enable;
-
void
-ao_led_on(uint16_t colors)
+ao_led_on(AO_LED_TYPE colors)
{
#ifdef LED_PORT
- LED_PORT->bsrr = (colors & ao_led_enable);
+ LED_PORT->bsrr = (colors & LEDS_AVAILABLE);
#else
#ifdef LED_PORT_0
- LED_PORT_0->bsrr = ((colors & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
+ LED_PORT_0->bsrr = ((colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
#endif
#ifdef LED_PORT_1
- LED_PORT_1->bsrr = ((colors & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+ LED_PORT_1->bsrr = ((colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
#endif
#endif
}
void
-ao_led_off(uint16_t colors)
+ao_led_off(AO_LED_TYPE colors)
{
#ifdef LED_PORT
- LED_PORT->bsrr = (uint32_t) (colors & ao_led_enable) << 16;
+ LED_PORT->bsrr = (uint32_t) (colors & LEDS_AVAILABLE) << 16;
#else
#ifdef LED_PORT_0
- LED_PORT_0->bsrr = ((uint32_t) (colors & ao_led_enable) & LED_PORT_0_MASK) << (LED_PORT_0_SHIFT + 16);
+ LED_PORT_0->bsrr = ((uint32_t) (colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << (LED_PORT_0_SHIFT + 16);
#endif
#ifdef LED_PORT_1
- LED_PORT_1->bsrr = ((uint32_t) (colors & ao_led_enable) & LED_PORT_1_MASK) << (LED_PORT_1_SHIFT + 16);
+ LED_PORT_1->bsrr = ((uint32_t) (colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << (LED_PORT_1_SHIFT + 16);
#endif
#endif
}
void
-ao_led_set(uint16_t colors)
+ao_led_set(AO_LED_TYPE colors)
{
- uint16_t on = colors & ao_led_enable;
- uint16_t off = ~colors & ao_led_enable;
+ AO_LED_TYPE on = colors & LEDS_AVAILABLE;
+ AO_LED_TYPE off = ~colors & LEDS_AVAILABLE;
ao_led_off(off);
ao_led_on(on);
}
void
-ao_led_toggle(uint16_t colors)
+ao_led_toggle(AO_LED_TYPE colors)
{
#ifdef LED_PORT
- LED_PORT->odr ^= (colors & ao_led_enable);
+ LED_PORT->odr ^= (colors & LEDS_AVAILABLE);
#else
#ifdef LED_PORT_0
- LED_PORT_0->odr ^= ((colors & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
+ LED_PORT_0->odr ^= ((colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
#endif
#ifdef LED_PORT_1
- LED_PORT_1->odr ^= ((colors & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+ LED_PORT_1->odr ^= ((colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
#endif
#endif
}
void
-ao_led_for(uint16_t colors, uint16_t ticks) __reentrant
+ao_led_for(AO_LED_TYPE colors, AO_TICK_TYPE ticks)
{
ao_led_on(colors);
ao_delay(ticks);
@@ -89,26 +87,25 @@ ao_led_for(uint16_t colors, uint16_t ticks) __reentrant
} while (0)
void
-ao_led_init(uint16_t enable)
+ao_led_init(void)
{
int bit;
- ao_led_enable = enable;
#ifdef LED_PORT
stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE);
- LED_PORT->odr &= ~enable;
+ LED_PORT->odr &= ~LEDS_AVAILABLE;
#else
#ifdef LED_PORT_0
stm_rcc.ahbenr |= (1 << LED_PORT_0_ENABLE);
- LED_PORT_0->odr &= ~((enable & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
+ LED_PORT_0->odr &= (uint32_t) ~(LEDS_AVAILABLE & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
#endif
#ifdef LED_PORT_1
stm_rcc.ahbenr |= (1 << LED_PORT_1_ENABLE);
- LED_PORT_1->odr &= ~((enable & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+ LED_PORT_1->odr &= (uint32_t) ~(LEDS_AVAILABLE & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
#endif
#endif
for (bit = 0; bit < 16; bit++) {
- if (enable & (1 << bit)) {
+ if (LEDS_AVAILABLE & (1 << bit)) {
#ifdef LED_PORT
init_led_pin(LED_PORT, bit);
#else
diff --git a/src/stmf0/ao_romconfig.c b/src/stmf0/ao_romconfig.c
deleted file mode 100644
index 9d5fd6fb..00000000
--- a/src/stmf0/ao_romconfig.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright © 2011 Keith Packard <keithp@keithp.com>
- *
- * 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"
-
-AO_ROMCONFIG_SYMBOL (0) uint16_t ao_romconfig_version = AO_ROMCONFIG_VERSION;
-AO_ROMCONFIG_SYMBOL (0) uint16_t ao_romconfig_check = ~AO_ROMCONFIG_VERSION;
-AO_ROMCONFIG_SYMBOL (0) uint16_t ao_serial_number = 0;
-#ifndef AO_RADIO_CAL_DEFAULT
-#define AO_RADIO_CAL_DEFAULT 0x01020304
-#endif
-AO_ROMCONFIG_SYMBOL (0) uint32_t ao_radio_cal = AO_RADIO_CAL_DEFAULT;
-
diff --git a/src/stmf0/ao_storage_stm.c b/src/stmf0/ao_storage_stm.c
index 1a6198a7..17c934a5 100644
--- a/src/stmf0/ao_storage_stm.c
+++ b/src/stmf0/ao_storage_stm.c
@@ -157,7 +157,7 @@ ao_storage_device_write(uint32_t pos, void *v, uint16_t len)
}
uint8_t
-ao_storage_device_read(uint32_t pos, __xdata void *d, uint16_t len) __reentrant
+ao_storage_device_read(uint32_t pos, void *d, uint16_t len)
{
if (pos >= ao_storage_total || pos + len > ao_storage_total)
return 0;
@@ -166,7 +166,7 @@ ao_storage_device_read(uint32_t pos, __xdata void *d, uint16_t len) __reentrant
}
void
-ao_storage_flush(void) __reentrant
+ao_storage_flush(void)
{
}
@@ -179,7 +179,7 @@ ao_storage_setup(void)
}
void
-ao_storage_device_info(void) __reentrant
+ao_storage_device_info(void)
{
printf ("Using internal flash, page %d bytes, total %d bytes\n",
ao_storage_block, ao_storage_total);
diff --git a/src/stmf0/ao_timer.c b/src/stmf0/ao_timer.c
index 50fd67b8..1def5f69 100644
--- a/src/stmf0/ao_timer.c
+++ b/src/stmf0/ao_timer.c
@@ -36,8 +36,8 @@ ao_time(void)
}
#if AO_DATA_ALL
-volatile __data uint8_t ao_data_interval = 1;
-volatile __data uint8_t ao_data_count;
+volatile uint8_t ao_data_interval = 1;
+volatile uint8_t ao_data_count;
#endif
void stm_systick_isr(void)
diff --git a/src/stmf0/ao_usb_stm.c b/src/stmf0/ao_usb_stm.c
index c4860d8e..ff294849 100644
--- a/src/stmf0/ao_usb_stm.c
+++ b/src/stmf0/ao_usb_stm.c
@@ -1626,7 +1626,7 @@ ao_usb_irq(void)
control_count, out_count, in_count, int_count, reset_count);
}
-__code struct ao_cmds ao_usb_cmds[] = {
+const struct ao_cmds ao_usb_cmds[] = {
{ ao_usb_irq, "I\0Show USB interrupt counts" },
{ 0, NULL }
};