summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBdale Garbee <bdale@gag.com>2018-10-20 01:18:12 -0600
committerBdale Garbee <bdale@gag.com>2018-10-20 01:18:12 -0600
commit0686a7b8aec524d81bda4c572549a3a068ce0eed (patch)
tree2e6061c834b99e3b9668be8b3cfb1627251365d3
parent6aa451ce81bfdfe679e3f9902043a5f0d235c745 (diff)
parentcc528f1ff0271ec6488a1a7b91c731183502101e (diff)
Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
-rw-r--r--.gitmodules3
-rw-r--r--Makefile.am6
-rw-r--r--Releasing2
-rw-r--r--altoslib/AltosAdxl375.java93
-rw-r--r--altoslib/AltosCalData.java26
-rw-r--r--altoslib/AltosConfigData.java16
-rw-r--r--altoslib/AltosIdleFetch.java12
-rw-r--r--altoslib/Makefile.am1
-rw-r--r--altosui/Makefile.am19
-rw-r--r--altosui/altos-windows.nsi.in7
-rw-r--r--configure.ac100
-rw-r--r--doc/updating-firmware.inc6
m---------pdclib0
-rw-r--r--src/Makedefs.in10
-rw-r--r--src/Makefile28
-rw-r--r--src/aes/ao_aes.c6
-rw-r--r--src/attiny/ao_arch.h10
-rw-r--r--src/attiny/ao_arch_funcs.h20
-rw-r--r--src/attiny/ao_i2c_attiny.c4
-rw-r--r--src/attiny/ao_led.c64
-rw-r--r--src/attiny/ao_led_tiny.c (renamed from src/cc1111/ao_led.c)21
-rw-r--r--src/attiny/ao_spi_attiny.c4
-rw-r--r--src/avr-demo/Makefile2
-rw-r--r--src/avr/ao_adc_avr.c12
-rw-r--r--src/avr/ao_arch.h6
-rw-r--r--src/avr/ao_arch_funcs.h16
-rw-r--r--src/avr/ao_eeprom_avr.c20
-rw-r--r--src/avr/ao_i2c_usart.c6
-rw-r--r--src/avr/ao_led_avr.c (renamed from src/avr/ao_led.c)4
-rw-r--r--src/avr/ao_pwmin.c8
-rw-r--r--src/avr/ao_pwmin.h2
-rw-r--r--src/avr/ao_serial_avr.c10
-rw-r--r--src/avr/ao_spi_usart.c6
-rw-r--r--src/avr/ao_timer.c8
-rw-r--r--src/avr/ao_usb_avr.c46
-rw-r--r--src/cc1111/Makefile.cc111139
-rw-r--r--src/cc1111/_bp.c26
-rw-r--r--src/cc1111/ao_adc.c239
-rw-r--r--src/cc1111/ao_aes.c147
-rw-r--r--src/cc1111/ao_arch.h338
-rw-r--r--src/cc1111/ao_arch_funcs.h152
-rw-r--r--src/cc1111/ao_battery.c61
-rw-r--r--src/cc1111/ao_beep.c53
-rw-r--r--src/cc1111/ao_button.c159
-rw-r--r--src/cc1111/ao_dbg.c334
-rw-r--r--src/cc1111/ao_dma.c131
-rw-r--r--src/cc1111/ao_exti.c34
-rw-r--r--src/cc1111/ao_intflash.c212
-rw-r--r--src/cc1111/ao_launch.c212
-rw-r--r--src/cc1111/ao_launch.h44
-rw-r--r--src/cc1111/ao_lcd_port.c51
-rw-r--r--src/cc1111/ao_pins.h655
-rw-r--r--src/cc1111/ao_radio.c689
-rw-r--r--src/cc1111/ao_reboot.c29
-rw-r--r--src/cc1111/ao_romconfig.c33
-rw-r--r--src/cc1111/ao_serial.c392
-rw-r--r--src/cc1111/ao_spi.c339
-rw-r--r--src/cc1111/ao_string.c51
-rw-r--r--src/cc1111/ao_timer.c145
-rw-r--r--src/cc1111/ao_usb.c489
-rw-r--r--src/cc1111/cc1111.h1390
-rw-r--r--src/chaoskey-v0.1/Makefile2
-rw-r--r--src/chaoskey-v1.0/Makefile2
-rw-r--r--src/chaoskey-v1.0/ao_chaoskey.c2
-rw-r--r--src/cortexelf-v1/ao_cortexelf.c17
-rw-r--r--src/cortexelf-v1/cortexelf.ld4
-rw-r--r--src/detherm/Makefile2
-rw-r--r--src/draw/ao_line.c16
-rw-r--r--src/drivers/ao_25lc1024.c30
-rw-r--r--src/drivers/ao_74hc165.c2
-rw-r--r--src/drivers/ao_74hc497.c2
-rw-r--r--src/drivers/ao_adxl375.c263
-rw-r--r--src/drivers/ao_adxl375.h107
-rw-r--r--src/drivers/ao_aprs.c4
-rw-r--r--src/drivers/ao_at24c.c12
-rw-r--r--src/drivers/ao_at45db161d.c40
-rw-r--r--src/drivers/ao_btm.c37
-rw-r--r--src/drivers/ao_button.c5
-rw-r--r--src/drivers/ao_cc1120.c7
-rw-r--r--src/drivers/ao_cc115l.c6
-rw-r--r--src/drivers/ao_cc1200.c26
-rw-r--r--src/drivers/ao_companion.c22
-rw-r--r--src/drivers/ao_fat.c2
-rw-r--r--src/drivers/ao_gps_sirf.c42
-rw-r--r--src/drivers/ao_gps_skytraq.c52
-rw-r--r--src/drivers/ao_gps_ublox.c36
-rw-r--r--src/drivers/ao_hmc5883.c8
-rw-r--r--src/drivers/ao_lcd.c2
-rw-r--r--src/drivers/ao_lco.c6
-rw-r--r--src/drivers/ao_lco.h2
-rw-r--r--src/drivers/ao_lco_cmd.c34
-rw-r--r--src/drivers/ao_lco_func.c4
-rw-r--r--src/drivers/ao_lco_two.c6
-rw-r--r--src/drivers/ao_led.c174
-rw-r--r--src/drivers/ao_m25.c22
-rw-r--r--src/drivers/ao_mma655x.c10
-rw-r--r--src/drivers/ao_mpu6000.c10
-rw-r--r--src/drivers/ao_mpu9250.c28
-rw-r--r--src/drivers/ao_mr25.c22
-rw-r--r--src/drivers/ao_ms5607.c46
-rw-r--r--src/drivers/ao_ms5607.h10
-rw-r--r--src/drivers/ao_ms5607_convert_8051.c4
-rw-r--r--src/drivers/ao_packet.c24
-rw-r--r--src/drivers/ao_packet_master.c12
-rw-r--r--src/drivers/ao_packet_slave.c2
-rw-r--r--src/drivers/ao_pad.c80
-rw-r--r--src/drivers/ao_pca9922.c10
-rw-r--r--src/drivers/ao_ps2.c8
-rw-r--r--src/drivers/ao_pyro_slave.c2
-rw-r--r--src/drivers/ao_quadrature.c5
-rw-r--r--src/drivers/ao_quadrature.h2
-rw-r--r--src/drivers/ao_radio_master.c26
-rw-r--r--src/drivers/ao_radio_slave.c8
-rw-r--r--src/drivers/ao_rn4678.c28
-rw-r--r--src/drivers/ao_sdcard.c4
-rw-r--r--src/drivers/ao_seven_segment.c6
-rw-r--r--src/drivers/ao_trng_send.c12
-rw-r--r--src/drivers/ao_watchdog.c14
-rw-r--r--src/easymega-v1.0/Makefile20
-rw-r--r--src/easymega-v1.0/ao_easymega.c2
-rw-r--r--src/easymega-v1.0/ao_pins.h7
-rw-r--r--src/easymega-v2.0/Makefile (renamed from src/telescience-v0.2/Makefile)66
-rw-r--r--src/easymega-v2.0/ao_easymega.c (renamed from src/telemini-v2.0/ao_telemini.c)56
-rw-r--r--src/easymega-v2.0/ao_pins.h354
-rw-r--r--src/easymega-v2.0/flash-loader/Makefile (renamed from src/megadongle-v0.1/flash-loader/Makefile)3
-rw-r--r--src/easymega-v2.0/flash-loader/ao_pins.h (renamed from src/telescience-v0.2/flash-loader/ao_pins.h)12
-rw-r--r--src/easymini-v1.0/ao_pins.h2
-rw-r--r--src/easymini-v2.0/ao_pins.h2
-rw-r--r--src/fox1ihu/Makefile2
-rw-r--r--src/fox1ihu/ao_fox1ihu.c2
-rw-r--r--src/kernel/ao.h145
-rw-r--r--src/kernel/ao_aes.h8
-rw-r--r--src/kernel/ao_balloon.c14
-rw-r--r--src/kernel/ao_beep.h2
-rw-r--r--src/kernel/ao_cmd.c113
-rw-r--r--src/kernel/ao_companion.h10
-rw-r--r--src/kernel/ao_config.c211
-rw-r--r--src/kernel/ao_config.h8
-rw-r--r--src/kernel/ao_convert.c6
-rw-r--r--src/kernel/ao_data.c8
-rw-r--r--src/kernel/ao_data.h78
-rw-r--r--src/kernel/ao_ee_fake.c4
-rw-r--r--src/kernel/ao_eeprom.h4
-rw-r--r--src/kernel/ao_fake_flight.c14
-rw-r--r--src/kernel/ao_flight.c40
-rw-r--r--src/kernel/ao_flight.h14
-rw-r--r--src/kernel/ao_flight_nano.c20
-rw-r--r--src/kernel/ao_forward.c8
-rw-r--r--src/kernel/ao_forward.h2
-rw-r--r--src/kernel/ao_freq.c8
-rw-r--r--src/kernel/ao_gps_print.c6
-rw-r--r--src/kernel/ao_gps_report.c8
-rw-r--r--src/kernel/ao_gps_report_mega.c8
-rw-r--r--src/kernel/ao_gps_report_metrum.c8
-rw-r--r--src/kernel/ao_gps_show.c2
-rw-r--r--src/kernel/ao_host.h14
-rw-r--r--src/kernel/ao_ignite.c28
-rw-r--r--src/kernel/ao_int64.c16
-rw-r--r--src/kernel/ao_int64.h16
-rw-r--r--src/kernel/ao_kalman.c24
-rw-r--r--src/kernel/ao_led.h204
-rw-r--r--src/kernel/ao_log.c43
-rw-r--r--src/kernel/ao_log.h20
-rw-r--r--src/kernel/ao_log_big.c4
-rw-r--r--src/kernel/ao_log_fireone.c12
-rw-r--r--src/kernel/ao_log_mega.c4
-rw-r--r--src/kernel/ao_log_metrum.c4
-rw-r--r--src/kernel/ao_log_mini.c4
-rw-r--r--src/kernel/ao_log_single.c32
-rw-r--r--src/kernel/ao_log_telem.c16
-rw-r--r--src/kernel/ao_log_telescience.c6
-rw-r--r--src/kernel/ao_log_tiny.c12
-rw-r--r--src/kernel/ao_monitor.c47
-rw-r--r--src/kernel/ao_mutex.c6
-rw-r--r--src/kernel/ao_notask.c4
-rw-r--r--src/kernel/ao_notask.h4
-rw-r--r--src/kernel/ao_packet.h18
-rw-r--r--src/kernel/ao_power.c4
-rw-r--r--src/kernel/ao_product.c2
-rw-r--r--src/kernel/ao_pyro.c59
-rw-r--r--src/kernel/ao_radio_cmac.c14
-rw-r--r--src/kernel/ao_radio_cmac.h6
-rw-r--r--src/kernel/ao_radio_cmac_cmd.c18
-rw-r--r--src/kernel/ao_report.c20
-rw-r--r--src/kernel/ao_report_micro.c8
-rw-r--r--src/kernel/ao_romconfig.c (renamed from src/avr/ao_romconfig.c)7
-rw-r--r--src/kernel/ao_rssi.c8
-rw-r--r--src/kernel/ao_sample.c82
-rw-r--r--src/kernel/ao_sample.h72
-rw-r--r--src/kernel/ao_sample_profile.c2
-rw-r--r--src/kernel/ao_send_packet.c11
-rw-r--r--src/kernel/ao_serial.h16
-rw-r--r--src/kernel/ao_stdio.c49
-rw-r--r--src/kernel/ao_storage.c49
-rw-r--r--src/kernel/ao_storage.h24
-rw-r--r--src/kernel/ao_task.c25
-rw-r--r--src/kernel/ao_task.h28
-rw-r--r--src/kernel/ao_telemetry.c56
-rw-r--r--src/kernel/ao_tracker.c6
-rw-r--r--src/kernel/ao_usb.h6
-rw-r--r--src/lambdakey-v1.0/Makefile19
-rw-r--r--src/lambdakey-v1.0/ao_lambdakey.c15
-rw-r--r--src/lambdakey-v1.0/ao_pins.h8
-rw-r--r--src/lambdakey-v1.0/ao_scheme_os.h20
-rw-r--r--src/lpc/Makefile-lpc.defs5
-rw-r--r--src/lpc/altos-loader.ld4
-rw-r--r--src/lpc/altos-standalone.ld4
-rw-r--r--src/lpc/altos.ld4
-rw-r--r--src/lpc/ao_adc_lpc.c22
-rw-r--r--src/lpc/ao_arch.h22
-rw-r--r--src/lpc/ao_arch_funcs.h18
-rw-r--r--src/lpc/ao_beep_lpc.c2
-rw-r--r--src/lpc/ao_boot_pin.c2
-rw-r--r--src/lpc/ao_interrupt.c4
-rw-r--r--src/lpc/ao_led_lpc.c21
-rw-r--r--src/lpc/ao_romconfig.c26
-rw-r--r--src/lpc/ao_timer_lpc.c6
-rw-r--r--src/lpc/ao_usb_lpc.c8
-rw-r--r--src/math/ef_acos.c84
-rw-r--r--src/math/ef_log.c92
-rw-r--r--src/math/ef_rem_pio2.c193
-rw-r--r--src/math/ef_sqrt.c89
-rw-r--r--src/math/fdlibm.h414
-rw-r--r--src/math/ieeefp.h256
-rw-r--r--src/math/kf_cos.c59
-rw-r--r--src/math/kf_rem_pio2.c209
-rw-r--r--src/math/kf_sin.c49
-rw-r--r--src/math/machine/ieeefp.h382
-rw-r--r--src/math/math.h40
-rw-r--r--src/math/sf_copysign.c50
-rw-r--r--src/math/sf_cos.c62
-rw-r--r--src/math/sf_fabs.c47
-rw-r--r--src/math/sf_floor.c80
-rw-r--r--src/math/sf_scalbn.c86
-rw-r--r--src/math/sf_sin.c62
-rw-r--r--src/megadongle-v0.1/.gitignore2
-rw-r--r--src/megadongle-v0.1/Makefile90
-rw-r--r--src/megadongle-v0.1/ao_megadongle.c55
-rw-r--r--src/megadongle-v0.1/ao_pins.h153
-rw-r--r--src/megadongle-v0.1/flash-loader/ao_pins.h35
-rw-r--r--src/microkite/Makefile2
-rw-r--r--src/micropeak-v2.0/Makefile2
-rw-r--r--src/micropeak-v2.0/ao_micropeak.c2
-rw-r--r--src/micropeak-v2.0/micropeak.ld4
-rw-r--r--src/micropeak/Makefile2
-rw-r--r--src/microsplash/Makefile2
-rw-r--r--src/nanopeak-v0.1/Makefile2
-rw-r--r--src/nucleao-32/Makefile2
-rw-r--r--src/nucleao-32/load.ld4
-rw-r--r--src/pnpservo-v1/Makefile2
-rw-r--r--src/pnpservo-v1/lambda.ld4
-rw-r--r--src/product/Makefile.teledongle98
-rw-r--r--src/product/Makefile.telelaunch100
-rw-r--r--src/product/Makefile.telemetrum113
-rw-r--r--src/product/Makefile.telemini101
-rw-r--r--src/product/Makefile.telenano100
-rw-r--r--src/product/ao_flash_task.c2
-rw-r--r--src/product/ao_micropeak.c2
-rw-r--r--src/product/ao_telemetrum.c2
-rw-r--r--src/product/ao_telemini.c2
-rw-r--r--src/product/ao_telenano.c2
-rw-r--r--src/product/ao_teleterra.c2
-rw-r--r--src/product/ao_terraui.c58
-rw-r--r--src/product/ao_test.c18
-rw-r--r--src/spiradio-v0.1/.gitignore2
-rw-r--r--src/spiradio-v0.1/.sdcdbrc2
-rw-r--r--src/spiradio-v0.1/Makefile92
-rw-r--r--src/spiradio-v0.1/ao_pins.h66
-rw-r--r--src/spiradio-v0.1/ao_spiradio.c40
-rw-r--r--src/stm-bringup/bringup.ld4
-rw-r--r--src/stm-demo/Makefile2
-rw-r--r--src/stm-demo/ao_demo.c4
-rw-r--r--src/stm-scheme-newlib/Makefile2
-rw-r--r--src/stm-scheme-newlib/ao_demo.c2
-rw-r--r--src/stm-vga/Makefile2
-rw-r--r--src/stm-vga/ao_demo.c11
-rw-r--r--src/stm/Makefile-flash.defs10
-rw-r--r--src/stm/Makefile.defs9
-rw-r--r--src/stm/altos-512.ld4
-rw-r--r--src/stm/altos-loader.ld4
-rw-r--r--src/stm/altos-ram.ld4
-rw-r--r--src/stm/altos.ld4
-rw-r--r--src/stm/ao_adc_single_stm.c2
-rw-r--r--src/stm/ao_adc_stm.c27
-rw-r--r--src/stm/ao_arch.h24
-rw-r--r--src/stm/ao_arch_funcs.h30
-rw-r--r--src/stm/ao_beep_stm.c166
-rw-r--r--src/stm/ao_eeprom_stm.c6
-rw-r--r--src/stm/ao_flash_stm_pins.h20
-rw-r--r--src/stm/ao_i2c_stm.c6
-rw-r--r--src/stm/ao_interrupt.c4
-rw-r--r--src/stm/ao_lcd_stm.c9
-rw-r--r--src/stm/ao_led.c216
-rw-r--r--src/stm/ao_led_stm.c144
-rw-r--r--src/stm/ao_pwm_stm.c6
-rw-r--r--src/stm/ao_romconfig.c29
-rw-r--r--src/stm/ao_serial_stm.c8
-rw-r--r--src/stm/ao_spi_stm.c31
-rw-r--r--src/stm/ao_timer.c4
-rw-r--r--src/stm/ao_usb_stm.c2
-rw-r--r--src/stm/stm32l.h15
-rw-r--r--src/stm32f4-disco/.gitignore3
-rw-r--r--src/stm32f4-disco/Makefile81
-rw-r--r--src/stm32f4-disco/ao_disco.c56
-rw-r--r--src/stm32f4-disco/ao_pins.h79
-rw-r--r--src/stm32f4-disco/ao_scheme_os.h70
-rw-r--r--src/stm32f4/Makefile-flash.defs68
-rw-r--r--src/stm32f4/Makefile-raw.defs13
-rw-r--r--src/stm32f4/Makefile-stm32f4.defs52
-rw-r--r--src/stm32f4/Makefile.defs13
-rw-r--r--src/stm32f4/altos-loader.ld97
-rw-r--r--src/stm32f4/altos-raw.ld74
-rw-r--r--src/stm32f4/altos.ld (renamed from src/lambdakey-v1.0/lambda.ld)43
-rw-r--r--src/stm32f4/ao_arch.h141
-rw-r--r--src/stm32f4/ao_arch_funcs.h340
-rw-r--r--src/stm32f4/ao_exti.h (renamed from src/cc1111/ao_exti.h)41
-rw-r--r--src/stm32f4/ao_exti_stm32f4.c162
-rw-r--r--src/stm32f4/ao_interrupt.c290
-rw-r--r--src/stm32f4/ao_serial_stm32f4.c544
-rw-r--r--src/stm32f4/ao_timer.c284
-rw-r--r--src/stm32f4/ao_usart_stm32f4.c350
-rw-r--r--src/stm32f4/ao_usb_gen.c712
-rw-r--r--src/stm32f4/ao_usb_gen.h110
-rw-r--r--src/stm32f4/ao_usb_stm32f4.c1144
-rw-r--r--src/stm32f4/registers.ld75
-rw-r--r--src/stm32f4/stm32f4.h1522
-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
-rw-r--r--src/teleballoon-v1.1/.gitignore2
-rw-r--r--src/teleballoon-v1.1/Makefile119
-rw-r--r--src/teleballoon-v1.1/ao_pins.h231
-rw-r--r--src/teleballoon-v1.1/ao_teleballoon.c82
-rw-r--r--src/teleballoon-v2.0/Makefile6
-rw-r--r--src/teleballoon-v2.0/ao_pins.h6
-rw-r--r--src/teleballoon-v2.0/ao_teleballoon.c9
-rw-r--r--src/telebt-v1.0/.gitignore2
-rw-r--r--src/telebt-v1.0/.sdcdbrc2
-rw-r--r--src/telebt-v1.0/Makefile97
-rw-r--r--src/telebt-v1.0/ao_pins.h104
-rw-r--r--src/telebt-v1.0/ao_telebt.c45
-rw-r--r--src/telebt-v3.0/Makefile2
-rw-r--r--src/telebt-v3.0/ao_telebt.c2
-rw-r--r--src/telebt-v4.0/Makefile2
-rw-r--r--src/telebt-v4.0/ao_telebt.c2
-rw-r--r--src/teledongle-v0.1/.gitignore2
-rw-r--r--src/teledongle-v0.1/.sdcdbrc1
-rw-r--r--src/teledongle-v0.1/Makefile8
-rw-r--r--src/teledongle-v0.2/.gitignore2
-rw-r--r--src/teledongle-v0.2/.sdcdbrc1
-rw-r--r--src/teledongle-v0.2/Makefile8
-rw-r--r--src/teledongle-v1.8/.gitignore2
-rw-r--r--src/teledongle-v1.8/Makefile88
-rw-r--r--src/teledongle-v1.8/ao_pins.h148
-rw-r--r--src/teledongle-v1.8/ao_teledongle.c55
-rw-r--r--src/teledongle-v3.0/ao_teledongle.c2
-rw-r--r--src/telefire-v0.1/.gitignore2
-rw-r--r--src/telefire-v0.1/.sdcdbrc2
-rw-r--r--src/telefire-v0.1/Makefile102
-rw-r--r--src/telefire-v0.1/ao_pins.h136
-rw-r--r--src/telefire-v0.1/ao_telefire.c47
-rw-r--r--src/telefire-v0.2/.gitignore2
-rw-r--r--src/telefire-v0.2/.sdcdbrc2
-rw-r--r--src/telefire-v0.2/Makefile102
-rw-r--r--src/telefire-v0.2/ao_pins.h155
-rw-r--r--src/telefire-v0.2/ao_telefire.c46
-rw-r--r--src/telefireeight-v1.0/ao_pins.h33
-rw-r--r--src/telefireeight-v1.0/ao_telefireeight.c5
-rw-r--r--src/telefireone-v1.0/Makefile2
-rw-r--r--src/telefireone-v1.0/ao_pins.h1
-rw-r--r--src/telefireone-v1.0/ao_telefireone.c5
-rw-r--r--src/telefiretwo-v0.1/Makefile2
-rw-r--r--src/telefiretwo-v0.1/ao_telefiretwo.c5
-rw-r--r--src/telefiretwo-v0.2/Makefile2
-rw-r--r--src/telefiretwo-v0.2/ao_pins.h1
-rw-r--r--src/telegps-v0.1/Makefile2
-rw-r--r--src/telegps-v2.0/Makefile2
-rw-r--r--src/telegps-v2.0/ao_telegps.c7
-rw-r--r--src/telelco-v0.1/.gitignore2
-rw-r--r--src/telelco-v0.1/Makefile99
-rw-r--r--src/telelco-v0.1/ao_lco.c392
-rw-r--r--src/telelco-v0.1/ao_lco.h25
-rw-r--r--src/telelco-v0.1/ao_pins.h226
-rw-r--r--src/telelco-v0.1/ao_telelco.c72
-rw-r--r--src/telelco-v0.2-cc1200/Makefile2
-rw-r--r--src/telelco-v0.2-cc1200/ao_pins.h4
-rw-r--r--src/telelco-v0.2-cc1200/ao_telelco.c7
-rw-r--r--src/telelco-v0.2/Makefile2
-rw-r--r--src/telelco-v0.2/ao_pins.h4
-rw-r--r--src/telelco-v0.2/ao_telelco.c14
-rw-r--r--src/telelco-v0.3/Makefile2
-rw-r--r--src/telelco-v0.3/ao_pins.h4
-rw-r--r--src/telelco-v0.3/ao_telelco.c6
-rw-r--r--src/telelco-v2.0/ao_lco_v2.c10
-rw-r--r--src/telelco-v2.0/ao_pins.h77
-rw-r--r--src/telelco-v2.0/ao_telelco.c6
-rw-r--r--src/telelcotwo-v0.1/Makefile2
-rw-r--r--src/telelcotwo-v0.1/ao_pins.h3
-rw-r--r--src/telelcotwo-v0.1/ao_telelcotwo.c6
-rw-r--r--src/telemega-v0.1/Makefile19
-rw-r--r--src/telemega-v0.1/ao_pins.h7
-rw-r--r--src/telemega-v0.1/ao_telemega.c7
-rw-r--r--src/telemega-v1.0/Makefile20
-rw-r--r--src/telemega-v1.0/ao_pins.h7
-rw-r--r--src/telemega-v1.0/ao_telemega.c4
-rw-r--r--src/telemega-v2.0/Makefile20
-rw-r--r--src/telemega-v2.0/ao_pins.h7
-rw-r--r--src/telemega-v2.0/ao_telemega.c4
-rw-r--r--src/telemega-v3.0/Makefile20
-rw-r--r--src/telemega-v3.0/ao_pins.h7
-rw-r--r--src/telemega-v3.0/ao_telemega.c4
-rw-r--r--src/telemetrum-v0.1-sirf/.gitignore2
-rw-r--r--src/telemetrum-v0.1-sirf/Makefile17
-rw-r--r--src/telemetrum-v0.1-sky/.gitignore2
-rw-r--r--src/telemetrum-v0.1-sky/.sdcdbrc1
-rw-r--r--src/telemetrum-v0.1-sky/Makefile18
-rw-r--r--src/telemetrum-v1.0/.gitignore2
-rw-r--r--src/telemetrum-v1.0/.sdcdbrc1
-rw-r--r--src/telemetrum-v1.0/Makefile17
-rw-r--r--src/telemetrum-v1.1/.gitignore2
-rw-r--r--src/telemetrum-v1.1/.sdcdbrc1
-rw-r--r--src/telemetrum-v1.1/Makefile18
-rw-r--r--src/telemetrum-v1.2/.gitignore2
-rw-r--r--src/telemetrum-v1.2/.sdcdbrc1
-rw-r--r--src/telemetrum-v1.2/Makefile18
-rw-r--r--src/telemetrum-v2.0/Makefile6
-rw-r--r--src/telemetrum-v2.0/ao_pins.h6
-rw-r--r--src/telemetrum-v2.0/ao_telemetrum.c4
-rw-r--r--src/telemetrum-v3.0/Makefile6
-rw-r--r--src/telemetrum-v3.0/ao_pins.h6
-rw-r--r--src/telemetrum-v3.0/ao_telemetrum.c7
-rw-r--r--src/telemini-v1.0/.gitignore2
-rw-r--r--src/telemini-v1.0/.sdcdbrc2
-rw-r--r--src/telemini-v1.0/Makefile8
-rw-r--r--src/telemini-v2.0/.gitignore2
-rw-r--r--src/telemini-v2.0/.sdcdbrc2
-rw-r--r--src/telemini-v2.0/Makefile116
-rw-r--r--src/telemini-v2.0/ao_pins.h192
-rw-r--r--src/telemini-v3.0/ao_pins.h6
-rw-r--r--src/telemini-v3.0/ao_telemini.c4
-rw-r--r--src/telenano-v0.1/.gitignore2
-rw-r--r--src/telenano-v0.1/.sdcdbrc1
-rw-r--r--src/telenano-v0.1/Makefile9
-rw-r--r--src/telepyro-v0.1/.gitignore2
-rw-r--r--src/telepyro-v0.1/Makefile100
-rw-r--r--src/telerepeat-v1.0/.gitignore2
-rw-r--r--src/telerepeat-v1.0/.sdcdbrc2
-rw-r--r--src/telerepeat-v1.0/Makefile100
-rw-r--r--src/telerepeat-v1.0/ao_pins.h112
-rw-r--r--src/telerepeat-v1.0/ao_telerepeat.c48
-rw-r--r--src/telescience-pwm/.gitignore2
-rw-r--r--src/telescience-pwm/Makefile112
-rw-r--r--src/telescience-v0.1/.gitignore2
-rw-r--r--src/telescience-v0.1/Makefile111
-rw-r--r--src/telescience-v0.2/.gitignore2
-rw-r--r--src/telescience-v0.2/ao_pins.h147
-rw-r--r--src/telescience-v0.2/ao_telescience.c54
-rw-r--r--src/telescience-v0.2/flash-loader/Makefile8
-rw-r--r--src/teleshield-v0.1/.gitignore2
-rw-r--r--src/teleshield-v0.1/Makefile111
-rw-r--r--src/teleshield-v0.1/ao_ardu_serial.c40
-rw-r--r--src/teleshield-v0.1/ao_pins.h225
-rw-r--r--src/teleshield-v0.1/ao_teleshield.c54
-rw-r--r--src/teleterra-v0.1/.gitignore2
-rw-r--r--src/teleterra-v0.1/ao_pins.h213
-rw-r--r--src/teleterra-v0.2/.gitignore2
-rw-r--r--src/teleterra-v0.2/.sdcdbrc1
-rw-r--r--src/teleterra-v0.2/Makefile105
-rw-r--r--src/teleterra-v0.2/ao_pins.h237
-rw-r--r--src/test/ao_aes_test.c6
-rw-r--r--src/test/ao_eeprom_read.h6
-rw-r--r--src/test/ao_flight_test.c12
-rw-r--r--src/test/ao_gps_test_skytraq.c4
-rw-r--r--src/test/ao_gps_test_ublox.c4
-rw-r--r--src/test/ao_int64_test.c4
-rw-r--r--src/test/ao_ms5607_convert_test.c4
-rw-r--r--src/tidongle/.gitignore2
-rw-r--r--src/tidongle/Makefile91
-rw-r--r--src/tmgps-v2.0/Makefile2
-rw-r--r--src/usbrelay-v0.1/ao_usbrelay.c7
-rw-r--r--src/usbtrng-v2.0/.gitignore2
-rw-r--r--src/usbtrng-v2.0/Makefile70
-rw-r--r--src/usbtrng-v2.0/ao_pins.h68
-rw-r--r--src/usbtrng-v2.0/ao_usbtrng.c44
-rw-r--r--src/usbtrng-v2.0/flash-loader/.gitignore2
-rw-r--r--src/usbtrng-v2.0/flash-loader/Makefile8
-rw-r--r--src/usbtrng-v2.0/flash-loader/ao_pins.h32
-rw-r--r--src/usbtrng/Makefile70
-rw-r--r--src/usbtrng/ao_pins.h76
-rw-r--r--src/usbtrng/ao_usbtrng.c247
-rw-r--r--src/usbtrng/flash-loader/Makefile8
-rw-r--r--src/usbtrng/flash-loader/ao_pins.h34
-rw-r--r--src/vidtime/ao_vidtime.c4
-rw-r--r--telegps/Makefile.am6
-rw-r--r--telegps/telegps-windows.nsi.in2
506 files changed, 9783 insertions, 17873 deletions
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 719da199..00000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "pdclib"]
- path = pdclib
- url = git://git.gag.com/fw/pdclib
diff --git a/Makefile.am b/Makefile.am
index 89fdd6c9..602226f5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,12 +6,6 @@ MAINTAINERCLEANFILES = ChangeLog
.PHONY: ChangeLog
-all: pdclib/Makefile
-all-recursive: pdclib/Makefile
-
-pdclib/Makefile:
- git submodule update
-
ChangeLog:
(GIT_DIR=$(top_srcdir)/.git git log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) || \
(touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2)
diff --git a/Releasing b/Releasing
index 6540383b..d0db6ac1 100644
--- a/Releasing
+++ b/Releasing
@@ -103,6 +103,7 @@ These are Bdale's notes on how to do a release.
cp src/chaoskey-v1.0/{*.elf,*.ihx,*.bin} \
src/easymega-v1.0/{*.elf,*.ihx} \
+ src/easymega-v2.0/{*.elf,*.ihx} \
src/easymini-v1.0/{*.elf,*.ihx} \
src/easymini-v2.0/{*.elf,*.ihx} \
src/telebt-v3.0/{*.elf,*.ihx} \
@@ -120,6 +121,7 @@ These are Bdale's notes on how to do a release.
~/altusmetrumllc/Binaries/
cp src/chaoskey-v1.0/flash-loader/{*.elf,*.bin} \
src/easymega-v1.0/flash-loader/*.elf \
+ src/easymega-v2.0/flash-loader/*.elf \
src/easymini-v1.0/flash-loader/*.elf \
src/easymini-v2.0/flash-loader/{*.elf,*.bin} \
src/telebt-v3.0/flash-loader/*.elf \
diff --git a/altoslib/AltosAdxl375.java b/altoslib/AltosAdxl375.java
new file mode 100644
index 00000000..2129ed6e
--- /dev/null
+++ b/altoslib/AltosAdxl375.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright © 2012 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.
+ */
+
+package org.altusmetrum.altoslib_13;
+
+import java.util.concurrent.*;
+
+public class AltosAdxl375 implements Cloneable {
+
+ private int accel;
+ private int axis;
+
+ public static final int X_AXIS = 0;
+ public static final int Y_AXIS = 1;
+ public static final int Z_AXIS = 2;
+
+ public boolean parse_line(String line) throws NumberFormatException {
+ if (line.startsWith("ADXL375 value")) {
+ System.out.printf("adxl parse line %s\n", line);
+ String[] items = line.split("\\s+");
+ if (axis == AltosLib.MISSING)
+ throw new NumberFormatException("No ADXL375 axis specified");
+ if (items.length >= 3) {
+ accel = Integer.parseInt(items[2 + axis]);
+ System.out.printf("accel %d\n", accel);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public AltosAdxl375 clone() {
+ AltosAdxl375 n = new AltosAdxl375(axis);
+
+ n.accel = accel;
+ return n;
+ }
+
+ static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException, AltosUnknownProduct {
+ try {
+ AltosCalData cal_data = listener.cal_data();
+ AltosAdxl375 adxl375 = new AltosAdxl375(link, cal_data.adxl375_axis);
+
+ if (adxl375 != null) {
+ int accel = adxl375.accel;
+ if (cal_data.adxl375_inverted)
+ accel = -accel;
+ if (cal_data.pad_orientation == 1)
+ accel = -accel;
+ listener.set_acceleration(cal_data.acceleration(accel));
+ }
+ } catch (TimeoutException te) {
+ } catch (NumberFormatException ne) {
+ }
+ }
+
+ public AltosAdxl375() {
+ accel = AltosLib.MISSING;
+ axis = AltosLib.MISSING;
+ }
+
+ public AltosAdxl375(int axis) {
+ this();
+ this.axis = axis;
+ }
+
+ public AltosAdxl375(AltosLink link, int axis) throws InterruptedException, TimeoutException, NumberFormatException {
+ this(axis);
+ link.printf("A\n");
+ for (;;) {
+ String line = link.get_reply_no_dialog(5000);
+ if (line == null)
+ throw new TimeoutException();
+ if (parse_line(line))
+ break;
+ }
+ }
+}
diff --git a/altoslib/AltosCalData.java b/altoslib/AltosCalData.java
index d448fdfe..c3d79250 100644
--- a/altoslib/AltosCalData.java
+++ b/altoslib/AltosCalData.java
@@ -133,6 +133,18 @@ public class AltosCalData {
mma655x_inverted = inverted;
}
+ public boolean adxl375_inverted = false;
+
+ public void set_adxl375_inverted(boolean inverted) {
+ adxl375_inverted = inverted;
+ }
+
+ public int adxl375_axis = AltosLib.MISSING;
+
+ public void set_adxl375_axis(int axis) {
+ adxl375_axis = axis;
+ }
+
public int pad_orientation = AltosLib.MISSING;
public void set_pad_orientation(int orientation) {
@@ -142,7 +154,11 @@ public class AltosCalData {
/* Compute acceleration */
public double acceleration(double sensor) {
- return AltosConvert.acceleration_from_sensor(sensor, accel_plus_g, accel_minus_g, ground_accel);
+ double accel;
+ accel = AltosConvert.acceleration_from_sensor(sensor, accel_plus_g, accel_minus_g, ground_accel);
+ System.out.printf("acceleration %g (+ %g - %g g %g) -> %g\n",
+ sensor, accel_plus_g, accel_minus_g, ground_accel, accel);
+ return accel;
}
public AltosMs5607 ms5607 = null;
@@ -404,6 +420,14 @@ public class AltosCalData {
set_mma655x_inverted(config_data.mma655x_inverted());
} catch (AltosUnknownProduct up) {
}
+ try {
+ set_adxl375_inverted(config_data.adxl375_inverted());
+ } catch (AltosUnknownProduct up) {
+ }
+ try {
+ set_adxl375_axis(config_data.adxl375_axis());
+ } catch (AltosUnknownProduct up) {
+ }
set_pad_orientation(config_data.pad_orientation);
}
}
diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java
index 48dab421..29ce033d 100644
--- a/altoslib/AltosConfigData.java
+++ b/altoslib/AltosConfigData.java
@@ -581,6 +581,22 @@ public class AltosConfigData {
throw new AltosUnknownProduct(product);
}
+ public boolean adxl375_inverted() throws AltosUnknownProduct {
+ if (product != null) {
+ if (product.startsWith("EasyMega-v2"))
+ return true;
+ }
+ throw new AltosUnknownProduct(product);
+ }
+
+ public int adxl375_axis() throws AltosUnknownProduct {
+ if (product != null) {
+ if (product.startsWith("EasyMega-v2"))
+ return AltosAdxl375.X_AXIS;
+ }
+ throw new AltosUnknownProduct(product);
+ }
+
public void get_values(AltosConfigValues source) throws AltosConfigDataException {
/* HAS_FLIGHT */
diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java
index 88a65e63..884d8761 100644
--- a/altoslib/AltosIdleFetch.java
+++ b/altoslib/AltosIdleFetch.java
@@ -32,7 +32,7 @@ class AltosIdler {
static final int idle_mag = 2;
static final int idle_mma655x = 4;
static final int idle_ms5607 = 5;
-
+ static final int idle_adxl375 = 6;
static final int idle_sensor_tm = 10;
static final int idle_sensor_metrum = 11;
@@ -58,6 +58,9 @@ class AltosIdler {
case idle_mma655x:
AltosMma655x.provide_data(listener, link);
break;
+ case idle_adxl375:
+ AltosAdxl375.provide_data(listener, link);
+ break;
case idle_ms5607:
AltosMs5607.provide_data(listener, link);
break;
@@ -157,11 +160,16 @@ public class AltosIdleFetch implements AltosDataProvider {
AltosIdler.idle_ms5607,
AltosIdler.idle_imu,
AltosIdler.idle_sensor_mega),
- new AltosIdler("EasyMega",
+ new AltosIdler("EasyMega-v1",
AltosIdler.idle_mma655x,
AltosIdler.idle_ms5607,
AltosIdler.idle_imu, AltosIdler.idle_mag,
AltosIdler.idle_sensor_mega),
+ new AltosIdler("EasyMega-v2",
+ AltosIdler.idle_adxl375,
+ AltosIdler.idle_ms5607,
+ AltosIdler.idle_imu,
+ AltosIdler.idle_sensor_mega),
new AltosIdler("TeleGPS",
AltosIdler.idle_gps,
AltosIdler.idle_sensor_tgps),
diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am
index 92976332..2f4e5959 100644
--- a/altoslib/Makefile.am
+++ b/altoslib/Makefile.am
@@ -28,6 +28,7 @@ altoslib_JAVA = \
AltosLib.java \
AltosAccelCal.java \
AltosAccelCalListener.java \
+ AltosAdxl375.java \
AltosCalData.java \
AltosCompanion.java \
AltosConfigData.java \
diff --git a/altosui/Makefile.am b/altosui/Makefile.am
index 144d21d7..7cc1f4ea 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
@@ -148,7 +140,8 @@ FIRMWARE_EMINI_1_0=$(top_srcdir)/src/easymini-v1.0/easymini-v1.0-$(VERSION).ihx
FIRMWARE_EMINI=$(FIRMWARE_EMINI_1_0)
FIRMWARE_EMEGA_1_0=$(top_srcdir)/src/easymega-v1.0/easymega-v1.0-$(VERSION).ihx
-FIRMWARE_EMEGA=$(FIRMWARE_EMEGA_1_0)
+FIRMWARE_EMEGA_2_0=$(top_srcdir)/src/easymega-v2.0/easymega-v2.0-$(VERSION).ihx
+FIRMWARE_EMEGA=$(FIRMWARE_EMEGA_1_0) $(FIRMWARE_EMEGA_2_0)
FIRMWARE_TGPS_1_0=$(top_srcdir)/src/telegps-v1.0/telegps-v1.0-$(VERSION).ihx
FIRMWARE_TGPS_2_0=$(top_srcdir)/src/telegps-v2.0/telegps-v2.0-$(VERSION).ihx
diff --git a/altosui/altos-windows.nsi.in b/altosui/altos-windows.nsi.in
index be9fb433..2666fc33 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"
@@ -140,6 +134,7 @@ Section "Firmware"
File "../src/easymini-v1.0/easymini-v1.0-${VERSION}.ihx"
File "../src/easymini-v2.0/easymini-v2.0-${VERSION}.ihx"
File "../src/easymega-v1.0/easymega-v1.0-${VERSION}.ihx"
+ File "../src/easymega-v2.0/easymega-v2.0-${VERSION}.ihx"
SectionEnd
diff --git a/configure.ac b/configure.ac
index 7f7eec93..e888aa99 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,8 +18,8 @@ dnl
dnl Process this file with autoconf to create configure.
AC_PREREQ(2.57)
-AC_INIT([altos], 1.8.7)
-ANDROID_VERSION=17
+AC_INIT([altos], 1.8.7.1)
+ANDROID_VERSION=18
AC_CONFIG_SRCDIR([src/kernel/ao.h])
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE
@@ -210,36 +210,6 @@ 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
#
@@ -268,27 +238,6 @@ fi
AC_SUBST(HAVE_ARM_CC)
AC_SUBST(ARM_CC)
-if test -d pdclib -a x"$HAVE_ARM_CC" = xyes; then
- PDCLIB_ROOT='$(TOPDIR)/../pdclib-root'
- PDCLIB_INCLUDES='-I$(TOPDIR)/../pdclib-root/include'
- PDCLIB_LIBS_M0='-L$(TOPDIR)/../pdclib-root/lib -lpdclib-cortex-m0'
- PDCLIB_LIBS_M3='-L$(TOPDIR)/../pdclib-root/lib -lpdclib-cortex-m3'
- HAVE_PDCLIB=yes
-else
- PDCLIB_INCLUDES=''
- PDCLIB_LIBS_M0='-lpdclib-cortex-m0'
- PDCLIB_LIBS_M3='-lpdclib-cortex-m3'
- HAVE_PDCLIB=no
-fi
-
-AM_CONDITIONAL(PDCLIB, [test x$HAVE_PDCLIB = xyes])
-
-AC_SUBST(PDCLIB_INCLUDES)
-AC_SUBST(PDCLIB_LIBS_M0)
-AC_SUBST(PDCLIB_LIBS_M3)
-AC_SUBST(PDCLIB_ROOT)
-AC_SUBST(HAVE_PDCLIB)
-
if test "x$HAVE_ARM_CC" = "xyes"; then
save_CC="$CC"
save_CFLAGS="$CFLAGS"
@@ -311,16 +260,6 @@ if test "x$HAVE_ARM_CC" = "xyes"; then
[HAVE_ARM_M3_CC=no])
AC_MSG_RESULT([$HAVE_ARM_M3_CC])
- if test x$HAVE_PDCLIB != xyes; then
- AC_CHECK_LIB(pdclib-cortex-m0,memcpy,
- [],
- [HAVE_ARM_M0_CC=no])
-
- AC_CHECK_LIB(pdclib-cortex-m3,memcpy,
- [],
- [HAVE_ARM_M3_CC=no])
- fi
-
AC_LANG_POP([C])
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
@@ -340,6 +279,37 @@ if test "x$HAVE_ARM_M0_CC" = "xno"; then
AC_MSG_WARN([No cortex-m0 arm compiler found, LPC11U14 binaries will not be built])
fi
+AC_ARG_WITH([newlib-nano],
+ [AS_HELP_STRING([--with-newlib-nano],
+ [Root of newlib nano install])],
+ [],
+ [with_newlib_nano=auto])
+
+HAVE_NEWLIB_NANO=no
+if test "x$with_newlib_nano" != "xno"; then
+ if test "x$with_newlib_nano" = "xauto"; then
+ for d in /usr/local/lib/newlib-nano /usr/lib/newlib-nano; do
+ if test "x$with_newlib_nano" = "xauto" -a -d "$d"; then
+ with_newlib_nano="$d"
+ HAVE_NEWLIB_NANO=yes
+ fi
+ done
+ else
+ HAVE_NEWLIB_NANO=yes
+ fi
+fi
+
+if test "x$HAVE_NEWLIB_NANO" = "xno"; then
+ AC_MSG_WARN([No newlib-nano library found, ARM binaries will not be built])
+ HAVE_ARM_M3_CC=no
+ HAVE_ARM_M0_CC=no
+else
+ NEWLIB_NANO="$with_newlib_nano"
+fi
+
+AC_SUBST(HAVE_NEWLIB_NANO)
+AC_SUBST(NEWLIB_NANO)
+
#
# Configure AVR compiler
#
@@ -587,14 +557,12 @@ 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}"
echo " Android release support.....: ${ANDROID_RELEASE}"
echo " STlink support..............: ${HAVE_STLINK}"
-echo " Local pdclib................: ${HAVE_PDCLIB}"
+echo " Newlib-nano support.........: ${NEWLIB_NANO}"
echo " i386 and amd64 libaltos.....: ${MULTI_ARCH}"
echo " install shared mime info....: ${INSTALL_SHARED_MIME_INFO}"
echo ""
diff --git a/doc/updating-firmware.inc b/doc/updating-firmware.inc
index 91aa58f2..d2883829 100644
--- a/doc/updating-firmware.inc
+++ b/doc/updating-firmware.inc
@@ -131,6 +131,12 @@
to the USB wires on the row of pins towards the center
of the board. Ground is available on the capacitor
next to it, on the end towards the USB wires.
+
+ TeleBT v4::
+
+ Connect pin 30 on the CPU to ground. Pin 30 is the 6th
+ pin from the right on the top when the unit is oriented
+ such that the SMA is at the top.
endif::telemetrum[]
Once you've located the right pins:
diff --git a/pdclib b/pdclib
deleted file mode 160000
-Subproject 20f71c3a97eb4c7ecfa9754a0ca42855db93599
diff --git a/src/Makedefs.in b/src/Makedefs.in
index a52f96fa..b87e8846 100644
--- a/src/Makedefs.in
+++ b/src/Makedefs.in
@@ -1,14 +1,8 @@
ARM_CC=@ARM_CC@
HAVE_ARM_M3_CC=@HAVE_ARM_M3_CC@
HAVE_ARM_M0_CC=@HAVE_ARM_M0_CC@
-PDCLIB_INCLUDES=@PDCLIB_INCLUDES@
-PDCLIB_LIBS_M0=@PDCLIB_LIBS_M0@
-PDCLIB_LIBS_M3=@PDCLIB_LIBS_M3@
-PDCLIB_ROOT=@PDCLIB_ROOT@
-HAVE_PDCLIB=@HAVE_PDCLIB@
-
-SDCC=@SDCC@
-HAVE_SDCC=@HAVE_SDCC@
+NEWLIB_NANO=@NEWLIB_NANO@
+HAVE_NEWLIB_NANO=@HAVE_NEWLIB_NANO@
AVR_CC=@AVR_CC@
AVR_OBJCOPY=@AVR_OBJCOPY@
diff --git a/src/Makefile b/src/Makefile
index a1ff84c2..757641f7 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -16,16 +16,9 @@ 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 \
+ easymega-v2.0 easymega-v2.0/flash-loader \
telemega-v0.1 telemega-v0.1/flash-loader \
telemega-v1.0 telemega-v1.0/flash-loader \
telemega-v2.0 telemega-v2.0/flash-loader \
@@ -59,15 +52,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 +66,7 @@ ifeq ($(strip $(HAVE_AVR_CC)),yes)
SUBDIRS += $(AVRDIRS)
endif
-ALLDIRS=$(SDCCDIRS) $(ARMM3DIRS) $(ARMM0DIRS) $(AVRDIRS)
+ALLDIRS=$(ARMM3DIRS) $(ARMM0DIRS) $(AVRDIRS)
all: all-local all-recursive
@@ -133,11 +117,3 @@ ao_whiten.h: make-whiten
clean-local: $(CLEAN_PDCLIB)
rm -f altitude.h ao_kalman.h
-
-pdclib:
- mkdir -p $(PDCLIB_ROOT)/include $(PDCLIB_ROOT)/lib
- cd ../pdclib && make && make prefix=`pwd`/../pdclib-root install
-
-clean-pdclib:
- rm -rf $(PDCLIB_ROOT)
- cd ../pdclib && make clean
diff --git a/src/aes/ao_aes.c b/src/aes/ao_aes.c
index fd90c5bf..0bc8188e 100644
--- a/src/aes/ao_aes.c
+++ b/src/aes/ao_aes.c
@@ -372,7 +372,7 @@ ao_aes_set_mode(enum ao_aes_mode mode)
}
void
-ao_aes_set_key(__xdata uint8_t *in)
+ao_aes_set_key(uint8_t *in)
{
memcpy(key, in, 16);
xrijndaelKeySched((word32 *) key, 128, 128, &rkk);
@@ -385,8 +385,8 @@ ao_aes_zero_iv(void)
}
void
-ao_aes_run(__xdata uint8_t *in,
- __xdata uint8_t *out)
+ao_aes_run(uint8_t *in,
+ uint8_t *out)
{
uint8_t i;
uint8_t *_iv = (uint8_t *) iv;
diff --git a/src/attiny/ao_arch.h b/src/attiny/ao_arch.h
index 68f5702d..dfd41afe 100644
--- a/src/attiny/ao_arch.h
+++ b/src/attiny/ao_arch.h
@@ -34,16 +34,12 @@
#define AO_PORT_TYPE uint8_t
+#define AO_LED_TYPE uint8_t
+
/* Various definitions to make GCC look more like SDCC */
#define ao_arch_naked_declare __attribute__((naked))
#define ao_arch_naked_define
-#define __pdata
-#define __data
-#define __xdata
-#define __code const
-#define __reentrant
-#define __critical
#define __interrupt(n)
#define __at(n)
@@ -53,6 +49,8 @@
#define ao_arch_interrupt(n) /* nothing */
+#define AO_ROMCONFIG_SYMBOL __attribute__((section(".romconfig"))) const
+
#undef putchar
#undef getchar
#define putchar(c) ao_putchar(c)
diff --git a/src/attiny/ao_arch_funcs.h b/src/attiny/ao_arch_funcs.h
index 0b67a407..69b259d9 100644
--- a/src/attiny/ao_arch_funcs.h
+++ b/src/attiny/ao_arch_funcs.h
@@ -28,21 +28,21 @@
(reg) |= (mask); \
} while (0)
-#define ao_spi_get_bit(reg,bit,pin,bus,speed) ao_spi_get_mask(reg,(1<<(bit)),bus,speed)
+#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,pin,bus) ao_spi_put_mask(reg,(1<<(bit)),bus)
+#define ao_spi_put_bit(reg,bit,bus) ao_spi_put_mask(reg,(1<<(bit)),bus)
#define ao_gpio_token_paster(x,y) x ## y
#define ao_gpio_token_evaluator(x,y) ao_gpio_token_paster(x,y)
-#define ao_gpio_set(port, bit, pin, v) do { \
+#define ao_gpio_set(port, bit, v) do { \
if (v) \
PORTB |= (1 << bit); \
else \
PORTB &= ~(1 << bit); \
} while (0)
-#define ao_gpio_get(port, bit, pin) ((PORTB >> (bit)) & 1)
+#define ao_gpio_get(port, bit) ((PORTB >> (bit)) & 1)
/*
* The SPI mutex must be held to call either of these
@@ -50,17 +50,17 @@
* from chip select low to chip select high
*/
-#define ao_enable_output(port, bit, pin, v) do { \
- ao_gpio_set(port, bit, pin, v); \
+#define ao_enable_output(port, bit, v) do { \
+ ao_gpio_set(port, bit, v); \
ao_gpio_token_evaluator(DDR,port) |= (1 << bit); \
} while (0)
void
-ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant;
+ao_spi_send_bus(void *block, uint16_t len);
void
-ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant;
+ao_spi_recv_bus(void *block, uint16_t len);
#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)
@@ -110,10 +110,10 @@ ao_i2c_init(void);
/* notask.c */
uint8_t
-ao_sleep(__xdata void *wchan);
+ao_sleep(void *wchan);
void
-ao_wakeup(__xdata void *wchan);
+ao_wakeup(void *wchan);
extern alt_t ao_max_height;
diff --git a/src/attiny/ao_i2c_attiny.c b/src/attiny/ao_i2c_attiny.c
index f29ed6a9..34185b5a 100644
--- a/src/attiny/ao_i2c_attiny.c
+++ b/src/attiny/ao_i2c_attiny.c
@@ -173,7 +173,7 @@ ao_i2c_stop_bus(void)
* so using interrupts would take way too long
*/
uint8_t
-ao_i2c_send_bus(void __xdata *block, uint16_t len, uint8_t stop)
+ao_i2c_send_bus(void *block, uint16_t len, uint8_t stop)
{
uint8_t *d = block;
@@ -206,7 +206,7 @@ ao_i2c_send_fixed_bus(uint8_t d, uint16_t len, uint8_t stop)
* Poll, sending zeros and reading data back
*/
uint8_t
-ao_i2c_recv_bus(void __xdata *block, uint16_t len, uint8_t stop)
+ao_i2c_recv_bus(void *block, uint16_t len, uint8_t stop)
{
uint8_t *d = block;
diff --git a/src/attiny/ao_led.c b/src/attiny/ao_led.c
deleted file mode 100644
index 5f53129e..00000000
--- a/src/attiny/ao_led.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright © 2009 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"
-
-__pdata uint8_t ao_led_enable;
-
-#define LED_PORT PORTB
-#define LED_DDR DDRB
-
-void
-ao_led_on(uint8_t colors)
-{
- LED_PORT |= (colors & ao_led_enable);
-}
-
-void
-ao_led_off(uint8_t colors)
-{
- LED_PORT &= ~(colors & ao_led_enable);
-}
-
-void
-ao_led_set(uint8_t colors)
-{
- LED_PORT = (LED_PORT & ~(ao_led_enable)) | (colors & ao_led_enable);
-}
-
-void
-ao_led_toggle(uint8_t colors)
-{
- LED_PORT ^= (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;
- LED_PORT &= ~enable;
- LED_DDR |= enable;
-}
diff --git a/src/cc1111/ao_led.c b/src/attiny/ao_led_tiny.c
index 5fae46c2..cd620f46 100644
--- a/src/cc1111/ao_led.c
+++ b/src/attiny/ao_led_tiny.c
@@ -18,34 +18,35 @@
#include "ao.h"
-__pdata uint8_t ao_led_enable;
+#define LED_PORT PORTB
+#define LED_DDR DDRB
void
ao_led_on(uint8_t colors)
{
- P1 |= (colors & ao_led_enable);
+ LED_PORT |= colors;
}
void
ao_led_off(uint8_t colors)
{
- P1 &= ~(colors & ao_led_enable);
+ LED_PORT &= ~colors;
}
void
ao_led_set(uint8_t colors)
{
- P1 = (P1 & ~(ao_led_enable)) | (colors & ao_led_enable);
+ LED_PORT = (LED_PORT & ~LEDS_AVAILABLE) | (colors & LEDS_AVAILABLE);
}
void
ao_led_toggle(uint8_t colors)
{
- P1 ^= (colors & ao_led_enable);
+ LED_PORT ^= (colors & LEDS_AVAILABLE);
}
void
-ao_led_for(uint8_t colors, uint16_t ticks) __reentrant
+ao_led_for(uint8_t colors, AO_TICK_TYPE ticks)
{
ao_led_on(colors);
ao_delay(ticks);
@@ -53,10 +54,8 @@ ao_led_for(uint8_t colors, uint16_t ticks) __reentrant
}
void
-ao_led_init(uint8_t enable)
+ao_led_init(void)
{
- ao_led_enable = enable;
- P1SEL &= ~enable;
- P1 &= ~enable;
- P1DIR |= enable;
+ LED_PORT &= ~LEDS_AVAILABLE;
+ LED_DDR |= LEDS_AVAILABLE;
}
diff --git a/src/attiny/ao_spi_attiny.c b/src/attiny/ao_spi_attiny.c
index f63eb651..1c90ad56 100644
--- a/src/attiny/ao_spi_attiny.c
+++ b/src/attiny/ao_spi_attiny.c
@@ -82,7 +82,7 @@ ao_spi_transfer(uint8_t i)
* so using interrupts would take way too long
*/
void
-ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant
+ao_spi_send_bus(void *block, uint16_t len)
{
uint8_t *d = block;
@@ -95,7 +95,7 @@ ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant
* Poll, sending zeros and reading data back
*/
void
-ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant
+ao_spi_recv_bus(void *block, uint16_t len)
{
uint8_t *d = block;
diff --git a/src/avr-demo/Makefile b/src/avr-demo/Makefile
index e21ad047..0aca6f8a 100644
--- a/src/avr-demo/Makefile
+++ b/src/avr-demo/Makefile
@@ -38,7 +38,7 @@ ALTOS_SRC = \
ao_stdio.c \
ao_task.c \
ao_timer.c \
- ao_led.c \
+ ao_led_avr.c \
ao_usb_avr.c \
ao_lcd.c
diff --git a/src/avr/ao_adc_avr.c b/src/avr/ao_adc_avr.c
index 2732c4db..2aae95ac 100644
--- a/src/avr/ao_adc_avr.c
+++ b/src/avr/ao_adc_avr.c
@@ -19,8 +19,8 @@
#include "ao.h"
#include "ao_pwmin.h"
-volatile __xdata struct ao_data ao_data_ring[AO_DATA_RING];
-volatile __data uint8_t ao_data_head;
+volatile struct ao_data ao_data_ring[AO_DATA_RING];
+volatile uint8_t ao_data_head;
#ifdef TELESCIENCE
const uint8_t adc_channels[AO_LOG_TELESCIENCE_NUM_ADC] = {
@@ -119,16 +119,16 @@ ao_adc_poll(void)
}
void
-ao_data_get(__xdata struct ao_data *packet)
+ao_data_get(struct ao_data *packet)
{
uint8_t i = ao_data_ring_prev(ao_data_head);
memcpy(packet, (void *) &ao_data_ring[i], sizeof (struct ao_data));
}
static void
-ao_adc_dump(void) __reentrant
+ao_adc_dump(void)
{
- static __xdata struct ao_data packet;
+ static struct ao_data packet;
uint8_t i;
ao_data_get(&packet);
printf("tick: %5u", packet.tick);
@@ -137,7 +137,7 @@ ao_adc_dump(void) __reentrant
printf("\n");
}
-__code struct ao_cmds ao_adc_cmds[] = {
+const struct ao_cmds ao_adc_cmds[] = {
{ ao_adc_dump, "a\0ADC" },
{ 0, NULL },
};
diff --git a/src/avr/ao_arch.h b/src/avr/ao_arch.h
index 2b1da642..6166c50e 100644
--- a/src/avr/ao_arch.h
+++ b/src/avr/ao_arch.h
@@ -48,12 +48,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 __critical
#define __interrupt(n)
#define __at(n)
diff --git a/src/avr/ao_arch_funcs.h b/src/avr/ao_arch_funcs.h
index 891ad9b1..f2a58af0 100644
--- a/src/avr/ao_arch_funcs.h
+++ b/src/avr/ao_arch_funcs.h
@@ -20,7 +20,7 @@
* ao_spi.c
*/
-extern __xdata uint8_t ao_spi_mutex;
+extern uint8_t ao_spi_mutex;
#define ao_spi_get_mask(reg,mask,bus,speed) do { \
ao_mutex_get(&ao_spi_mutex); \
@@ -32,12 +32,12 @@ extern __xdata uint8_t ao_spi_mutex;
ao_mutex_put(&ao_spi_mutex); \
} while (0)
-#define ao_spi_get_bit(reg,bit,pin,bus,speed) do { \
+#define ao_spi_get_bit(reg,bit,bus,speed) do { \
ao_mutex_get(&ao_spi_mutex); \
(pin) = 0; \
} while (0)
-#define ao_spi_put_bit(reg,bit,pin,bus) do { \
+#define ao_spi_put_bit(reg,bit,bus) do { \
(pin) = 1; \
ao_mutex_put(&ao_spi_mutex); \
} while (0)
@@ -46,7 +46,7 @@ extern __xdata uint8_t ao_spi_mutex;
#define ao_gpio_token_paster(x,y) x ## y
#define ao_gpio_token_evaluator(x,y) ao_gpio_token_paster(x,y)
-#define ao_gpio_set(port, bit, pin, v) do { \
+#define ao_gpio_set(port, bit, v) do { \
if (v) \
(ao_gpio_token_evaluator(PORT,port)) |= (1 << bit); \
else \
@@ -59,17 +59,17 @@ extern __xdata uint8_t ao_spi_mutex;
* from chip select low to chip select high
*/
-#define ao_enable_output(port, bit, pin, v) do { \
- ao_gpio_set(port, bit, pin, v); \
+#define ao_enable_output(port, bit, v) do { \
+ ao_gpio_set(port, bit, v); \
ao_gpio_token_evaluator(DDR,port) |= (1 << bit); \
} while (0)
void
-ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant;
+ao_spi_send_bus(void *block, uint16_t len);
void
-ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant;
+ao_spi_recv_bus(void *block, uint16_t len);
#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)
diff --git a/src/avr/ao_eeprom_avr.c b/src/avr/ao_eeprom_avr.c
index 2fdf177b..84942cd7 100644
--- a/src/avr/ao_eeprom_avr.c
+++ b/src/avr/ao_eeprom_avr.c
@@ -21,16 +21,16 @@
#include <ao_storage.h>
/* Total bytes of available storage */
-__pdata ao_pos_t ao_storage_total = 1024;
+ao_pos_t ao_storage_total = 1024;
/* Block size - device is erased in these units. */
-__pdata ao_pos_t ao_storage_block = 1024;
+ao_pos_t ao_storage_block = 1024;
/* Byte offset of config block. Will be ao_storage_block bytes long */
-__pdata ao_pos_t ao_storage_config = 0;
+ao_pos_t ao_storage_config = 0;
/* Storage unit size - device reads and writes must be within blocks of this size. */
-__pdata uint16_t ao_storage_unit = 1024;
+uint16_t ao_storage_unit = 1024;
/*
* The internal flash chip is arranged in 8 byte sectors; the
@@ -45,7 +45,7 @@ __pdata uint16_t ao_storage_unit = 1024;
* Erase the specified sector
*/
uint8_t
-ao_storage_erase(ao_pos_t pos) __reentrant
+ao_storage_erase(ao_pos_t pos)
{
/* Not necessary */
return 1;
@@ -83,10 +83,10 @@ ao_intflash_read(uint16_t pos)
*/
uint8_t
-ao_storage_device_write(ao_pos_t pos32, __xdata void *v, uint16_t len) __reentrant
+ao_storage_device_write(ao_pos_t pos32, void *v, uint16_t len)
{
uint16_t pos = pos32;
- __xdata uint8_t *d = v;
+ uint8_t *d = v;
if (pos >= ao_storage_total || pos + len > ao_storage_total)
return 0;
@@ -101,7 +101,7 @@ ao_storage_device_write(ao_pos_t pos32, __xdata void *v, uint16_t len) __reentra
* Read from flash
*/
uint8_t
-ao_storage_device_read(ao_pos_t pos, __xdata void *v, uint16_t len) __reentrant
+ao_storage_device_read(ao_pos_t pos, void *v, uint16_t len)
{
uint8_t *d = v;
@@ -113,7 +113,7 @@ ao_storage_device_read(ao_pos_t pos, __xdata void *v, uint16_t len) __reentrant
}
void
-ao_storage_flush(void) __reentrant
+ao_storage_flush(void)
{
}
@@ -123,7 +123,7 @@ ao_storage_setup(void)
}
void
-ao_storage_device_info(void) __reentrant
+ao_storage_device_info(void)
{
printf ("Using internal flash\n");
}
diff --git a/src/avr/ao_i2c_usart.c b/src/avr/ao_i2c_usart.c
index c95548d4..67bee339 100644
--- a/src/avr/ao_i2c_usart.c
+++ b/src/avr/ao_i2c_usart.c
@@ -22,7 +22,7 @@
* Atmega32u4 TWI master mode (I2C)
*/
-__xdata uint8_t ao_i2c_mutex;
+uint8_t ao_i2c_mutex;
/* Send bytes over I2C.
*
@@ -30,7 +30,7 @@ __xdata uint8_t ao_i2c_mutex;
* so using interrupts would take way too long
*/
void
-ao_i2c_send(void __xdata *block, uint16_t len) __reentrant
+ao_i2c_send(void *block, uint16_t len)
{
uint8_t *d = block;
@@ -51,7 +51,7 @@ ao_i2c_send(void __xdata *block, uint16_t len) __reentrant
* clocks the data coming in.
*/
void
-ao_i2c_recv(void __xdata *block, uint16_t len) __reentrant
+ao_i2c_recv(void *block, uint16_t len)
{
uint8_t *d = block;
diff --git a/src/avr/ao_led.c b/src/avr/ao_led_avr.c
index 8eba4898..165e95d3 100644
--- a/src/avr/ao_led.c
+++ b/src/avr/ao_led_avr.c
@@ -18,7 +18,7 @@
#include "ao.h"
-__pdata uint8_t ao_led_enable;
+uint8_t ao_led_enable;
#define LED_PORT PORTB
#define LED_DDR DDRB
@@ -48,7 +48,7 @@ ao_led_toggle(uint8_t colors)
}
void
-ao_led_for(uint8_t colors, uint16_t ticks) __reentrant
+ao_led_for(uint8_t colors, uint16_t ticks)
{
ao_led_on(colors);
ao_delay(ticks);
diff --git a/src/avr/ao_pwmin.c b/src/avr/ao_pwmin.c
index 5eb392a4..2d83380f 100644
--- a/src/avr/ao_pwmin.c
+++ b/src/avr/ao_pwmin.c
@@ -26,8 +26,8 @@
* project payload developed at Challenger Middle School.
*/
-volatile __data uint16_t ao_icp3_count = 0;
-volatile __data uint16_t ao_icp3_last = 0;
+volatile uint16_t ao_icp3_count = 0;
+volatile uint16_t ao_icp3_last = 0;
uint16_t ao_icp3(void)
{
@@ -39,7 +39,7 @@ uint16_t ao_icp3(void)
}
static void
-ao_pwmin_display(void) __reentrant
+ao_pwmin_display(void)
{
/* display the most recent value */
printf("icp 3: %5u\n", ao_icp3());
@@ -62,7 +62,7 @@ ISR(TIMER3_CAPT_vect)
ao_icp3_last = ao_icp3_this;
}
-__code struct ao_cmds ao_pwmin_cmds[] = {
+const struct ao_cmds ao_pwmin_cmds[] = {
{ ao_pwmin_display, "p\0PWM input" },
{ 0, NULL },
};
diff --git a/src/avr/ao_pwmin.h b/src/avr/ao_pwmin.h
index 43c12f53..fcb5e267 100644
--- a/src/avr/ao_pwmin.h
+++ b/src/avr/ao_pwmin.h
@@ -18,4 +18,4 @@
void ao_pwmin_init(void);
-extern volatile __data uint16_t ao_icp3_count;
+extern volatile uint16_t ao_icp3_count;
diff --git a/src/avr/ao_serial_avr.c b/src/avr/ao_serial_avr.c
index ab82b7b1..cfdd7dfe 100644
--- a/src/avr/ao_serial_avr.c
+++ b/src/avr/ao_serial_avr.c
@@ -18,8 +18,8 @@
#include "ao.h"
-__xdata struct ao_fifo ao_serial1_rx_fifo;
-__xdata struct ao_fifo ao_serial1_tx_fifo;
+struct ao_fifo ao_serial1_rx_fifo;
+struct ao_fifo ao_serial1_tx_fifo;
void
ao_debug_out(char c)
@@ -40,7 +40,7 @@ ISR(USART1_RX_vect)
#endif
}
-static __xdata uint8_t ao_serial_tx1_started;
+static uint8_t ao_serial_tx1_started;
static void
ao_serial1_tx_start(void)
@@ -75,7 +75,7 @@ _ao_serial1_pollchar(void)
#endif
char
-ao_serial1_getchar(void) __critical
+ao_serial1_getchar(void)
{
char c;
@@ -99,7 +99,7 @@ ao_serial1_putchar(char c)
}
void
-ao_serial1_drain(void) __critical
+ao_serial1_drain(void)
{
ao_arch_block_interrupts();
while (!ao_fifo_empty(ao_serial1_tx_fifo))
diff --git a/src/avr/ao_spi_usart.c b/src/avr/ao_spi_usart.c
index 0d509cb7..6c30b025 100644
--- a/src/avr/ao_spi_usart.c
+++ b/src/avr/ao_spi_usart.c
@@ -22,7 +22,7 @@
* Atmega32u4 USART in MSPIM (master SPI mode)
*/
-__xdata uint8_t ao_spi_mutex;
+uint8_t ao_spi_mutex;
/* Send bytes over SPI.
*
@@ -30,7 +30,7 @@ __xdata uint8_t ao_spi_mutex;
* so using interrupts would take way too long
*/
void
-ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant
+ao_spi_send_bus(void *block, uint16_t len)
{
uint8_t *d = block;
@@ -47,7 +47,7 @@ ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant
* Poll, sending zeros and reading data back
*/
void
-ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant
+ao_spi_recv_bus(void *block, uint16_t len)
{
uint8_t *d = block;
diff --git a/src/avr/ao_timer.c b/src/avr/ao_timer.c
index 2eaa8b63..ff6a829a 100644
--- a/src/avr/ao_timer.c
+++ b/src/avr/ao_timer.c
@@ -18,7 +18,7 @@
#include "ao.h"
-volatile __data uint16_t ao_tick_count;
+volatile uint16_t ao_tick_count;
uint16_t ao_time(void)
{
@@ -33,8 +33,8 @@ uint16_t ao_time(void)
#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;
+volatile uint8_t ao_adc_interval = 1;
+volatile uint8_t ao_adc_count;
#endif
void
@@ -53,7 +53,7 @@ ISR(TIMER1_COMPA_vect)
#if HAS_ADC
void
-ao_timer_set_adc_interval(uint8_t interval) __critical
+ao_timer_set_adc_interval(uint8_t interval)
{
ao_adc_interval = interval;
ao_adc_count = 0;
diff --git a/src/avr/ao_usb_avr.c b/src/avr/ao_usb_avr.c
index 41d3c1be..df800994 100644
--- a/src/avr/ao_usb_avr.c
+++ b/src/avr/ao_usb_avr.c
@@ -27,7 +27,7 @@
#define debug(format, args...)
#endif
-struct ao_task __xdata ao_usb_task;
+struct ao_task ao_usb_task;
struct ao_usb_setup {
uint8_t dir_type_recip;
@@ -35,21 +35,21 @@ struct ao_usb_setup {
uint16_t value;
uint16_t index;
uint16_t length;
-} __xdata ao_usb_setup;
-
-static __xdata uint8_t ao_usb_ep0_state;
-static const uint8_t * __xdata ao_usb_ep0_in_data;
-static __xdata uint8_t ao_usb_ep0_in_len;
-static __xdata uint8_t ao_usb_ep0_in_pending;
-static __xdata uint8_t ao_usb_addr_pending;
-static __xdata uint8_t ao_usb_ep0_in_buf[2];
-static __xdata uint8_t ao_usb_ep0_out_len;
-static __xdata uint8_t *__xdata ao_usb_ep0_out_data;
-
-static __xdata uint8_t ao_usb_in_flushed;
-__xdata uint8_t ao_usb_running;
-static __xdata uint8_t ao_usb_configuration;
-static __xdata uint8_t ueienx_0;
+} ao_usb_setup;
+
+static uint8_t ao_usb_ep0_state;
+static const uint8_t * ao_usb_ep0_in_data;
+static uint8_t ao_usb_ep0_in_len;
+static uint8_t ao_usb_ep0_in_pending;
+static uint8_t ao_usb_addr_pending;
+static uint8_t ao_usb_ep0_in_buf[2];
+static uint8_t ao_usb_ep0_out_len;
+static uint8_t *ao_usb_ep0_out_data;
+
+static uint8_t ao_usb_in_flushed;
+uint8_t ao_usb_running;
+static uint8_t ao_usb_configuration;
+static uint8_t ueienx_0;
void
ao_usb_set_address(uint8_t address)
@@ -143,9 +143,9 @@ struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8};
static void
ao_usb_get_descriptor(uint16_t value)
{
- const uint8_t *__xdata descriptor;
- __xdata uint8_t type = value >> 8;
- __xdata uint8_t index = value;
+ const uint8_t *descriptor;
+ uint8_t type = value >> 8;
+ uint8_t index = value;
descriptor = ao_usb_descriptors;
while (descriptor[0] != 0) {
@@ -174,7 +174,7 @@ ao_usb_ep0_set_in_pending(uint8_t in_pending)
static void
ao_usb_ep0_flush(void)
{
- __xdata uint8_t this_len;
+ uint8_t this_len;
cli();
UENUM = 0;
@@ -242,7 +242,7 @@ 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_data = (uint8_t *) &ao_usb_setup;
ao_usb_ep0_out_len = 8;
ao_usb_ep0_fill(8, (1 << RXSTPI) | (1 << RXOUTI) | (1 << TXINI));
if (ao_usb_ep0_out_len != 0) {
@@ -334,7 +334,7 @@ ao_usb_ep0_setup(void)
case AO_USB_SET_LINE_CODING:
debug ("set line coding\n");
ao_usb_ep0_out_len = 7;
- ao_usb_ep0_out_data = (__xdata uint8_t *) &ao_usb_line_coding;
+ ao_usb_ep0_out_data = (uint8_t *) &ao_usb_line_coding;
break;
case AO_USB_GET_LINE_CODING:
debug ("get line coding\n");
@@ -636,7 +636,7 @@ ao_usb_enable(void)
}
#if USB_DEBUG
-struct ao_task __xdata ao_usb_echo_task;
+struct ao_task ao_usb_echo_task;
static void
ao_usb_echo(void)
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 <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"
-
-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 <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"
-
-#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 <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.
- */
-
-/*
- * 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 <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.
- */
-
-/*
- * 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 <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"
-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 <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"
-
-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 <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"
-
-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 <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"
-#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 <count>\0Get data" },
- { debug_input, "I <count> <addr>\0Input <count> at <addr>" },
- { debug_output, "O <count> <addr>\0Output <count> at <addr>" },
- { debug_put, "P <byte> ...\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 <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"
-
-#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 <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>
-#include <ao_exti.h>
-
-#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_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 <aj@erisian.com.au>
- *
- * 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 <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>
-#include <ao_launch.h>
-#include <ao_radio_cmac.h>
-
-__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 <key>\0Fire igniter. <key> 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 <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.
- */
-
-#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 <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"
-
-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_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 <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.
- */
-
-#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 <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"
-#if HAS_PAD
-#include <ao_pad.h>
-#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 <offset> <value>\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 <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"
-
-/* 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 <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"
-
-__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 <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"
-
-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 <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"
-
-/* 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 <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"
-
-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 <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"
-
-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 <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"
-#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 <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.
-
- 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 <cc1110.h>
-#include <stdint.h>
-
-__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/chaoskey-v0.1/Makefile b/src/chaoskey-v0.1/Makefile
index 85392280..faa4a291 100644
--- a/src/chaoskey-v0.1/Makefile
+++ b/src/chaoskey-v0.1/Makefile
@@ -28,7 +28,7 @@ ALTOS_SRC = \
ao_adc_fast.c \
ao_crc_stm.c \
ao_stdio.c \
- ao_led.c \
+ ao_led_stmf0.c \
ao_romconfig.c \
ao_boot_chain.c \
ao_usb_stm.c \
diff --git a/src/chaoskey-v1.0/Makefile b/src/chaoskey-v1.0/Makefile
index c6cf45bd..329f603d 100644
--- a/src/chaoskey-v1.0/Makefile
+++ b/src/chaoskey-v1.0/Makefile
@@ -30,7 +30,7 @@ ALTOS_SRC = \
ao_adc_fast.c \
ao_crc_stm.c \
ao_stdio.c \
- ao_led.c \
+ ao_led_stmf0.c \
ao_romconfig.c \
ao_boot_chain.c \
ao_usb_stm.c \
diff --git a/src/chaoskey-v1.0/ao_chaoskey.c b/src/chaoskey-v1.0/ao_chaoskey.c
index 1165e454..80f5a4ba 100644
--- a/src/chaoskey-v1.0/ao_chaoskey.c
+++ b/src/chaoskey-v1.0/ao_chaoskey.c
@@ -24,7 +24,7 @@
void main(void)
{
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
ao_clock_init();
ao_task_init();
ao_timer_init();
diff --git a/src/cortexelf-v1/ao_cortexelf.c b/src/cortexelf-v1/ao_cortexelf.c
index 5ed78bf0..1c30cd85 100644
--- a/src/cortexelf-v1/ao_cortexelf.c
+++ b/src/cortexelf-v1/ao_cortexelf.c
@@ -149,17 +149,16 @@ ao_fb_init(void)
static void
ao_video_toggle(void)
{
- ao_cmd_decimal();
- if (ao_cmd_lex_i)
+ uint16_t r = ao_cmd_decimal();
+ if (r)
ao_fb_init();
- ao_vga_enable(ao_cmd_lex_i);
+ ao_vga_enable(r)
}
static void
ao_ball_toggle(void)
{
- ao_cmd_decimal();
- ball_enable = ao_cmd_lex_i;
+ ball_enable = ao_cmd_decimal();
ao_wakeup(&ball_enable);
}
@@ -208,17 +207,15 @@ led_cmd(void)
{
uint8_t start;
uint8_t value;
- ao_cmd_decimal();
- start = ao_cmd_lex_i;
- ao_cmd_hex();
- value = ao_cmd_lex_i;
+ start = ao_cmd_decimal();
+ value = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
ao_as1107_write_8(start, value);
}
-__code struct ao_cmds ao_demo_cmds[] = {
+const struct ao_cmds ao_demo_cmds[] = {
{ ao_video_toggle, "V\0Toggle video" },
{ ao_ball_toggle, "B\0Toggle ball" },
{ ao_ps2_read_keys, "K\0Read keys from keyboard" },
diff --git a/src/cortexelf-v1/cortexelf.ld b/src/cortexelf-v1/cortexelf.ld
index 6ad2a679..069fe5bd 100644
--- a/src/cortexelf-v1/cortexelf.ld
+++ b/src/cortexelf-v1/cortexelf.ld
@@ -75,10 +75,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/detherm/Makefile b/src/detherm/Makefile
index 6b0e0bf8..7681a049 100644
--- a/src/detherm/Makefile
+++ b/src/detherm/Makefile
@@ -27,7 +27,7 @@ ALTOS_SRC = \
ao_spi_stm.c \
ao_exti_stm.c \
ao_stdio.c \
- ao_led.c \
+ ao_led_stmf0.c \
ao_log.c \
ao_log_mini.c \
ao_sample.c \
diff --git a/src/draw/ao_line.c b/src/draw/ao_line.c
index ed1fc21c..742b3aa3 100644
--- a/src/draw/ao_line.c
+++ b/src/draw/ao_line.c
@@ -159,28 +159,28 @@ ao_clip_line(struct ao_cc *c, struct ao_cbox *b)
/* Clip major axis */
if (c->major < b->maj1) {
if (c->sign_major <= 0)
- return FALSE;
+ return false;
adjust_major = b->maj1 - c->major;
} else if (c->major >= b->maj2) {
if (c->sign_major >= 0)
- return FALSE;
+ return false;
adjust_major = c->major - (b->maj2-1);
}
/* Clip minor axis */
if (c->minor < b->min1) {
if (c->sign_minor <= 0)
- return FALSE;
+ return false;
adjust_minor = b->min1 - c->minor;
} else if (c->minor >= b->min2) {
if (c->sign_minor >= 0)
- return FALSE;
+ return false;
adjust_minor = c->minor - (b->min2-1);
}
/* If unclipped, we're done */
if (adjust_major == 0 && adjust_minor == 0)
- return TRUE;
+ return true;
/* See how much minor adjustment would happen during
* a major clip. This is a bit tricky because line drawing
@@ -208,7 +208,7 @@ ao_clip_line(struct ao_cc *c, struct ao_cbox *b)
c->major += c->sign_major * adjust_major;
c->minor += c->sign_minor * adjust_minor;
- return TRUE;
+ return true;
}
void
@@ -276,8 +276,8 @@ ao_line(const struct ao_bitmap *dst,
e3 = e2 - e1;
e = e - e1;
- clip_1.first = TRUE;
- clip_2.first = FALSE;
+ clip_1.first = true;
+ clip_2.first = false;
clip_2.e = clip_1.e = e;
clip_2.e1 = clip_1.e1 = e1;
clip_2.e3 = clip_1.e3 = e3;
diff --git a/src/drivers/ao_25lc1024.c b/src/drivers/ao_25lc1024.c
index a9c897b3..c73f54df 100644
--- a/src/drivers/ao_25lc1024.c
+++ b/src/drivers/ao_25lc1024.c
@@ -24,16 +24,16 @@
#define EE_DEVICE_SIZE ((uint32_t) 128 * (uint32_t) 1024)
/* Total bytes of available storage */
-__pdata uint32_t ao_storage_total;
+uint32_t ao_storage_total;
/* Block size - device is erased in these units. At least 256 bytes */
-__pdata uint32_t ao_storage_block;
+uint32_t ao_storage_block;
/* Byte offset of config block. Will be ao_storage_block bytes long */
-__pdata uint32_t ao_storage_config;
+uint32_t ao_storage_config;
/* Storage unit size - device reads and writes must be within blocks of this size. Usually 256 bytes. */
-__pdata uint16_t ao_storage_unit;
+uint16_t ao_storage_unit;
/*
* Using SPI on USART 0, with P1_2 as the chip select
@@ -43,7 +43,7 @@ __pdata uint16_t ao_storage_unit;
#define EE_CS P1_2
#define EE_CS_PIN 2
-static __xdata uint8_t ao_ee_mutex;
+static uint8_t ao_ee_mutex;
#define ao_ee_delay() do { \
_asm nop _endasm; \
@@ -58,7 +58,7 @@ static __xdata uint8_t ao_ee_mutex;
struct ao_ee_instruction {
uint8_t instruction;
uint8_t address[3];
-} __xdata ao_ee_instruction;
+} ao_ee_instruction;
static void
ao_ee_write_enable(void)
@@ -92,9 +92,9 @@ ao_ee_wrsr(uint8_t status)
#define EE_BLOCK_NONE 0xffff
-static __xdata uint8_t ao_ee_data[EE_BLOCK_SIZE];
-static __pdata uint16_t ao_ee_block = EE_BLOCK_NONE;
-static __pdata uint8_t ao_ee_block_dirty;
+static uint8_t ao_ee_data[EE_BLOCK_SIZE];
+static uint16_t ao_ee_block = EE_BLOCK_NONE;
+static uint8_t ao_ee_block_dirty;
/* Write the current block to the EEPROM */
static void
@@ -157,7 +157,7 @@ ao_ee_fill(uint16_t block)
}
uint8_t
-ao_storage_device_write(uint32_t pos, __xdata void *buf, uint16_t len) __reentrant
+ao_storage_device_write(uint32_t pos, void *buf, uint16_t len)
{
uint16_t block = (uint16_t) (pos >> EE_BLOCK_SHIFT);
@@ -176,7 +176,7 @@ ao_storage_device_write(uint32_t pos, __xdata void *buf, uint16_t len) __reentra
}
uint8_t
-ao_storage_device_read(uint32_t pos, __xdata void *buf, uint16_t len) __reentrant
+ao_storage_device_read(uint32_t pos, void *buf, uint16_t len)
{
uint16_t block = (uint16_t) (pos >> EE_BLOCK_SHIFT);
@@ -189,7 +189,7 @@ ao_storage_device_read(uint32_t pos, __xdata void *buf, uint16_t len) __reentran
}
void
-ao_storage_flush(void) __reentrant
+ao_storage_flush(void)
{
ao_mutex_get(&ao_ee_mutex); {
ao_ee_flush_internal();
@@ -197,7 +197,7 @@ ao_storage_flush(void) __reentrant
}
uint8_t
-ao_storage_erase(uint32_t pos) __reentrant
+ao_storage_erase(uint32_t pos)
{
ao_mutex_get(&ao_ee_mutex); {
ao_ee_flush_internal();
@@ -209,7 +209,7 @@ ao_storage_erase(uint32_t pos) __reentrant
}
static void
-ee_store(void) __reentrant
+ee_store(void)
{
}
@@ -225,7 +225,7 @@ ao_storage_setup(void)
}
void
-ao_storage_device_info(void) __reentrant
+ao_storage_device_info(void)
{
}
diff --git a/src/drivers/ao_74hc165.c b/src/drivers/ao_74hc165.c
index 8842801d..b62e0134 100644
--- a/src/drivers/ao_74hc165.c
+++ b/src/drivers/ao_74hc165.c
@@ -27,7 +27,7 @@
uint8_t
ao_74hc165_read(void)
{
- static __xdata state;
+ static state;
ao_spi_get(AO_74HC165_SPI_BUS);
ao_spi_set_speed(AO_74HC165_SPI_BUS, AO_SPI_SPEED_FAST);
AO_74HC165_CS = 1;
diff --git a/src/drivers/ao_74hc497.c b/src/drivers/ao_74hc497.c
index b3fd3c91..e8c39430 100644
--- a/src/drivers/ao_74hc497.c
+++ b/src/drivers/ao_74hc497.c
@@ -27,7 +27,7 @@
uint8_t
ao_74hc497_read(void)
{
- static __xdata state;
+ static state;
ao_spi_get_bit(AO_74HC497_CS_PORT, AO_74HC497_CS_PIN, AO_74HC497_CS, AO_74HC497_SPI_BUS, AO_SPI_SPEED_FAST);
ao_spi_recv(&state, 1, AO_74HC497_SPI_BUS);
ao_spi_put_bit(AO_74HC497_CS_PORT, AO_74HC497_CS_PIN, AO_74HC497_CS, AO_74HC497_SPI_BUS);
diff --git a/src/drivers/ao_adxl375.c b/src/drivers/ao_adxl375.c
new file mode 100644
index 00000000..e0d094f2
--- /dev/null
+++ b/src/drivers/ao_adxl375.c
@@ -0,0 +1,263 @@
+/*
+ * Copyright © 2018 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.
+ */
+
+#include <ao.h>
+#include "ao_adxl375.h"
+
+#define DEBUG_LOW 1
+#define DEBUG_HIGH 2
+
+#define DEBUG 0
+
+#if DEBUG
+#define PRINTD(l, ...) do { if (DEBUG & (l)) { printf ("\r%5u %s: ", ao_tick_count, __func__); printf(__VA_ARGS__); flush(); } } while(0)
+#else
+#define PRINTD(l,...)
+#endif
+
+struct ao_adxl375_sample ao_adxl375_current;
+
+static void
+ao_adxl375_start(void) {
+ ao_spi_get_bit(AO_ADXL375_CS_PORT,
+ AO_ADXL375_CS_PIN,
+ AO_ADXL375_SPI_INDEX,
+ AO_ADXL375_SPI_SPEED);
+}
+
+static void
+ao_adxl375_stop(void) {
+ ao_spi_put_bit(AO_ADXL375_CS_PORT,
+ AO_ADXL375_CS_PIN,
+ AO_ADXL375_SPI_INDEX);
+}
+
+static uint8_t
+ao_adxl375_reg_read(uint8_t addr)
+{
+ uint8_t d[2];
+
+ d[0] = addr | AO_ADXL375_READ;
+ ao_adxl375_start();
+ ao_spi_duplex(d, d, 2, AO_ADXL375_SPI_INDEX);
+ ao_adxl375_stop();
+
+ PRINTD(DEBUG_LOW, "read %x = %x\n", addr, d);
+
+ return d[1];
+}
+
+static void
+ao_adxl375_reg_write(uint8_t addr, uint8_t value)
+{
+ uint8_t d[2];
+
+ PRINTD(DEBUG_LOW, "write %x %x\n", addr, value);
+ d[0] = addr;
+ d[1] = value;
+ ao_adxl375_start();
+ ao_spi_send(d, 2, AO_ADXL375_SPI_INDEX);
+ ao_adxl375_stop();
+
+#if DEBUG & DEBUG_LOW
+ d[0] = addr | AO_ADXL375_READ
+ d[1] = 0;
+ ao_adxl375_start();
+ ao_spi_duplex(d, d, 2, AO_ADXL375_SPI_INDEX);
+ ao_adxl375_stop();
+ PRINTD(DEBUG_LOW, "readback %x %x\n", d[0], d[1]);
+#endif
+}
+
+static void
+ao_adxl375_value(struct ao_adxl375_sample *value)
+{
+ uint8_t d[7];
+
+ d[0] = AO_ADXL375_DATAX0 | AO_ADXL375_READ | AO_ADXL375_MULTI_BYTE;
+ ao_adxl375_start();
+ ao_spi_duplex(d, d, 7, AO_ADXL375_SPI_INDEX);
+ ao_adxl375_stop();
+ memcpy(value, &d[1], 6);
+}
+
+struct ao_adxl375_total {
+ int32_t x;
+ int32_t y;
+ int32_t z;
+};
+
+#define AO_ADXL375_SELF_TEST_SAMPLES 16
+#define AO_ADXL375_SELF_TEST_SETTLE 6
+
+#define MIN_LSB_G 18.4
+#define MAX_LSB_G 22.6
+#define SELF_TEST_MIN_G 6.0
+#define SELF_TEST_MAX_G 6.8
+
+#define MIN_SELF_TEST ((int32_t) (MIN_LSB_G * SELF_TEST_MIN_G * AO_ADXL375_SELF_TEST_SAMPLES + 0.5))
+#define MAX_SELF_TEST ((int32_t) (MAX_LSB_G * SELF_TEST_MAX_G * AO_ADXL375_SELF_TEST_SAMPLES + 0.5))
+
+static const int32_t min_self_test = MIN_SELF_TEST;
+static const int32_t max_self_test = MAX_SELF_TEST;
+
+static void
+ao_adxl375_total_value(struct ao_adxl375_total *total, int samples)
+{
+ struct ao_adxl375_sample value;
+
+ *total = (struct ao_adxl375_total) { 0, 0, 0 };
+ for (int i = 0; i < samples; i++) {
+ ao_adxl375_value(&value);
+ total->x += value.x;
+ total->y += value.y;
+ total->z += value.z;
+ ao_delay(AO_MS_TO_TICKS(10));
+ }
+}
+
+#define AO_ADXL375_DATA_FORMAT_SETTINGS(self_test) ( \
+ AO_ADXL375_DATA_FORMAT_FIXED | \
+ (self_test << AO_ADXL375_DATA_FORMAT_SELF_TEST) | \
+ (AO_ADXL375_DATA_FORMAT_SPI_4_WIRE << AO_ADXL375_DATA_FORMAT_SPI_4_WIRE) | \
+ (0 << AO_ADXL375_DATA_FORMAT_INT_INVERT) | \
+ (0 << AO_ADXL375_DATA_FORMAT_JUSTIFY))
+
+static int32_t self_test_value;
+
+static void
+ao_adxl375_setup(void)
+{
+ /* Get the device into 4-wire SPI mode before proceeding */
+ ao_adxl375_reg_write(AO_ADXL375_DATA_FORMAT,
+ AO_ADXL375_DATA_FORMAT_SETTINGS(0));
+
+
+ uint8_t devid = ao_adxl375_reg_read(AO_ADXL375_DEVID);
+ if (devid != AO_ADXL375_DEVID_ID)
+ ao_sensor_errors = 1;
+
+ /* Set the data rate */
+ ao_adxl375_reg_write(AO_ADXL375_BW_RATE,
+ (0 << AO_ADXL375_BW_RATE_LOW_POWER) |
+ (AO_ADXL375_BW_RATE_RATE_200 << AO_ADXL375_BW_RATE_RATE));
+
+ /* Set the offsets all to zero */
+ ao_adxl375_reg_write(AO_ADXL375_OFSX, 0);
+ ao_adxl375_reg_write(AO_ADXL375_OFSY, 0);
+ ao_adxl375_reg_write(AO_ADXL375_OFSZ, 0);
+
+ /* Clear interrupts */
+ ao_adxl375_reg_write(AO_ADXL375_INT_ENABLE, 0);
+
+ /* Configure FIFO (disable) */
+ ao_adxl375_reg_write(AO_ADXL375_FIFO_CTL,
+ (AO_ADXL375_FIFO_CTL_FIFO_MODE_BYPASS << AO_ADXL375_FIFO_CTL_FIFO_MODE) |
+ (0 << AO_ADXL375_FIFO_CTL_TRIGGER) |
+ (0 << AO_ADXL375_FIFO_CTL_SAMPLES));
+
+ /* Place part in measurement mode */
+ ao_adxl375_reg_write(AO_ADXL375_POWER_CTL,
+ (0 << AO_ADXL375_POWER_CTL_LINK) |
+ (0 << AO_ADXL375_POWER_CTL_AUTO_SLEEP) |
+ (1 << AO_ADXL375_POWER_CTL_MEASURE) |
+ (0 << AO_ADXL375_POWER_CTL_SLEEP) |
+ (AO_ADXL375_POWER_CTL_WAKEUP_8 << AO_ADXL375_POWER_CTL_WAKEUP));
+
+ (void) ao_adxl375_total_value;
+ /* Perform self-test */
+
+#define AO_ADXL375_SELF_TEST_SAMPLES 16
+#define AO_ADXL375_SELF_TEST_SETTLE 6
+
+ struct ao_adxl375_total self_test_off, self_test_on;
+
+ /* Discard some samples to let it settle down */
+ ao_adxl375_total_value(&self_test_off, AO_ADXL375_SELF_TEST_SETTLE);
+
+ /* Get regular values */
+ ao_adxl375_total_value(&self_test_off, AO_ADXL375_SELF_TEST_SAMPLES);
+
+ /* Turn on self test */
+ ao_adxl375_reg_write(AO_ADXL375_DATA_FORMAT,
+ AO_ADXL375_DATA_FORMAT_SETTINGS(1));
+
+ /* Discard at least 4 samples to let the device settle */
+ ao_adxl375_total_value(&self_test_on, AO_ADXL375_SELF_TEST_SETTLE);
+
+ /* Read self test samples */
+ ao_adxl375_total_value(&self_test_on, AO_ADXL375_SELF_TEST_SAMPLES);
+
+ /* Reset back to normal mode */
+
+ ao_adxl375_reg_write(AO_ADXL375_DATA_FORMAT,
+ AO_ADXL375_DATA_FORMAT_SETTINGS(0));
+
+ /* Verify Z axis value is in range */
+
+ int32_t z_change = self_test_on.z - self_test_off.z;
+
+ self_test_value = z_change;
+
+ if (z_change < min_self_test || max_self_test < z_change)
+ ao_sensor_errors = 1;
+
+ /* Discard some samples to let it settle down */
+ ao_adxl375_total_value(&self_test_off, AO_ADXL375_SELF_TEST_SETTLE);
+}
+
+static int adxl375_count;
+
+static void
+ao_adxl375(void)
+{
+ ao_adxl375_setup();
+ for (;;) {
+ ao_adxl375_value(&ao_adxl375_current);
+ ++adxl375_count;
+ ao_arch_critical(
+ AO_DATA_PRESENT(AO_DATA_ADXL375);
+ AO_DATA_WAIT();
+ );
+ }
+}
+
+static struct ao_task ao_adxl375_task;
+
+static void
+ao_adxl375_dump(void)
+{
+ printf ("ADXL375 value %d %d %d count %d self test %d min %d max %d\n",
+ ao_adxl375_current.x,
+ ao_adxl375_current.y,
+ ao_adxl375_current.z,
+ adxl375_count,
+ self_test_value,
+ MIN_SELF_TEST,
+ MAX_SELF_TEST);
+}
+
+const struct ao_cmds ao_adxl375_cmds[] = {
+ { ao_adxl375_dump, "A\0Display ADXL375 data" },
+ { 0, NULL },
+};
+
+void
+ao_adxl375_init(void)
+{
+ ao_cmd_register(ao_adxl375_cmds);
+ ao_spi_init_cs(AO_ADXL375_CS_PORT, (1 << AO_ADXL375_CS_PIN));
+
+ ao_add_task(&ao_adxl375_task, ao_adxl375, "adxl375");
+}
diff --git a/src/drivers/ao_adxl375.h b/src/drivers/ao_adxl375.h
new file mode 100644
index 00000000..a1ed216d
--- /dev/null
+++ b/src/drivers/ao_adxl375.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright © 2018 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.
+ */
+
+#ifndef _AO_ADXL375_H_
+#define _AO_ADXL375_H_
+
+#define AO_ADXL375_READ 0x80 /* read mode */
+#define AO_ADXL375_MULTI_BYTE 0x40 /* multi-byte mode */
+
+#define AO_ADXL375_DEVID 0x00
+#define AO_ADXL375_DEVID_ID 0xe5
+#define AO_ADXL375_THRESH_SHOCK 0x1d
+#define AO_ADXL375_OFSX 0x1e
+#define AO_ADXL375_OFSY 0x1f
+#define AO_ADXL375_OFSZ 0x20
+#define AO_ADXL375_DUR 0x21
+#define AO_ADXL375_LATENT 0x22
+#define AO_ADXL375_WINDOW 0x23
+#define AO_ADXL375_THRESH_ACT 0x24
+#define AO_ADXL375_THRESH_INACT 0x25
+#define AO_ADXL375_TIME_INACT 0x26
+#define AO_ADXL375_ACT_INACT_CTL 0x27
+#define AO_ADXL375_SHOCK_AXES 0x2a
+#define AO_ADXL375_ACT_SHOCK_STATUS 0x2b
+#define AO_ADXL375_BW_RATE 0x2c
+
+#define AO_ADXL375_BW_RATE_LOW_POWER 4
+#define AO_ADXL375_BW_RATE_RATE 0
+#define AO_ADXL375_BW_RATE_RATE_3200 0xf
+#define AO_ADXL375_BW_RATE_RATE_1600 0xe
+#define AO_ADXL375_BW_RATE_RATE_800 0xd
+#define AO_ADXL375_BW_RATE_RATE_400 0xc
+#define AO_ADXL375_BW_RATE_RATE_200 0xb
+#define AO_ADXL375_BW_RATE_RATE_100 0xa
+#define AO_ADXL375_BW_RATE_RATE_50 0x9
+#define AO_ADXL375_BW_RATE_RATE_25 0x8
+#define AO_ADXL375_BW_RATE_RATE_12_5 0x7
+#define AO_ADXL375_BW_RATE_RATE_6_25 0x6
+#define AO_ADXL375_BW_RATE_RATE_3_13 0x5
+#define AO_ADXL375_BW_RATE_RATE_1_56 0x4
+#define AO_ADXL375_BW_RATE_RATE_0_78 0x3
+#define AO_ADXL375_BW_RATE_RATE_0_39 0x2
+#define AO_ADXL375_BW_RATE_RATE_0_20 0x1
+#define AO_ADXL375_BW_RATE_RATE_0_10 0x0
+
+#define AO_ADXL375_POWER_CTL 0x2d
+#define AO_ADXL375_POWER_CTL_LINK 5
+#define AO_ADXL375_POWER_CTL_AUTO_SLEEP 4
+#define AO_ADXL375_POWER_CTL_MEASURE 3
+#define AO_ADXL375_POWER_CTL_SLEEP 2
+#define AO_ADXL375_POWER_CTL_WAKEUP 0
+#define AO_ADXL375_POWER_CTL_WAKEUP_8 0
+#define AO_ADXL375_POWER_CTL_WAKEUP_4 1
+#define AO_ADXL375_POWER_CTL_WAKEUP_2 2
+#define AO_ADXL375_POWER_CTL_WAKEUP_1 3
+
+#define AO_ADXL375_INT_ENABLE 0x2e
+#define AO_ADXL375_INT_MAP 0x2f
+#define AO_ADXL375_INT_SOURCE 0x30
+#define AO_ADXL375_DATA_FORMAT 0x31
+# define AO_ADXL375_DATA_FORMAT_FIXED 0x0b /* these bits must be set to 1 */
+# define AO_ADXL375_DATA_FORMAT_SELF_TEST 7
+# define AO_ADXL375_DATA_FORMAT_SPI 6
+# define AO_ADXL375_DATA_FORMAT_SPI_3_WIRE 0
+# define AO_ADXL375_DATA_FORMAT_SPI_4_WIRE 1
+# define AO_ADXL375_DATA_FORMAT_INT_INVERT 5
+# define AO_ADXL375_DATA_FORMAT_JUSTIFY 2
+#define AO_ADXL375_DATAX0 0x32
+#define AO_ADXL375_DATAX1 0x33
+#define AO_ADXL375_DATAY0 0x34
+#define AO_ADXL375_DATAY1 0x35
+#define AO_ADXL375_DATAZ0 0x36
+#define AO_ADXL375_DATAZ1 0x37
+#define AO_ADXL375_FIFO_CTL 0x38
+#define AO_ADXL375_FIFO_CTL_FIFO_MODE 6
+#define AO_ADXL375_FIFO_CTL_FIFO_MODE_BYPASS 0
+#define AO_ADXL375_FIFO_CTL_FIFO_MODE_FIFO 1
+#define AO_ADXL375_FIFO_CTL_FIFO_MODE_STREAM 2
+#define AO_ADXL375_FIFO_CTL_FIFO_MODE_TRIGGER 3
+#define AO_ADXL375_FIFO_CTL_TRIGGER 5
+#define AO_ADXL375_FIFO_CTL_SAMPLES 0
+
+#define AO_ADXL375_FIFO_STATUS 0x39
+
+struct ao_adxl375_sample {
+ int16_t x;
+ int16_t y;
+ int16_t z;
+};
+
+extern struct ao_adxl375_sample ao_adxl375_current;
+
+void
+ao_adxl375_init(void);
+
+#endif /* _AO_ADXL375_H_ */
diff --git a/src/drivers/ao_aprs.c b/src/drivers/ao_aprs.c
index a8016673..2f17d044 100644
--- a/src/drivers/ao_aprs.c
+++ b/src/drivers/ao_aprs.c
@@ -804,10 +804,10 @@ static int tncPositionPacket(void)
/* Convert from meters to feet */
alt = (alt * 328 + 50) / 100;
- buf += sprintf((char *) tncBuffer, "!%02u%02u.%02u%c/%03u%02u.%02u%c'/A=%06u ",
+ buf += sprintf((char *) tncBuffer, "!%02u%02u.%02u%c/%03u%02u.%02u%c'/A=%06lu ",
lat_deg, lat_min, lat_frac, lat_sign,
lon_deg, lon_min, lon_frac, lon_sign,
- alt);
+ (long) alt);
break;
}
}
diff --git a/src/drivers/ao_at24c.c b/src/drivers/ao_at24c.c
index 8f91e3ca..16141c73 100644
--- a/src/drivers/ao_at24c.c
+++ b/src/drivers/ao_at24c.c
@@ -25,10 +25,10 @@
#define AO_AT24C_PAGE_LEN 128
/* Total bytes of available storage */
-__pdata ao_pos_t ao_storage_total = 64l * 1024l;
+ao_pos_t ao_storage_total = 64l * 1024l;
/* Storage unit size - device reads and writes must be within blocks of this size. */
-__pdata uint16_t ao_storage_unit = 128;
+uint16_t ao_storage_unit = 128;
static void
ao_at24c_set_address(uint8_t addr, ao_pos_t pos)
@@ -45,7 +45,7 @@ ao_at24c_set_address(uint8_t addr, ao_pos_t pos)
* Erase the specified sector
*/
uint8_t
-ao_storage_erase(ao_pos_t pos) __reentrant
+ao_storage_erase(ao_pos_t pos)
{
if (pos >= ao_storage_total || pos + AO_AT24C_PAGE_LEN > ao_storage_total)
return 0;
@@ -61,7 +61,7 @@ ao_storage_erase(ao_pos_t pos) __reentrant
* Write to flash
*/
uint8_t
-ao_storage_device_write(ao_pos_t pos, __xdata void *d, uint16_t len) __reentrant
+ao_storage_device_write(ao_pos_t pos, void *d, uint16_t len)
{
if (pos >= ao_storage_total || pos + len > ao_storage_total)
return 0;
@@ -77,7 +77,7 @@ ao_storage_device_write(ao_pos_t pos, __xdata void *d, uint16_t len) __reentrant
* Read from flash
*/
uint8_t
-ao_storage_device_read(ao_pos_t pos, __xdata void *d, uint16_t len) __reentrant
+ao_storage_device_read(ao_pos_t pos, void *d, uint16_t len)
{
if (pos >= ao_storage_total || pos + len > ao_storage_total)
return 0;
@@ -89,7 +89,7 @@ ao_storage_device_read(ao_pos_t pos, __xdata void *d, uint16_t len) __reentrant
}
void
-ao_storage_flush(void) __reentrant
+ao_storage_flush(void)
{
}
diff --git a/src/drivers/ao_at45db161d.c b/src/drivers/ao_at45db161d.c
index abba3f1f..516811b8 100644
--- a/src/drivers/ao_at45db161d.c
+++ b/src/drivers/ao_at45db161d.c
@@ -20,23 +20,23 @@
#include "ao_at45db161d.h"
/* Total bytes of available storage */
-__pdata uint32_t ao_storage_total;
+uint32_t ao_storage_total;
/* Block size - device is erased in these units. At least 256 bytes */
-__pdata uint32_t ao_storage_block;
+uint32_t ao_storage_block;
/* Byte offset of config block. Will be ao_storage_block bytes long */
-__pdata uint32_t ao_storage_config;
+uint32_t ao_storage_config;
/* Storage unit size - device reads and writes must be within blocks of this size. Usually 256 bytes. */
-__pdata uint16_t ao_storage_unit;
+uint16_t ao_storage_unit;
#define FLASH_CS P1_1
#define FLASH_CS_INDEX 1
#define FLASH_BLOCK_SIZE_MAX 512
-__xdata uint8_t ao_flash_mutex;
+uint8_t ao_flash_mutex;
#define ao_flash_delay() do { \
_asm nop _endasm; \
@@ -51,7 +51,7 @@ __xdata uint8_t ao_flash_mutex;
struct ao_flash_instruction {
uint8_t instruction;
uint8_t address[3];
-} __xdata ao_flash_instruction;
+} ao_flash_instruction;
static void
ao_flash_set_pagesize_512(void)
@@ -79,17 +79,17 @@ ao_flash_read_status(void)
#define FLASH_BLOCK_NONE 0xffff
-static __xdata uint8_t ao_flash_data[FLASH_BLOCK_SIZE_MAX];
-static __pdata uint16_t ao_flash_block = FLASH_BLOCK_NONE;
-static __pdata uint8_t ao_flash_block_dirty;
-static __pdata uint8_t ao_flash_write_pending;
-static __pdata uint8_t ao_flash_setup_done;
-static __pdata uint8_t ao_flash_block_shift;
-static __pdata uint16_t ao_flash_block_size;
-static __pdata uint16_t ao_flash_block_mask;
+static uint8_t ao_flash_data[FLASH_BLOCK_SIZE_MAX];
+static uint16_t ao_flash_block = FLASH_BLOCK_NONE;
+static uint8_t ao_flash_block_dirty;
+static uint8_t ao_flash_write_pending;
+static uint8_t ao_flash_setup_done;
+static uint8_t ao_flash_block_shift;
+static uint16_t ao_flash_block_size;
+static uint16_t ao_flash_block_mask;
void
-ao_storage_setup(void) __reentrant
+ao_storage_setup(void)
{
uint8_t status;
@@ -234,7 +234,7 @@ ao_flash_fill(uint16_t block)
}
uint8_t
-ao_storage_device_write(uint32_t pos, __xdata void *buf, uint16_t len) __reentrant
+ao_storage_device_write(uint32_t pos, void *buf, uint16_t len)
{
uint16_t block = (uint16_t) (pos >> ao_flash_block_shift);
@@ -255,7 +255,7 @@ ao_storage_device_write(uint32_t pos, __xdata void *buf, uint16_t len) __reentra
}
uint8_t
-ao_storage_device_read(uint32_t pos, __xdata void *buf, uint16_t len) __reentrant
+ao_storage_device_read(uint32_t pos, void *buf, uint16_t len)
{
uint16_t block = (uint16_t) (pos >> ao_flash_block_shift);
@@ -270,7 +270,7 @@ ao_storage_device_read(uint32_t pos, __xdata void *buf, uint16_t len) __reentran
}
void
-ao_storage_flush(void) __reentrant
+ao_storage_flush(void)
{
ao_mutex_get(&ao_flash_mutex); {
ao_flash_flush_internal();
@@ -278,7 +278,7 @@ ao_storage_flush(void) __reentrant
}
uint8_t
-ao_storage_erase(uint32_t pos) __reentrant
+ao_storage_erase(uint32_t pos)
{
ao_mutex_get(&ao_flash_mutex); {
ao_flash_flush_internal();
@@ -290,7 +290,7 @@ ao_storage_erase(uint32_t pos) __reentrant
}
void
-ao_storage_device_info(void) __reentrant
+ao_storage_device_info(void)
{
uint8_t status;
diff --git a/src/drivers/ao_btm.c b/src/drivers/ao_btm.c
index c65a8548..04bf4138 100644
--- a/src/drivers/ao_btm.c
+++ b/src/drivers/ao_btm.c
@@ -30,12 +30,12 @@
#endif
int8_t ao_btm_stdio;
-__xdata uint8_t ao_btm_connected;
+uint8_t ao_btm_connected;
-#define BT_DEBUG 0
+#define BT_DEBUG 1
#if BT_DEBUG
-__xdata char ao_btm_buffer[256];
+char ao_btm_buffer[256];
uint16_t ao_btm_ptr;
char ao_btm_dir;
@@ -76,6 +76,7 @@ ao_btm_dump(void)
{
int i;
char c;
+ uint16_t r;
for (i = 0; i < ao_btm_ptr; i++) {
c = ao_btm_buffer[i];
@@ -85,8 +86,8 @@ ao_btm_dump(void)
putchar(ao_btm_buffer[i]);
}
putchar('\n');
- ao_cmd_decimal();
- if (ao_cmd_status == ao_cmd_success && ao_cmd_lex_i)
+ r = ao_cmd_decimal();
+ if (ao_cmd_status == ao_cmd_success && r)
ao_btm_ptr = 0;
ao_cmd_status = ao_cmd_success;
}
@@ -94,13 +95,17 @@ ao_btm_dump(void)
static void
ao_btm_speed(void)
{
- ao_cmd_decimal();
- if (ao_cmd_lex_u32 == 57600)
+ switch (ao_cmd_decimal()) {
+ case 57600:
ao_serial_btm_set_speed(AO_SERIAL_SPEED_57600);
- else if (ao_cmd_lex_u32 == 19200)
+ break;
+ case 19200:
ao_serial_btm_set_speed(AO_SERIAL_SPEED_19200);
- else
+ break;
+ default:
ao_cmd_status = ao_cmd_syntax_error;
+ break;
+ }
}
static uint8_t ao_btm_enable;
@@ -137,7 +142,7 @@ ao_btm_send(void)
ao_wakeup((void *) &ao_serial_btm_rx_fifo);
}
-__code struct ao_cmds ao_btm_cmds[] = {
+const struct ao_cmds ao_btm_cmds[] = {
{ ao_btm_dump, "d\0Dump btm buffer." },
{ ao_btm_speed, "s <19200,57600>\0Set btm serial speed." },
{ ao_btm_send, "S\0BTM interactive mode. ~ to exit." },
@@ -153,7 +158,7 @@ __code struct ao_cmds ao_btm_cmds[] = {
#endif
#define AO_BTM_MAX_REPLY 16
-__xdata char ao_btm_reply[AO_BTM_MAX_REPLY];
+char ao_btm_reply[AO_BTM_MAX_REPLY];
/*
* Read one bluetooth character.
@@ -252,7 +257,7 @@ ao_btm_wait_reply(void)
}
void
-ao_btm_string(__code char *cmd)
+ao_btm_string(const char *cmd)
{
char c;
@@ -261,7 +266,7 @@ ao_btm_string(__code char *cmd)
}
uint8_t
-ao_btm_cmd(__code char *cmd)
+ao_btm_cmd(const char *cmd)
{
ao_btm_drain();
@@ -342,7 +347,7 @@ ao_btm_check_link()
);
#else
ao_arch_block_interrupts();
- if (ao_gpio_get(AO_BTM_INT_PORT, AO_BTM_INT_PIN, AO_BTM_INT) == 0) {
+ if (ao_gpio_get(AO_BTM_INT_PORT, AO_BTM_INT_PIN) == 0) {
ao_btm_connected = 1;
} else {
ao_btm_connected = 0;
@@ -351,7 +356,7 @@ ao_btm_check_link()
#endif
}
-__xdata struct ao_task ao_btm_task;
+struct ao_task ao_btm_task;
/*
* A thread to initialize the bluetooth device and
@@ -450,7 +455,7 @@ ao_btm_init (void)
ao_serial_btm_set_speed(AO_SERIAL_SPEED_19200);
#ifdef AO_BTM_RESET_PORT
- ao_enable_output(AO_BTM_RESET_PORT,AO_BTM_RESET_PIN,AO_BTM_RESET,0);
+ ao_enable_output(AO_BTM_RESET_PORT,AO_BTM_RESET_PIN,0);
#endif
#ifdef AO_BTM_INT_PORT
diff --git a/src/drivers/ao_button.c b/src/drivers/ao_button.c
index f6a9676b..c8103e88 100644
--- a/src/drivers/ao_button.c
+++ b/src/drivers/ao_button.c
@@ -37,7 +37,6 @@ static struct ao_button_state ao_button_state[AO_BUTTON_COUNT];
#define port(q) AO_BUTTON_ ## q ## _PORT
#define bit(q) AO_BUTTON_ ## q
-#define pin(q) AO_BUTTON_ ## q ## _PIN
#ifndef AO_BUTTON_INVERTED
#define AO_BUTTON_INVERTED 1
@@ -45,9 +44,9 @@ static struct ao_button_state ao_button_state[AO_BUTTON_COUNT];
#if AO_BUTTON_INVERTED
/* pins are inverted */
-#define ao_button_value(b) !ao_gpio_get(port(b), bit(b), pin(b))
+#define ao_button_value(b) !ao_gpio_get(port(b), bit(b))
#else
-#define ao_button_value(b) ao_gpio_get(port(b), bit(b), pin(b))
+#define ao_button_value(b) ao_gpio_get(port(b), bit(b))
#endif
static uint8_t
diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c
index 2f091485..b1a13778 100644
--- a/src/drivers/ao_cc1120.c
+++ b/src/drivers/ao_cc1120.c
@@ -208,7 +208,7 @@ ao_radio_fifo_write_fixed(uint8_t data, uint8_t len)
static uint8_t
ao_radio_int_pin(void)
{
- return ao_gpio_get(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN, AO_CC1120_INT);
+ return ao_gpio_get(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN);
}
#if CC1120_DEBUG
@@ -805,8 +805,7 @@ ao_radio_test_cmd(void)
static uint8_t radio_on;
ao_cmd_white();
if (ao_cmd_lex_c != '\n') {
- ao_cmd_decimal();
- mode = (uint8_t) ao_cmd_lex_u32;
+ mode = ao_cmd_decimal();
}
mode++;
if ((mode & 2) && !radio_on) {
@@ -1066,7 +1065,7 @@ ao_radio_rx_wait(void)
}
uint8_t
-ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout)
+ao_radio_recv(void *d, uint8_t size, uint8_t timeout)
{
uint8_t len;
uint8_t radio_rssi = 0;
diff --git a/src/drivers/ao_cc115l.c b/src/drivers/ao_cc115l.c
index c1c21e0d..a8f2c4f5 100644
--- a/src/drivers/ao_cc115l.c
+++ b/src/drivers/ao_cc115l.c
@@ -700,10 +700,8 @@ ao_radio_test_cmd(void)
uint8_t mode = 2;
static uint8_t radio_on;
ao_cmd_white();
- if (ao_cmd_lex_c != '\n') {
- ao_cmd_decimal();
- mode = (uint8_t) ao_cmd_lex_u32;
- }
+ if (ao_cmd_lex_c != '\n')
+ mode = ao_cmd_decimal();
mode++;
if ((mode & 2) && !radio_on) {
#if HAS_MONITOR
diff --git a/src/drivers/ao_cc1200.c b/src/drivers/ao_cc1200.c
index de282000..105e0d50 100644
--- a/src/drivers/ao_cc1200.c
+++ b/src/drivers/ao_cc1200.c
@@ -192,7 +192,7 @@ ao_radio_fifo_write_fixed(uint8_t data, uint8_t len)
static uint8_t
ao_radio_int_pin(void)
{
- return ao_gpio_get(AO_CC1200_INT_PORT, AO_CC1200_INT_PIN, AO_CC1200_INT);
+ return ao_gpio_get(AO_CC1200_INT_PORT, AO_CC1200_INT_PIN);
}
static uint8_t
@@ -858,10 +858,8 @@ ao_radio_test_cmd(void)
{
uint8_t mode = 2;
ao_cmd_white();
- if (ao_cmd_lex_c != '\n') {
- ao_cmd_decimal();
- mode = (uint8_t) ao_cmd_lex_u32;
- }
+ if (ao_cmd_lex_c != '\n')
+ mode = ao_cmd_decimal();
mode++;
if ((mode & 2))
ao_radio_test_on();
@@ -988,7 +986,7 @@ ao_radio_dump_state(struct ao_radio_state *s)
#endif
uint8_t
-ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout)
+ao_radio_recv(void *d, uint8_t size, uint8_t timeout)
{
uint8_t success = 0;
@@ -1362,14 +1360,15 @@ ao_radio_aprs(void)
static void
ao_radio_strobe_test(void)
{
+ uint8_t addr;
uint8_t r;
- ao_cmd_hex();
+ addr = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
- r = ao_radio_strobe(ao_cmd_lex_i);
+ r = ao_radio_strobe(addr);
printf ("Strobe %02x -> %02x (rdy %d state %d)\n",
- ao_cmd_lex_i,
+ addr,
r,
r >> 7,
(r >> 4) & 0x7);
@@ -1381,14 +1380,12 @@ ao_radio_write_test(void)
uint16_t addr;
uint8_t data;
- ao_cmd_hex();
+ addr = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
- addr = ao_cmd_lex_i;
- ao_cmd_hex();
+ data = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
- data = ao_cmd_lex_i;
printf ("Write %04x = %02x\n", addr, data);
ao_radio_reg_write(addr, data);
}
@@ -1399,10 +1396,9 @@ ao_radio_read_test(void)
uint16_t addr;
uint8_t data;
- ao_cmd_hex();
+ addr = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
- addr = ao_cmd_lex_i;
data = ao_radio_reg_read(addr);
printf ("Read %04x = %02x\n", addr, data);
}
diff --git a/src/drivers/ao_companion.c b/src/drivers/ao_companion.c
index f82558a3..44868fb6 100644
--- a/src/drivers/ao_companion.c
+++ b/src/drivers/ao_companion.c
@@ -31,7 +31,6 @@
#define COMPANION_SELECT() do { \
ao_spi_get_bit(AO_COMPANION_CS_PORT, \
AO_COMPANION_CS_PIN, \
- AO_COMPANION_CS, \
AO_COMPANION_SPI_BUS, \
AO_SPI_SPEED_200kHz); \
} while (0)
@@ -39,16 +38,15 @@
#define COMPANION_DESELECT() do { \
ao_spi_put_bit(AO_COMPANION_CS_PORT, \
AO_COMPANION_CS_PIN, \
- AO_COMPANION_CS, \
AO_COMPANION_SPI_BUS); \
} while (0)
-__xdata struct ao_companion_command ao_companion_command;
-__xdata struct ao_companion_setup ao_companion_setup;
+struct ao_companion_command ao_companion_command;
+struct ao_companion_setup ao_companion_setup;
-__xdata uint16_t ao_companion_data[AO_COMPANION_MAX_CHANNELS];
-__pdata uint8_t ao_companion_running;
-__xdata uint8_t ao_companion_mutex;
+uint16_t ao_companion_data[AO_COMPANION_MAX_CHANNELS];
+uint8_t ao_companion_running;
+uint8_t ao_companion_mutex;
static void
ao_companion_send_command(uint8_t command)
@@ -107,7 +105,7 @@ ao_companion(void)
break;
}
while (ao_companion_running) {
- if (ao_sleep_for(DATA_TO_XDATA(&ao_flight_state), ao_companion_setup.update_period))
+ if (ao_sleep_for(&ao_flight_state, ao_companion_setup.update_period))
ao_companion_get_data();
else
ao_companion_notify();
@@ -116,7 +114,7 @@ ao_companion(void)
}
void
-ao_companion_status(void) __reentrant
+ao_companion_status(void)
{
uint8_t i;
printf("Companion running: %d\n", ao_companion_running);
@@ -134,17 +132,17 @@ ao_companion_status(void) __reentrant
printf("\n");
}
-__code struct ao_cmds ao_companion_cmds[] = {
+const struct ao_cmds ao_companion_cmds[] = {
{ ao_companion_status, "L\0Companion link status" },
{ 0, NULL },
};
-static __xdata struct ao_task ao_companion_task;
+static struct ao_task ao_companion_task;
void
ao_companion_init(void)
{
- ao_enable_output(AO_COMPANION_CS_PORT, AO_COMPANION_CS_PIN, AO_COMPANION_CS, 1);
+ ao_enable_output(AO_COMPANION_CS_PORT, AO_COMPANION_CS_PIN, 1);
ao_cmd_register(&ao_companion_cmds[0]);
ao_add_task(&ao_companion_task, ao_companion, "companion");
}
diff --git a/src/drivers/ao_fat.c b/src/drivers/ao_fat.c
index 43e7df23..e9ff2789 100644
--- a/src/drivers/ao_fat.c
+++ b/src/drivers/ao_fat.c
@@ -990,7 +990,7 @@ ao_fat_sync(void)
/*
* ao_fat_full
*
- * Returns TRUE if the filesystem cannot take
+ * Returns true if the filesystem cannot take
* more data
*/
diff --git a/src/drivers/ao_gps_sirf.c b/src/drivers/ao_gps_sirf.c
index 8bebd610..bdd9410e 100644
--- a/src/drivers/ao_gps_sirf.c
+++ b/src/drivers/ao_gps_sirf.c
@@ -20,11 +20,11 @@
#include "ao.h"
#endif
-__xdata uint8_t ao_gps_new;
-__xdata uint8_t ao_gps_mutex;
-__pdata uint16_t ao_gps_tick;
-__xdata struct ao_telemetry_location ao_gps_data;
-__xdata struct ao_telemetry_satellite ao_gps_tracking_data;
+uint8_t ao_gps_new;
+uint8_t ao_gps_mutex;
+uint16_t ao_gps_tick;
+struct ao_telemetry_location ao_gps_data;
+struct ao_telemetry_satellite ao_gps_tracking_data;
static const char ao_gps_set_nmea[] = "\r\n$PSRF100,0,57600,8,1,0*37\r\n";
@@ -107,7 +107,7 @@ struct sirf_geodetic_nav_data {
uint8_t hdop;
};
-static __xdata struct sirf_geodetic_nav_data ao_sirf_data;
+static struct sirf_geodetic_nav_data ao_sirf_data;
struct sirf_measured_sat_data {
uint8_t svid;
@@ -121,10 +121,10 @@ struct sirf_measured_tracker_data {
struct sirf_measured_sat_data sats[12];
};
-static __xdata struct sirf_measured_tracker_data ao_sirf_tracker_data;
+static struct sirf_measured_tracker_data ao_sirf_tracker_data;
-static __pdata uint16_t ao_sirf_cksum;
-static __pdata uint16_t ao_sirf_len;
+static uint16_t ao_sirf_cksum;
+static uint16_t ao_sirf_len;
#ifndef ao_sirf_getchar
#define ao_sirf_getchar ao_serial1_getchar
@@ -142,11 +142,11 @@ static uint8_t data_byte(void)
return c;
}
-static char __xdata *sirf_target;
+static char *sirf_target;
static void sirf_u16(uint8_t offset)
{
- uint16_t __xdata *ptr = (uint16_t __xdata *) (sirf_target + offset);
+ uint16_t *ptr = (uint16_t *) (sirf_target + offset);
uint16_t val;
val = data_byte() << 8;
@@ -156,16 +156,16 @@ static void sirf_u16(uint8_t offset)
static void sirf_u8(uint8_t offset)
{
- uint8_t __xdata *ptr = (uint8_t __xdata *) (sirf_target + offset);
+ uint8_t *ptr = (uint8_t *) (sirf_target + offset);
uint8_t val;
val = data_byte ();
*ptr = val;
}
-static void sirf_u32(uint8_t offset) __reentrant
+static void sirf_u32(uint8_t offset)
{
- uint32_t __xdata *ptr = (uint32_t __xdata *) (sirf_target + offset);
+ uint32_t *ptr = (uint32_t *) (sirf_target + offset);
uint32_t val;
val = ((uint32_t) data_byte ()) << 24;
@@ -194,7 +194,7 @@ struct sirf_packet_parse {
};
static void
-ao_sirf_parse(void __xdata *target, const struct sirf_packet_parse *parse) __reentrant
+ao_sirf_parse(void *target, const struct sirf_packet_parse *parse)
{
uint8_t i, offset, j;
@@ -258,7 +258,7 @@ static const struct sirf_packet_parse geodetic_nav_data_packet[] = {
};
static void
-ao_sirf_parse_41(void) __reentrant
+ao_sirf_parse_41(void)
{
ao_sirf_parse(&ao_sirf_data, geodetic_nav_data_packet);
}
@@ -279,7 +279,7 @@ static const struct sirf_packet_parse measured_sat_data_packet[] = {
};
static void
-ao_sirf_parse_4(void) __reentrant
+ao_sirf_parse_4(void)
{
uint8_t i;
ao_sirf_parse(&ao_sirf_tracker_data, measured_tracker_data_packet);
@@ -288,7 +288,7 @@ ao_sirf_parse_4(void) __reentrant
}
static void
-ao_gps_setup(void) __reentrant
+ao_gps_setup(void)
{
uint8_t i, k;
ao_sirf_set_speed(AO_SERIAL_SPEED_4800);
@@ -309,7 +309,7 @@ static const char ao_gps_set_message_rate[] = {
};
void
-ao_sirf_set_message_rate(uint8_t msg, uint8_t rate) __reentrant
+ao_sirf_set_message_rate(uint8_t msg, uint8_t rate)
{
uint16_t cksum = 0x00a6;
uint8_t i;
@@ -337,7 +337,7 @@ static const uint8_t sirf_disable[] = {
};
void
-ao_gps(void) __reentrant
+ao_gps(void)
{
uint8_t i, k;
uint16_t cksum;
@@ -443,7 +443,7 @@ ao_gps(void) __reentrant
}
}
-__xdata struct ao_task ao_gps_task;
+struct ao_task ao_gps_task;
void
ao_gps_init(void)
diff --git a/src/drivers/ao_gps_skytraq.c b/src/drivers/ao_gps_skytraq.c
index c483382e..193f20dc 100644
--- a/src/drivers/ao_gps_skytraq.c
+++ b/src/drivers/ao_gps_skytraq.c
@@ -33,20 +33,20 @@
#define ao_gps_set_speed ao_serial1_set_speed
#endif
-__xdata uint8_t ao_gps_new;
-__xdata uint8_t ao_gps_mutex;
-static __data char ao_gps_char;
-static __data uint8_t ao_gps_cksum;
-static __data uint8_t ao_gps_error;
+uint8_t ao_gps_new;
+uint8_t ao_gps_mutex;
+static char ao_gps_char;
+static uint8_t ao_gps_cksum;
+static uint8_t ao_gps_error;
-__pdata uint16_t ao_gps_tick;
-__xdata struct ao_telemetry_location ao_gps_data;
-__xdata struct ao_telemetry_satellite ao_gps_tracking_data;
+uint16_t ao_gps_tick;
+struct ao_telemetry_location ao_gps_data;
+struct ao_telemetry_satellite ao_gps_tracking_data;
-static __pdata uint16_t ao_gps_next_tick;
-static __pdata struct ao_telemetry_location ao_gps_next;
-static __pdata uint8_t ao_gps_date_flags;
-static __pdata struct ao_telemetry_satellite ao_gps_tracking_next;
+static uint16_t ao_gps_next_tick;
+static struct ao_telemetry_location ao_gps_next;
+static uint8_t ao_gps_date_flags;
+static struct ao_telemetry_satellite ao_gps_tracking_next;
#define STQ_S 0xa0, 0xa1
#define STQ_E 0x0d, 0x0a
@@ -60,7 +60,7 @@ static __pdata struct ao_telemetry_satellite ao_gps_tracking_next;
STQ_S, 0,15, id, a,b,c,d,e,f,g,h,i,j,k,l,m,n, \
(id^a^b^c^d^e^f^g^h^i^j^k^l^m^n), STQ_E
-static __code uint8_t ao_gps_config[] = {
+static const uint8_t ao_gps_config[] = {
SKYTRAQ_MSG_8(0x08, 1, 0, 1, 0, 1, 0, 0, 0), /* configure nmea */
/* gga interval */
/* gsa interval */
@@ -107,7 +107,7 @@ ao_gps_skip_sep(void)
ao_gps_lexchar();
}
-__data static uint8_t ao_gps_num_width;
+static uint8_t ao_gps_num_width;
static int16_t
ao_gps_decimal(uint8_t max_width)
@@ -162,11 +162,11 @@ ao_gps_hex(void)
}
static int32_t
-ao_gps_parse_pos(uint8_t deg_width) __reentrant
+ao_gps_parse_pos(uint8_t deg_width)
{
- static __pdata uint16_t d;
- static __pdata uint8_t m;
- static __pdata uint16_t f;
+ static uint16_t d;
+ static uint8_t m;
+ static uint16_t f;
char c;
d = ao_gps_decimal(deg_width);
@@ -298,7 +298,7 @@ ao_nmea_gga(void)
ao_mutex_get(&ao_gps_mutex);
ao_gps_new |= AO_GPS_NEW_DATA;
ao_gps_tick = ao_gps_next_tick;
- ao_xmemcpy(&ao_gps_data, PDATA_TO_XDATA(&ao_gps_next), sizeof (ao_gps_data));
+ ao_xmemcpy(&ao_gps_data, &ao_gps_next, sizeof (ao_gps_data));
ao_mutex_put(&ao_gps_mutex);
ao_wakeup(&ao_gps_new);
}
@@ -357,7 +357,7 @@ ao_nmea_gsv(void)
else if (done) {
ao_mutex_get(&ao_gps_mutex);
ao_gps_new |= AO_GPS_NEW_TRACKING;
- ao_xmemcpy(&ao_gps_tracking_data, PDATA_TO_XDATA(&ao_gps_tracking_next), sizeof(ao_gps_tracking_data));
+ ao_xmemcpy(&ao_gps_tracking_data, &ao_gps_tracking_next, sizeof(ao_gps_tracking_data));
ao_mutex_put(&ao_gps_mutex);
ao_wakeup(&ao_gps_new);
}
@@ -414,7 +414,7 @@ ao_nmea_rmc(void)
#define ao_skytraq_sendstruct(s) ao_skytraq_sendbytes((s), sizeof(s))
static void
-ao_skytraq_sendbytes(__code uint8_t *b, uint8_t l)
+ao_skytraq_sendbytes(const uint8_t *b, uint8_t l)
{
while (l--) {
uint8_t c = *b++;
@@ -462,7 +462,7 @@ ao_gps_nmea_parse(void)
static uint8_t ao_gps_updating;
void
-ao_gps(void) __reentrant
+ao_gps(void)
{
ao_gps_set_speed(AO_SERIAL_SPEED_9600);
@@ -486,9 +486,9 @@ ao_gps(void) __reentrant
}
}
-__xdata struct ao_task ao_gps_task;
+struct ao_task ao_gps_task;
-static __code uint8_t ao_gps_115200[] = {
+static const uint8_t ao_gps_115200[] = {
SKYTRAQ_MSG_3(5,0,5,0) /* Set to 115200 baud */
};
@@ -500,7 +500,7 @@ ao_gps_set_speed_delay(uint8_t speed) {
}
static void
-gps_update(void) __reentrant
+gps_update(void)
{
ao_gps_updating = 1;
ao_task_minimize_latency = 1;
@@ -517,7 +517,7 @@ gps_update(void) __reentrant
ao_gps_putchar(ao_usb_getchar());
}
-__code struct ao_cmds ao_gps_cmds[] = {
+const struct ao_cmds ao_gps_cmds[] = {
{ ao_gps_show, "g\0Display GPS" },
{ gps_update, "U\0Update GPS firmware" },
{ 0, NULL },
diff --git a/src/drivers/ao_gps_ublox.c b/src/drivers/ao_gps_ublox.c
index c720f802..a6d93083 100644
--- a/src/drivers/ao_gps_ublox.c
+++ b/src/drivers/ao_gps_ublox.c
@@ -26,11 +26,11 @@
#include <stdarg.h>
-__xdata uint8_t ao_gps_new;
-__xdata uint8_t ao_gps_mutex;
-__pdata uint16_t ao_gps_tick;
-__xdata struct ao_telemetry_location ao_gps_data;
-__xdata struct ao_telemetry_satellite ao_gps_tracking_data;
+uint8_t ao_gps_new;
+uint8_t ao_gps_mutex;
+uint16_t ao_gps_tick;
+struct ao_telemetry_location ao_gps_data;
+struct ao_telemetry_satellite ao_gps_tracking_data;
#undef AO_SERIAL_SPEED_UBLOX
@@ -58,8 +58,8 @@ struct ao_ublox_cksum {
uint8_t a, b;
};
-static __pdata struct ao_ublox_cksum ao_ublox_cksum;
-static __pdata uint16_t ao_ublox_len;
+static struct ao_ublox_cksum ao_ublox_cksum;
+static uint16_t ao_ublox_len;
#if AO_UBLOX_DEBUG
@@ -152,11 +152,11 @@ static uint8_t data_byte(void)
return header_byte();
}
-static char __xdata *ublox_target;
+static char *ublox_target;
static void ublox_u16(uint8_t offset)
{
- uint16_t __xdata *ptr = (uint16_t __xdata *) (void __xdata *) (ublox_target + offset);
+ uint16_t *ptr = (uint16_t *) (void *) (ublox_target + offset);
uint16_t val;
val = data_byte();
@@ -166,16 +166,16 @@ static void ublox_u16(uint8_t offset)
static void ublox_u8(uint8_t offset)
{
- uint8_t __xdata *ptr = (uint8_t __xdata *) (ublox_target + offset);
+ uint8_t *ptr = (uint8_t *) (ublox_target + offset);
uint8_t val;
val = data_byte ();
*ptr = val;
}
-static void ublox_u32(uint8_t offset) __reentrant
+static void ublox_u32(uint8_t offset)
{
- uint32_t __xdata *ptr = (uint32_t __xdata *) (void __xdata *) (ublox_target + offset);
+ uint32_t *ptr = (uint32_t *) (void *) (ublox_target + offset);
uint32_t val;
val = ((uint32_t) data_byte ());
@@ -203,7 +203,7 @@ struct ublox_packet_parse {
};
static void
-ao_ublox_parse(void __xdata *target, const struct ublox_packet_parse *parse) __reentrant
+ao_ublox_parse(void *target, const struct ublox_packet_parse *parse)
{
uint8_t i, offset;
@@ -610,7 +610,7 @@ ao_gps_set_rate(uint8_t rate)
}
void
-ao_gps(void) __reentrant
+ao_gps(void)
{
uint8_t class, id;
struct ao_ublox_cksum cksum;
@@ -783,12 +783,12 @@ ao_gps(void) __reentrant
#if AO_UBLOX_DEBUG
static void ao_gps_option(void)
{
- ao_cmd_hex();
+ uint16_t r = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success) {
ao_cmd_status = ao_cmd_success;
ao_gps_show();
} else {
- ao_gps_dbg_enable = ao_cmd_lex_i;
+ ao_gps_dbg_enable = r;
printf ("gps debug set to %d\n", ao_gps_dbg_enable);
}
}
@@ -796,12 +796,12 @@ static void ao_gps_option(void)
#define ao_gps_option ao_gps_show
#endif
-__code struct ao_cmds ao_gps_cmds[] = {
+const struct ao_cmds ao_gps_cmds[] = {
{ ao_gps_option, "g\0Display GPS" },
{ 0, NULL },
};
-__xdata struct ao_task ao_gps_task;
+struct ao_task ao_gps_task;
void
ao_gps_init(void)
diff --git a/src/drivers/ao_hmc5883.c b/src/drivers/ao_hmc5883.c
index c33aa536..f4705708 100644
--- a/src/drivers/ao_hmc5883.c
+++ b/src/drivers/ao_hmc5883.c
@@ -35,7 +35,7 @@ ao_hmc5883_reg_write(uint8_t addr, uint8_t data)
d[1] = data;
ao_i2c_get(AO_HMC5883_I2C_INDEX);
ao_i2c_start(AO_HMC5883_I2C_INDEX, HMC5883_ADDR_WRITE);
- ao_i2c_send(d, 2, AO_HMC5883_I2C_INDEX, TRUE);
+ ao_i2c_send(d, 2, AO_HMC5883_I2C_INDEX, true);
ao_i2c_put(AO_HMC5883_I2C_INDEX);
ao_hmc5883_addr = addr + 1;
}
@@ -46,10 +46,10 @@ ao_hmc5883_read(uint8_t addr, uint8_t *data, uint8_t len)
ao_i2c_get(AO_HMC5883_I2C_INDEX);
if (addr != ao_hmc5883_addr) {
ao_i2c_start(AO_HMC5883_I2C_INDEX, HMC5883_ADDR_WRITE);
- ao_i2c_send(&addr, 1, AO_HMC5883_I2C_INDEX, FALSE);
+ ao_i2c_send(&addr, 1, AO_HMC5883_I2C_INDEX, false);
}
ao_i2c_start(AO_HMC5883_I2C_INDEX, HMC5883_ADDR_READ);
- ao_i2c_recv(data, len, AO_HMC5883_I2C_INDEX, TRUE);
+ ao_i2c_recv(data, len, AO_HMC5883_I2C_INDEX, true);
ao_i2c_put(AO_HMC5883_I2C_INDEX);
ao_hmc5883_addr = 0xff;
}
@@ -103,7 +103,7 @@ ao_hmc5883_setup(void)
ao_i2c_get(AO_HMC5883_I2C_INDEX);
present = ao_i2c_start(AO_HMC5883_I2C_INDEX, HMC5883_ADDR_READ);
- ao_i2c_recv(&d, 1, AO_HMC5883_I2C_INDEX, TRUE);
+ ao_i2c_recv(&d, 1, AO_HMC5883_I2C_INDEX, true);
ao_i2c_put(AO_HMC5883_I2C_INDEX);
if (!present)
diff --git a/src/drivers/ao_lcd.c b/src/drivers/ao_lcd.c
index c35093bc..294361eb 100644
--- a/src/drivers/ao_lcd.c
+++ b/src/drivers/ao_lcd.c
@@ -20,7 +20,7 @@
static uint16_t ao_lcd_time = 3;
-static __xdata uint8_t ao_lcd_mutex;
+static uint8_t ao_lcd_mutex;
static void
ao_lcd_delay(void)
diff --git a/src/drivers/ao_lco.c b/src/drivers/ao_lco.c
index e892c8c0..5f5db572 100644
--- a/src/drivers/ao_lco.c
+++ b/src/drivers/ao_lco.c
@@ -319,12 +319,12 @@ ao_lco_main(void)
void
ao_lco_set_debug(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status == ao_cmd_success)
- ao_lco_debug = ao_cmd_lex_i != 0;
+ ao_lco_debug = r != 0;
}
-__code struct ao_cmds ao_lco_cmds[] = {
+const struct ao_cmds ao_lco_cmds[] = {
{ ao_lco_set_debug, "D <0 off, 1 on>\0Debug" },
{ ao_lco_search, "s\0Search for pad boxes" },
{ 0, NULL }
diff --git a/src/drivers/ao_lco.h b/src/drivers/ao_lco.h
index 2958fbcc..cdc19d3d 100644
--- a/src/drivers/ao_lco.h
+++ b/src/drivers/ao_lco.h
@@ -35,7 +35,7 @@ extern uint8_t ao_lco_debug;
#endif
#if AO_LCO_DRAG
-extern uint8_t ao_lco_drag_race; /* TRUE when drag race mode enabled */
+extern uint8_t ao_lco_drag_race; /* true when drag race mode enabled */
#endif
extern uint8_t ao_lco_pad; /* Currently selected pad */
diff --git a/src/drivers/ao_lco_cmd.c b/src/drivers/ao_lco_cmd.c
index dba9a76a..6f195e55 100644
--- a/src/drivers/ao_lco_cmd.c
+++ b/src/drivers/ao_lco_cmd.c
@@ -26,17 +26,15 @@
#define HAS_STATIC_TEST 1
#endif
-static __pdata uint16_t lco_box;
-static __pdata uint8_t lco_channels;
-static __pdata uint16_t tick_offset;
+static uint16_t lco_box;
+static uint8_t lco_channels;
+static uint16_t tick_offset;
static void
-lco_args(void) __reentrant
+lco_args(void)
{
- ao_cmd_decimal();
- lco_box = ao_cmd_lex_i;
- ao_cmd_hex();
- lco_channels = ao_cmd_lex_i;
+ lco_box = ao_cmd_decimal();
+ lco_channels = ao_cmd_hex();
}
static struct ao_pad_query ao_pad_query;
@@ -71,7 +69,7 @@ lco_ignite(uint8_t cmd)
}
static void
-lco_report_cmd(void) __reentrant
+lco_report_cmd(void)
{
int8_t r;
uint8_t c;
@@ -122,15 +120,14 @@ lco_report_cmd(void) __reentrant
}
static void
-lco_fire_cmd(void) __reentrant
+lco_fire_cmd(void)
{
uint8_t secs;
uint8_t i;
int8_t r;
lco_args();
- ao_cmd_decimal();
- secs = ao_cmd_lex_i;
+ secs = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
r = lco_query();
@@ -156,15 +153,14 @@ lco_fire_cmd(void) __reentrant
#if HAS_STATIC_TEST
static void
-lco_static_cmd(void) __reentrant
+lco_static_cmd(void)
{
uint8_t secs;
uint8_t i;
int8_t r;
lco_args();
- ao_cmd_decimal();
- secs = ao_cmd_lex_i;
+ secs = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
r = lco_query();
@@ -190,7 +186,7 @@ lco_static_cmd(void) __reentrant
#endif
static void
-lco_arm_cmd(void) __reentrant
+lco_arm_cmd(void)
{
uint8_t i;
int8_t r;
@@ -205,7 +201,7 @@ lco_arm_cmd(void) __reentrant
}
static void
-lco_ignite_cmd(void) __reentrant
+lco_ignite_cmd(void)
{
uint8_t i;
lco_args();
@@ -216,13 +212,13 @@ lco_ignite_cmd(void) __reentrant
#if HAS_STATIC_TEST
static void
-lco_endstatic_cmd(void) __reentrant
+lco_endstatic_cmd(void)
{
lco_ignite(AO_PAD_ENDSTATIC);
}
#endif
-static __code struct ao_cmds ao_lco_cmds[] = {
+static const struct ao_cmds ao_lco_cmds[] = {
{ lco_report_cmd, "l <box> <channel>\0Get remote status" },
{ lco_fire_cmd, "F <box> <channel> <secs>\0Fire remote igniters" },
#if HAS_STATIC_TEST
diff --git a/src/drivers/ao_lco_func.c b/src/drivers/ao_lco_func.c
index 92b344ed..06350694 100644
--- a/src/drivers/ao_lco_func.c
+++ b/src/drivers/ao_lco_func.c
@@ -21,8 +21,8 @@
#include <ao_radio_cmac.h>
#include <ao_lco_func.h>
-static __xdata struct ao_pad_command command;
-static __xdata uint8_t ao_lco_mutex;
+static struct ao_pad_command command;
+static uint8_t ao_lco_mutex;
int8_t
ao_lco_query(uint16_t box, struct ao_pad_query *query, uint16_t *tick_offset)
diff --git a/src/drivers/ao_lco_two.c b/src/drivers/ao_lco_two.c
index 6f2d81ff..49ea1236 100644
--- a/src/drivers/ao_lco_two.c
+++ b/src/drivers/ao_lco_two.c
@@ -124,12 +124,12 @@ ao_lco_main(void)
void
ao_lco_set_debug(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status == ao_cmd_success)
- ao_lco_debug = ao_cmd_lex_i;
+ ao_lco_debug = r;
}
-__code struct ao_cmds ao_lco_cmds[] = {
+const struct ao_cmds ao_lco_cmds[] = {
{ ao_lco_set_debug, "D <0 off, 1 on>\0Debug" },
{ 0, NULL }
};
diff --git a/src/drivers/ao_led.c b/src/drivers/ao_led.c
new file mode 100644
index 00000000..0f7b7c27
--- /dev/null
+++ b/src/drivers/ao_led.c
@@ -0,0 +1,174 @@
+/*
+ * Copyright © 2018 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"
+
+static const struct {
+ struct stm_gpio *port;
+ uint16_t pin;
+} ao_leds[] = {
+#ifdef LED_0_PORT
+ [0] { LED_0_PORT, LED_0_PIN },
+#endif
+#ifdef LED_1_PORT
+ [1] { LED_1_PORT, LED_1_PIN },
+#endif
+#ifdef LED_2_PORT
+ [2] { LED_2_PORT, LED_2_PIN },
+#endif
+#ifdef LED_3_PORT
+ [3] { LED_3_PORT, LED_3_PIN },
+#endif
+#ifdef LED_4_PORT
+ [4] { LED_4_PORT, LED_4_PIN },
+#endif
+#ifdef LED_5_PORT
+ [5] { LED_5_PORT, LED_5_PIN },
+#endif
+#ifdef LED_6_PORT
+ [6] { LED_6_PORT, LED_6_PIN },
+#endif
+#ifdef LED_7_PORT
+ [7] { LED_7_PORT, LED_7_PIN },
+#endif
+#ifdef LED_8_PORT
+ [8] { LED_8_PORT, LED_8_PIN },
+#endif
+#ifdef LED_9_PORT
+ [9] { LED_9_PORT, LED_9_PIN },
+#endif
+#ifdef LED_10_PORT
+ [10] { LED_10_PORT, LED_10_PIN },
+#endif
+#ifdef LED_11_PORT
+ [11] { LED_11_PORT, LED_11_PIN },
+#endif
+#ifdef LED_12_PORT
+ [12] { LED_12_PORT, LED_12_PIN },
+#endif
+#ifdef LED_13_PORT
+ [13] { LED_13_PORT, LED_13_PIN },
+#endif
+#ifdef LED_14_PORT
+ [14] { LED_14_PORT, LED_14_PIN },
+#endif
+#ifdef LED_15_PORT
+ [15] { LED_15_PORT, LED_15_PIN },
+#endif
+#ifdef LED_16_PORT
+ [16] { LED_16_PORT, LED_16_PIN },
+#endif
+#ifdef LED_17_PORT
+ [17] { LED_17_PORT, LED_17_PIN },
+#endif
+#ifdef LED_18_PORT
+ [18] { LED_18_PORT, LED_18_PIN },
+#endif
+#ifdef LED_19_PORT
+ [19] { LED_19_PORT, LED_19_PIN },
+#endif
+#ifdef LED_20_PORT
+ [20] { LED_20_PORT, LED_20_PIN },
+#endif
+#ifdef LED_21_PORT
+ [21] { LED_21_PORT, LED_21_PIN },
+#endif
+#ifdef LED_22_PORT
+ [22] { LED_22_PORT, LED_22_PIN },
+#endif
+#ifdef LED_23_PORT
+ [23] { LED_23_PORT, LED_23_PIN },
+#endif
+#ifdef LED_24_PORT
+ [24] { LED_24_PORT, LED_24_PIN },
+#endif
+#ifdef LED_25_PORT
+ [25] { LED_25_PORT, LED_25_PIN },
+#endif
+#ifdef LED_26_PORT
+ [26] { LED_26_PORT, LED_26_PIN },
+#endif
+#ifdef LED_27_PORT
+ [27] { LED_27_PORT, LED_27_PIN },
+#endif
+#ifdef LED_28_PORT
+ [28] { LED_28_PORT, LED_28_PIN },
+#endif
+#ifdef LED_29_PORT
+ [29] { LED_29_PORT, LED_29_PIN },
+#endif
+#ifdef LED_30_PORT
+ [30] { LED_30_PORT, LED_30_PIN },
+#endif
+#ifdef LED_31_PORT
+ [31] { LED_31_PORT, LED_31_PIN },
+#endif
+};
+#define N_LED (sizeof (ao_leds)/sizeof(ao_leds[0]))
+
+void
+ao_led_on(AO_LED_TYPE colors)
+{
+ AO_LED_TYPE i;
+ for (i = 0; i < N_LED; i++)
+ if (colors & (1 << i))
+ ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, 1);
+}
+
+void
+ao_led_off(AO_LED_TYPE colors)
+{
+ AO_LED_TYPE i;
+ for (i = 0; i < N_LED; i++)
+ if (colors & (1 << i))
+ ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, 0);
+}
+
+void
+ao_led_set(AO_LED_TYPE colors)
+{
+ AO_LED_TYPE i;
+ for (i = 0; i < N_LED; i++)
+ ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, (colors >> i) & 1);
+}
+
+void
+ao_led_toggle(AO_LED_TYPE colors)
+{
+ AO_LED_TYPE i;
+ for (i = 0; i < N_LED; i++)
+ if (colors & (1 << i))
+ ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, ~ao_gpio_get(ao_leds[i].port, ao_leds[i].pin));
+}
+
+void
+ao_led_for(AO_LED_TYPE colors, AO_TICK_TYPE ticks)
+{
+ ao_led_on(colors);
+ ao_delay(ticks);
+ ao_led_off(colors);
+}
+
+void
+ao_led_init(void)
+{
+ AO_LED_TYPE bit;
+
+ for (bit = 0; bit < N_LED; bit++)
+ ao_enable_output(ao_leds[bit].port, ao_leds[bit].pin, 0);
+}
diff --git a/src/drivers/ao_m25.c b/src/drivers/ao_m25.c
index b506b0a7..72617cc4 100644
--- a/src/drivers/ao_m25.c
+++ b/src/drivers/ao_m25.c
@@ -19,16 +19,16 @@
#include "ao.h"
/* Total bytes of available storage */
-__pdata uint32_t ao_storage_total;
+uint32_t ao_storage_total;
/* Block size - device is erased in these units. At least 256 bytes */
-__pdata uint32_t ao_storage_block;
+uint32_t ao_storage_block;
/* Byte offset of config block. Will be ao_storage_block bytes long */
-__pdata uint32_t ao_storage_config;
+uint32_t ao_storage_config;
/* Storage unit size - device reads and writes must be within blocks of this size. Usually 256 bytes. */
-__pdata uint16_t ao_storage_unit;
+uint16_t ao_storage_unit;
#define M25_DEBUG 0
/*
@@ -89,7 +89,7 @@ static uint8_t ao_m25_numchips; /* number of chips detected */
static uint8_t ao_m25_total; /* total sectors available */
static ao_port_t ao_m25_wip; /* write in progress */
-static __xdata uint8_t ao_m25_mutex;
+static uint8_t ao_m25_mutex;
/*
* This little array is abused to send and receive data. A particular
@@ -99,7 +99,7 @@ static __xdata uint8_t ao_m25_mutex;
* of which touch those last three bytes.
*/
-static __xdata uint8_t ao_m25_instruction[4];
+static uint8_t ao_m25_instruction[4];
#define M25_SELECT(cs) ao_spi_get_mask(AO_M25_SPI_CS_PORT,cs,AO_M25_SPI_BUS, AO_SPI_SPEED_FAST)
#define M25_DESELECT(cs) ao_spi_put_mask(AO_M25_SPI_CS_PORT,cs,AO_M25_SPI_BUS)
@@ -239,7 +239,7 @@ ao_m25_scan(void)
* Erase the specified sector
*/
uint8_t
-ao_storage_erase(uint32_t pos) __reentrant
+ao_storage_erase(uint32_t pos)
{
ao_port_t cs;
@@ -267,7 +267,7 @@ ao_storage_erase(uint32_t pos) __reentrant
* Write to flash
*/
uint8_t
-ao_storage_device_write(uint32_t pos, __xdata void *d, uint16_t len) __reentrant
+ao_storage_device_write(uint32_t pos, void *d, uint16_t len)
{
ao_port_t cs;
@@ -294,7 +294,7 @@ ao_storage_device_write(uint32_t pos, __xdata void *d, uint16_t len) __reentrant
* Read from flash
*/
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)
{
ao_port_t cs;
@@ -317,7 +317,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)
{
}
@@ -330,7 +330,7 @@ ao_storage_setup(void)
}
void
-ao_storage_device_info(void) __reentrant
+ao_storage_device_info(void)
{
#if M25_DEBUG
ao_port_t cs;
diff --git a/src/drivers/ao_mma655x.c b/src/drivers/ao_mma655x.c
index 5d44bffd..e8eeea6e 100644
--- a/src/drivers/ao_mma655x.c
+++ b/src/drivers/ao_mma655x.c
@@ -34,7 +34,6 @@ static void
ao_mma655x_start(void) {
ao_spi_get_bit(AO_MMA655X_CS_PORT,
AO_MMA655X_CS_PIN,
- AO_MMA655X_CS,
AO_MMA655X_SPI_INDEX,
AO_SPI_SPEED_FAST);
}
@@ -43,19 +42,18 @@ static void
ao_mma655x_stop(void) {
ao_spi_put_bit(AO_MMA655X_CS_PORT,
AO_MMA655X_CS_PIN,
- AO_MMA655X_CS,
AO_MMA655X_SPI_INDEX);
}
static void
ao_mma655x_restart(void) {
uint8_t i;
- ao_gpio_set(AO_MMA655X_CS_PORT, AO_MMA655X_CS_PIN, AO_MMA655X_CS, 1);
+ ao_gpio_set(AO_MMA655X_CS_PORT, AO_MMA655X_CS_PIN, 1);
/* Emperical testing on STM32L151 at 32MHz for this delay amount */
for (i = 0; i < 10; i++)
ao_arch_nop();
- ao_gpio_set(AO_MMA655X_CS_PORT, AO_MMA655X_CS_PIN, AO_MMA655X_CS, 0);
+ ao_gpio_set(AO_MMA655X_CS_PORT, AO_MMA655X_CS_PIN, 0);
}
static uint8_t
@@ -259,7 +257,7 @@ ao_mma655x_dump(void)
printf ("MMA655X value %d\n", ao_mma655x_current);
}
-__code struct ao_cmds ao_mma655x_cmds[] = {
+const struct ao_cmds ao_mma655x_cmds[] = {
{ ao_mma655x_dump, "A\0Display MMA655X data" },
{ 0, NULL },
};
@@ -277,7 +275,7 @@ ao_mma655x(void)
}
}
-static __xdata struct ao_task ao_mma655x_task;
+static struct ao_task ao_mma655x_task;
void
ao_mma655x_init(void)
diff --git a/src/drivers/ao_mpu6000.c b/src/drivers/ao_mpu6000.c
index 81d3c16c..8c85ab01 100644
--- a/src/drivers/ao_mpu6000.c
+++ b/src/drivers/ao_mpu6000.c
@@ -55,7 +55,7 @@ _ao_mpu6000_reg_write(uint8_t addr, uint8_t value)
#else
ao_i2c_get(AO_MPU6000_I2C_INDEX);
ao_i2c_start(AO_MPU6000_I2C_INDEX, MPU6000_ADDR_WRITE);
- ao_i2c_send(d, 2, AO_MPU6000_I2C_INDEX, TRUE);
+ ao_i2c_send(d, 2, AO_MPU6000_I2C_INDEX, true);
ao_i2c_put(AO_MPU6000_I2C_INDEX);
#endif
}
@@ -72,9 +72,9 @@ _ao_mpu6000_read(uint8_t addr, void *data, uint8_t len)
#else
ao_i2c_get(AO_MPU6000_I2C_INDEX);
ao_i2c_start(AO_MPU6000_I2C_INDEX, MPU6000_ADDR_WRITE);
- ao_i2c_send(&addr, 1, AO_MPU6000_I2C_INDEX, FALSE);
+ ao_i2c_send(&addr, 1, AO_MPU6000_I2C_INDEX, false);
ao_i2c_start(AO_MPU6000_I2C_INDEX, MPU6000_ADDR_READ);
- ao_i2c_recv(data, len, AO_MPU6000_I2C_INDEX, TRUE);
+ ao_i2c_recv(data, len, AO_MPU6000_I2C_INDEX, true);
ao_i2c_put(AO_MPU6000_I2C_INDEX);
#endif
}
@@ -92,9 +92,9 @@ _ao_mpu6000_reg_read(uint8_t addr)
#else
ao_i2c_get(AO_MPU6000_I2C_INDEX);
ao_i2c_start(AO_MPU6000_I2C_INDEX, MPU6000_ADDR_WRITE);
- ao_i2c_send(&addr, 1, AO_MPU6000_I2C_INDEX, FALSE);
+ ao_i2c_send(&addr, 1, AO_MPU6000_I2C_INDEX, false);
ao_i2c_start(AO_MPU6000_I2C_INDEX, MPU6000_ADDR_READ);
- ao_i2c_recv(&value, 1, AO_MPU6000_I2C_INDEX, TRUE);
+ ao_i2c_recv(&value, 1, AO_MPU6000_I2C_INDEX, true);
ao_i2c_put(AO_MPU6000_I2C_INDEX);
#endif
return value;
diff --git a/src/drivers/ao_mpu9250.c b/src/drivers/ao_mpu9250.c
index ae8dacd0..74e444a9 100644
--- a/src/drivers/ao_mpu9250.c
+++ b/src/drivers/ao_mpu9250.c
@@ -63,7 +63,7 @@ _ao_mpu9250_reg_write(uint8_t addr, uint8_t value)
#else
ao_i2c_get(AO_MPU9250_I2C_INDEX);
ao_i2c_start(AO_MPU9250_I2C_INDEX, MPU9250_ADDR_WRITE);
- ao_i2c_send(d, 2, AO_MPU9250_I2C_INDEX, TRUE);
+ ao_i2c_send(d, 2, AO_MPU9250_I2C_INDEX, true);
ao_i2c_put(AO_MPU9250_I2C_INDEX);
#endif
}
@@ -80,9 +80,9 @@ _ao_mpu9250_read(uint8_t addr, void *data, uint8_t len)
#else
ao_i2c_get(AO_MPU9250_I2C_INDEX);
ao_i2c_start(AO_MPU9250_I2C_INDEX, MPU9250_ADDR_WRITE);
- ao_i2c_send(&addr, 1, AO_MPU9250_I2C_INDEX, FALSE);
+ ao_i2c_send(&addr, 1, AO_MPU9250_I2C_INDEX, false);
ao_i2c_start(AO_MPU9250_I2C_INDEX, MPU9250_ADDR_READ);
- ao_i2c_recv(data, len, AO_MPU9250_I2C_INDEX, TRUE);
+ ao_i2c_recv(data, len, AO_MPU9250_I2C_INDEX, true);
ao_i2c_put(AO_MPU9250_I2C_INDEX);
#endif
}
@@ -100,9 +100,9 @@ _ao_mpu9250_reg_read(uint8_t addr)
#else
ao_i2c_get(AO_MPU9250_I2C_INDEX);
ao_i2c_start(AO_MPU9250_I2C_INDEX, MPU9250_ADDR_WRITE);
- ao_i2c_send(&addr, 1, AO_MPU9250_I2C_INDEX, FALSE);
+ ao_i2c_send(&addr, 1, AO_MPU9250_I2C_INDEX, false);
ao_i2c_start(AO_MPU9250_I2C_INDEX, MPU9250_ADDR_READ);
- ao_i2c_recv(&value, 1, AO_MPU9250_I2C_INDEX, TRUE);
+ ao_i2c_recv(&value, 1, AO_MPU9250_I2C_INDEX, true);
ao_i2c_put(AO_MPU9250_I2C_INDEX);
#endif
return value;
@@ -472,10 +472,9 @@ ao_mpu9250_read(void)
uint8_t addr;
uint8_t val;
- ao_cmd_hex();
+ addr = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
- addr = ao_cmd_lex_i;
ao_mpu9250_spi_get();
val = _ao_mpu9250_reg_read(addr);
ao_mpu9250_spi_put();
@@ -488,14 +487,12 @@ ao_mpu9250_write(void)
uint8_t addr;
uint8_t val;
- ao_cmd_hex();
+ addr = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
- addr = ao_cmd_lex_i;
- ao_cmd_hex();
+ val = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
- val = ao_cmd_lex_i;
printf("Addr %02x val %02x\n", addr, val);
ao_mpu9250_spi_get();
_ao_mpu9250_reg_write(addr, val);
@@ -508,10 +505,9 @@ ao_mpu9250_mag_read(void)
uint8_t addr;
uint8_t val;
- ao_cmd_hex();
+ addr = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
- addr = ao_cmd_lex_i;
ao_mpu9250_spi_get();
val = _ao_mpu9250_mag_reg_read(addr);
ao_mpu9250_spi_put();
@@ -524,14 +520,12 @@ ao_mpu9250_mag_write(void)
uint8_t addr;
uint8_t val;
- ao_cmd_hex();
+ addr = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
- addr = ao_cmd_lex_i;
- ao_cmd_hex();
+ val = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
- val = ao_cmd_lex_i;
printf("Addr %02x val %02x\n", addr, val);
ao_mpu9250_spi_get();
_ao_mpu9250_mag_reg_write(addr, val);
diff --git a/src/drivers/ao_mr25.c b/src/drivers/ao_mr25.c
index 2d355c9f..86dda22a 100644
--- a/src/drivers/ao_mr25.c
+++ b/src/drivers/ao_mr25.c
@@ -19,16 +19,16 @@
#include "ao.h"
/* Total bytes of available storage */
-__pdata uint32_t ao_storage_total;
+uint32_t ao_storage_total;
/* Block size - device is erased in these units. At least 256 bytes */
-__pdata uint32_t ao_storage_block;
+uint32_t ao_storage_block;
/* Byte offset of config block. Will be ao_storage_block bytes long */
-__pdata uint32_t ao_storage_config;
+uint32_t ao_storage_config;
/* Storage unit size - device reads and writes must be within blocks of this size. Usually 256 bytes. */
-__pdata uint16_t ao_storage_unit;
+uint16_t ao_storage_unit;
/*
* MRAM is entirely random access; no erase operations are required,
@@ -51,7 +51,7 @@ __pdata uint16_t ao_storage_unit;
#define MR25_STATUS_BP_SHIFT (2)
#define MR25_STATUS_WEL (1 << 1) /* Write enable latch */
-static __xdata uint8_t ao_mr25_mutex;
+static uint8_t ao_mr25_mutex;
/*
* This little array is abused to send and receive data. A particular
@@ -61,7 +61,7 @@ static __xdata uint8_t ao_mr25_mutex;
* those last three bytes.
*/
-static __xdata uint8_t ao_mr25_instruction[4];
+static uint8_t ao_mr25_instruction[4];
#define MR25_SELECT() ao_spi_get_mask(AO_MR25_SPI_CS_PORT,(1 << AO_MR25_SPI_CS_PIN),AO_MR25_SPI_BUS, AO_SPI_SPEED_FAST)
#define MR25_DESELECT() ao_spi_put_mask(AO_MR25_SPI_CS_PORT,(1 << AO_MR25_SPI_CS_PIN),AO_MR25_SPI_BUS)
@@ -93,7 +93,7 @@ ao_mr25_set_address(uint32_t pos)
* Erase the specified sector (no-op for MRAM)
*/
uint8_t
-ao_storage_erase(uint32_t pos) __reentrant
+ao_storage_erase(uint32_t pos)
{
if (pos >= ao_storage_total || pos + ao_storage_block > ao_storage_total)
return 0;
@@ -104,7 +104,7 @@ ao_storage_erase(uint32_t pos) __reentrant
* Write to flash
*/
uint8_t
-ao_storage_device_write(uint32_t pos, __xdata void *d, uint16_t len) __reentrant
+ao_storage_device_write(uint32_t pos, void *d, uint16_t len)
{
if (pos >= ao_storage_total || pos + len > ao_storage_total)
return 0;
@@ -128,7 +128,7 @@ ao_storage_device_write(uint32_t pos, __xdata void *d, uint16_t len) __reentrant
* Read from flash
*/
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;
@@ -147,7 +147,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)
{
}
@@ -157,7 +157,7 @@ ao_storage_setup(void)
}
void
-ao_storage_device_info(void) __reentrant
+ao_storage_device_info(void)
{
printf ("Detected chips 1 size %d\n", ao_storage_total >> 8);
}
diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c
index 53ed992a..e2327bf4 100644
--- a/src/drivers/ao_ms5607.c
+++ b/src/drivers/ao_ms5607.c
@@ -22,8 +22,8 @@
#if HAS_MS5607 || HAS_MS5611
-__xdata struct ao_ms5607_prom ao_ms5607_prom;
-static __xdata uint8_t ms5607_configured;
+struct ao_ms5607_prom ao_ms5607_prom;
+static uint8_t ms5607_configured;
#ifndef AO_MS5607_SPI_SPEED
#define AO_MS5607_SPI_SPEED AO_SPI_SPEED_FAST
@@ -31,12 +31,12 @@ static __xdata uint8_t ms5607_configured;
static void
ao_ms5607_start(void) {
- ao_spi_get_bit(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, AO_MS5607_CS, AO_MS5607_SPI_INDEX, AO_MS5607_SPI_SPEED);
+ ao_spi_get_bit(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, AO_MS5607_SPI_INDEX, AO_MS5607_SPI_SPEED);
}
static void
ao_ms5607_stop(void) {
- ao_spi_put_bit(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, AO_MS5607_CS, AO_MS5607_SPI_INDEX);
+ ao_spi_put_bit(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, AO_MS5607_SPI_INDEX);
}
static void
@@ -45,7 +45,7 @@ ao_ms5607_reset(void) {
cmd = AO_MS5607_RESET;
ao_ms5607_start();
- ao_spi_send(DATA_TO_XDATA(&cmd), 1, AO_MS5607_SPI_INDEX);
+ ao_spi_send(&cmd, 1, AO_MS5607_SPI_INDEX);
ao_delay(AO_MS_TO_TICKS(10));
ao_ms5607_stop();
}
@@ -74,7 +74,7 @@ ao_ms5607_crc(uint8_t *prom)
return n_rem;
}
-static int
+static bool
ao_ms5607_prom_valid(uint8_t *prom)
{
uint8_t crc;
@@ -87,26 +87,26 @@ ao_ms5607_prom_valid(uint8_t *prom)
if (*p++ + 1 > 1)
break;
if (i == 16)
- return FALSE;
+ return false;
crc = ao_ms5607_crc(prom);
if (crc != (prom[15] & 0xf))
- return FALSE;
+ return false;
- return TRUE;
+ return true;
}
static void
-ao_ms5607_prom_read(__xdata struct ao_ms5607_prom *prom)
+ao_ms5607_prom_read(struct ao_ms5607_prom *prom)
{
uint8_t addr;
uint16_t *r;
- r = (__xdata uint16_t *) prom;
+ r = (uint16_t *) prom;
for (addr = 0; addr < 8; addr++) {
uint8_t cmd = AO_MS5607_PROM_READ(addr);
ao_ms5607_start();
- ao_spi_send(DATA_TO_XDATA(&cmd), 1, AO_MS5607_SPI_INDEX);
+ ao_spi_send(&cmd, 1, AO_MS5607_SPI_INDEX);
ao_spi_recv(r, 2, AO_MS5607_SPI_INDEX);
ao_ms5607_stop();
r++;
@@ -138,25 +138,25 @@ ao_ms5607_setup(void)
ao_ms5607_prom_read(&ao_ms5607_prom);
}
-static __xdata volatile uint8_t ao_ms5607_done;
+static volatile uint8_t ao_ms5607_done;
static void
ao_ms5607_isr(void)
{
ao_exti_disable(AO_MS5607_MISO_PORT, AO_MS5607_MISO_PIN);
ao_ms5607_done = 1;
- ao_wakeup((__xdata void *) &ao_ms5607_done);
+ ao_wakeup((void *) &ao_ms5607_done);
}
static uint32_t
ao_ms5607_get_sample(uint8_t cmd) {
- __xdata uint8_t reply[3];
- __xdata uint8_t read;
+ uint8_t reply[3];
+ uint8_t read;
ao_ms5607_done = 0;
ao_ms5607_start();
- ao_spi_send(DATA_TO_XDATA(&cmd), 1, AO_MS5607_SPI_INDEX);
+ ao_spi_send(&cmd, 1, AO_MS5607_SPI_INDEX);
ao_exti_enable(AO_MS5607_MISO_PORT, AO_MS5607_MISO_PIN);
@@ -164,7 +164,7 @@ ao_ms5607_get_sample(uint8_t cmd) {
ao_spi_put(AO_MS5607_SPI_INDEX);
#endif
ao_arch_block_interrupts();
- while (!ao_gpio_get(AO_MS5607_MISO_PORT, AO_MS5607_MISO_PIN, AO_MS5607_MISO) &&
+ while (!ao_gpio_get(AO_MS5607_MISO_PORT, AO_MS5607_MISO_PIN) &&
!ao_ms5607_done)
ao_sleep((void *) &ao_ms5607_done);
ao_arch_release_interrupts();
@@ -198,7 +198,7 @@ ao_ms5607_get_sample(uint8_t cmd) {
#define AO_CONVERT_D2 token_evaluator(AO_MS5607_CONVERT_D2_, AO_MS5607_TEMP_OVERSAMPLE)
void
-ao_ms5607_sample(__xdata struct ao_ms5607_sample *sample)
+ao_ms5607_sample(struct ao_ms5607_sample *sample)
{
sample->pres = ao_ms5607_get_sample(AO_CONVERT_D1);
sample->temp = ao_ms5607_get_sample(AO_CONVERT_D2);
@@ -214,7 +214,7 @@ ao_ms5607_sample(__xdata struct ao_ms5607_sample *sample)
#define HAS_MS5607_TASK HAS_TASK
#endif
-__xdata struct ao_ms5607_sample ao_ms5607_current;
+struct ao_ms5607_sample ao_ms5607_current;
#if HAS_MS5607_TASK
static void
@@ -233,7 +233,7 @@ ao_ms5607(void)
}
}
-__xdata struct ao_task ao_ms5607_task;
+struct ao_task ao_ms5607_task;
#endif
#if HAS_TASK
@@ -253,7 +253,7 @@ ao_ms5607_info(void)
static void
ao_ms5607_dump(void)
{
- __xdata struct ao_ms5607_value value;
+ struct ao_ms5607_value value;
ao_ms5607_convert(&ao_ms5607_current, &value);
printf ("Pressure: %8lu %8ld\n", ao_ms5607_current.pres, value.pres);
@@ -261,7 +261,7 @@ ao_ms5607_dump(void)
printf ("Altitude: %ld\n", ao_pa_to_altitude(value.pres));
}
-__code struct ao_cmds ao_ms5607_cmds[] = {
+const struct ao_cmds ao_ms5607_cmds[] = {
{ ao_ms5607_dump, "B\0Display MS5607 data" },
{ 0, NULL },
};
diff --git a/src/drivers/ao_ms5607.h b/src/drivers/ao_ms5607.h
index 18f99bf8..322cc468 100644
--- a/src/drivers/ao_ms5607.h
+++ b/src/drivers/ao_ms5607.h
@@ -57,8 +57,8 @@ struct ao_ms5607_value {
int32_t temp; /* in °C * 100 */
};
-extern __xdata struct ao_ms5607_sample ao_ms5607_current;
-extern __xdata struct ao_ms5607_prom ao_ms5607_prom;
+extern struct ao_ms5607_sample ao_ms5607_current;
+extern struct ao_ms5607_prom ao_ms5607_prom;
void
ao_ms5607_setup(void);
@@ -70,10 +70,10 @@ void
ao_ms5607_info(void);
void
-ao_ms5607_sample(__xdata struct ao_ms5607_sample *sample);
+ao_ms5607_sample(struct ao_ms5607_sample *sample);
void
-ao_ms5607_convert(__xdata struct ao_ms5607_sample *sample,
- __xdata struct ao_ms5607_value *value);
+ao_ms5607_convert(struct ao_ms5607_sample *sample,
+ struct ao_ms5607_value *value);
#endif /* _AO_MS5607_H_ */
diff --git a/src/drivers/ao_ms5607_convert_8051.c b/src/drivers/ao_ms5607_convert_8051.c
index b7081107..e9052b41 100644
--- a/src/drivers/ao_ms5607_convert_8051.c
+++ b/src/drivers/ao_ms5607_convert_8051.c
@@ -32,8 +32,8 @@
#endif
void
-ao_ms5607_convert(__xdata struct ao_ms5607_sample *sample,
- __xdata struct ao_ms5607_value *value)
+ao_ms5607_convert(struct ao_ms5607_sample *sample,
+ struct ao_ms5607_value *value)
{
__LOCAL int32_t dT;
__LOCAL int32_t TEMP;
diff --git a/src/drivers/ao_packet.c b/src/drivers/ao_packet.c
index 008af5db..b5a0a4b7 100644
--- a/src/drivers/ao_packet.c
+++ b/src/drivers/ao_packet.c
@@ -18,20 +18,20 @@
#include "ao.h"
-__xdata struct ao_packet_recv ao_rx_packet;
-__xdata struct ao_packet ao_tx_packet;
-__pdata uint8_t ao_packet_rx_len, ao_packet_rx_used, ao_packet_tx_used;
+struct ao_packet_recv ao_rx_packet;
+struct ao_packet ao_tx_packet;
+uint8_t ao_packet_rx_len, ao_packet_rx_used, ao_packet_tx_used;
-static __xdata uint8_t tx_data[AO_PACKET_MAX];
-static __xdata uint8_t rx_data[AO_PACKET_MAX];
-static __pdata uint8_t rx_seq;
+static uint8_t tx_data[AO_PACKET_MAX];
+static uint8_t rx_data[AO_PACKET_MAX];
+static uint8_t rx_seq;
-__xdata struct ao_task ao_packet_task;
-__xdata uint8_t ao_packet_enable;
-__xdata uint8_t ao_packet_restart;
+struct ao_task ao_packet_task;
+uint8_t ao_packet_enable;
+uint8_t ao_packet_restart;
#if PACKET_HAS_MASTER
-__xdata uint8_t ao_packet_master_sleeping;
+uint8_t ao_packet_master_sleeping;
#endif
void
@@ -91,7 +91,7 @@ ao_packet_recv(uint16_t timeout)
if (ao_xmemcmp(ao_rx_packet.packet.callsign,
ao_config.callsign,
AO_MAX_CALLSIGN) != 0 &&
- ao_xmemcmp(ao_config.callsign, CODE_TO_XDATA("N0CALL"), 7) != 0)
+ ao_xmemcmp(ao_config.callsign, "N0CALL", 7) != 0)
return 0;
/* SYN packets carry no data */
@@ -150,7 +150,7 @@ ao_packet_flush(void)
#endif /* PACKET_HAS_MASTER */
void
-ao_packet_putchar(char c) __reentrant
+ao_packet_putchar(char c)
{
/* No need to block interrupts, all variables here
* are only manipulated in task context
diff --git a/src/drivers/ao_packet_master.c b/src/drivers/ao_packet_master.c
index e63771e5..68a5efef 100644
--- a/src/drivers/ao_packet_master.c
+++ b/src/drivers/ao_packet_master.c
@@ -39,7 +39,7 @@ ao_packet_getchar(void)
}
static void
-ao_packet_echo(void) __reentrant
+ao_packet_echo(void)
{
int c;
while (ao_packet_enable) {
@@ -50,9 +50,9 @@ ao_packet_echo(void) __reentrant
ao_exit();
}
-static __xdata struct ao_task ao_packet_echo_task;
-static __xdata uint16_t ao_packet_master_delay;
-static __xdata uint16_t ao_packet_master_time;
+static struct ao_task ao_packet_echo_task;
+static uint16_t ao_packet_master_delay;
+static uint16_t ao_packet_master_time;
#define AO_PACKET_MASTER_DELAY_SHORT AO_MS_TO_TICKS(100)
#define AO_PACKET_MASTER_DELAY_LONG AO_MS_TO_TICKS(1000)
@@ -114,7 +114,7 @@ ao_packet_master(void)
}
static void
-ao_packet_forward(void) __reentrant
+ao_packet_forward(void)
{
char c;
ao_packet_enable = 1;
@@ -152,7 +152,7 @@ ao_packet_signal(void)
printf ("RSSI: %d\n", ao_radio_rssi);
}
-__code struct ao_cmds ao_packet_master_cmds[] = {
+const struct ao_cmds ao_packet_master_cmds[] = {
{ ao_packet_forward, "p\0Remote packet link." },
{ ao_packet_signal, "s\0Report signal strength." },
{ 0, NULL },
diff --git a/src/drivers/ao_packet_slave.c b/src/drivers/ao_packet_slave.c
index b877128a..3ae1138c 100644
--- a/src/drivers/ao_packet_slave.c
+++ b/src/drivers/ao_packet_slave.c
@@ -28,7 +28,7 @@ ao_packet_slave(void)
if (ao_packet_recv(0)) {
ao_xmemcpy(&ao_tx_packet.callsign, &ao_rx_packet.packet.callsign, AO_MAX_CALLSIGN);
#if HAS_FLIGHT
- ao_flight_force_idle = TRUE;
+ ao_flight_force_idle = true;
#endif
ao_packet_send();
}
diff --git a/src/drivers/ao_pad.c b/src/drivers/ao_pad.c
index c6efc311..85691f5c 100644
--- a/src/drivers/ao_pad.c
+++ b/src/drivers/ao_pad.c
@@ -22,14 +22,14 @@
#include <ao_74hc165.h>
#include <ao_radio_cmac.h>
-static __xdata uint8_t ao_pad_ignite;
-static __xdata struct ao_pad_command command;
-static __xdata struct ao_pad_query query;
-static __pdata uint8_t ao_pad_armed;
-static __pdata uint16_t ao_pad_arm_time;
-static __pdata uint8_t ao_pad_box;
-static __xdata uint8_t ao_pad_disabled;
-static __pdata uint16_t ao_pad_packet_time;
+static uint8_t ao_pad_ignite;
+static struct ao_pad_command command;
+static struct ao_pad_query query;
+static uint8_t ao_pad_armed;
+static uint16_t ao_pad_arm_time;
+static uint8_t ao_pad_box;
+static uint8_t ao_pad_disabled;
+static uint16_t ao_pad_packet_time;
#ifndef AO_PAD_RSSI_MINIMUM
#define AO_PAD_RSSI_MINIMUM -90
@@ -38,7 +38,7 @@ static __pdata uint16_t ao_pad_packet_time;
#define DEBUG 1
#if DEBUG
-static __pdata uint8_t ao_pad_debug;
+static uint8_t ao_pad_debug;
#define PRINTD(...) (ao_pad_debug ? (printf(__VA_ARGS__), 0) : 0)
#define FLUSHD() (ao_pad_debug ? (flush(), 0) : 0)
#else
@@ -50,7 +50,7 @@ static void
ao_siren(uint8_t v)
{
#ifdef AO_SIREN
- ao_gpio_set(AO_SIREN_PORT, AO_SIREN_PIN, AO_SIREN, v);
+ ao_gpio_set(AO_SIREN_PORT, AO_SIREN_PIN, v);
#else
#if HAS_BEEP
ao_beep(v ? AO_BEEP_MID : 0);
@@ -64,7 +64,7 @@ static void
ao_strobe(uint8_t v)
{
#ifdef AO_STROBE
- ao_gpio_set(AO_STROBE_PORT, AO_STROBE_PIN, AO_STROBE, v);
+ ao_gpio_set(AO_STROBE_PORT, AO_STROBE_PIN, v);
#else
(void) v;
#endif
@@ -189,21 +189,21 @@ ao_pad_monitor(void)
{
uint8_t c;
uint8_t sample;
- __pdata AO_LED_TYPE prev = 0, cur = 0;
- __pdata uint8_t beeping = 0;
- __xdata volatile struct ao_data *packet;
- __pdata uint16_t arm_beep_time = 0;
+ AO_LED_TYPE prev = 0, cur = 0;
+ uint8_t beeping = 0;
+ volatile struct ao_data *packet;
+ uint16_t arm_beep_time = 0;
sample = ao_data_head;
ao_led_set(LEDS_AVAILABLE);
ao_delay(AO_MS_TO_TICKS(1000));
ao_led_set(0);
for (;;) {
- __pdata int16_t pyro;
+ int16_t pyro;
ao_arch_critical(
while (sample == ao_data_head)
- ao_sleep((void *) DATA_TO_XDATA(&ao_data_head));
+ ao_sleep((void *) &ao_data_head);
);
@@ -509,16 +509,14 @@ ao_pad_manual(void)
ao_cmd_white();
if (!ao_match_word("DoIt"))
return;
- ao_cmd_decimal();
+ ignite = 1 << ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- ignite = 1 << ao_cmd_lex_i;
- ao_cmd_decimal();
+ repeat = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success) {
repeat = 1;
ao_cmd_status = ao_cmd_success;
- } else
- repeat = ao_cmd_lex_i;
+ }
while (repeat-- > 0) {
ao_pad_ignite = ignite;
ao_wakeup(&ao_pad_ignite);
@@ -526,17 +524,17 @@ ao_pad_manual(void)
}
}
-static __xdata struct ao_task ao_pad_task;
-static __xdata struct ao_task ao_pad_ignite_task;
-static __xdata struct ao_task ao_pad_monitor_task;
+static struct ao_task ao_pad_task;
+static struct ao_task ao_pad_ignite_task;
+static struct ao_task ao_pad_monitor_task;
#if DEBUG
void
ao_pad_set_debug(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status == ao_cmd_success)
- ao_pad_debug = ao_cmd_lex_i != 0;
+ ao_pad_debug = r != 0;
}
@@ -544,14 +542,12 @@ static void
ao_pad_alarm_debug(void)
{
uint8_t which, value;
- ao_cmd_decimal();
+ which = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- which = ao_cmd_lex_i;
- ao_cmd_decimal();
+ value = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- value = ao_cmd_lex_i;
printf ("Set %s to %d\n", which ? "siren" : "strobe", value);
if (which)
ao_siren(value);
@@ -560,7 +556,7 @@ ao_pad_alarm_debug(void)
}
#endif
-__code struct ao_cmds ao_pad_cmds[] = {
+const struct ao_cmds ao_pad_cmds[] = {
{ ao_pad_test, "t\0Test pad continuity" },
{ ao_pad_manual, "i <key> <n>\0Fire igniter. <key> is doit with D&I" },
#if DEBUG
@@ -593,34 +589,34 @@ ao_pad_init(void)
}
#endif
#if AO_PAD_NUM > 0
- ao_enable_output(AO_PAD_0_PORT, AO_PAD_PIN_0, AO_PAD_0, 0);
+ ao_enable_output(AO_PAD_0_PORT, AO_PAD_PIN_0, 0);
#endif
#if AO_PAD_NUM > 1
- ao_enable_output(AO_PAD_1_PORT, AO_PAD_PIN_1, AO_PAD_1, 0);
+ ao_enable_output(AO_PAD_1_PORT, AO_PAD_PIN_1, 0);
#endif
#if AO_PAD_NUM > 2
- ao_enable_output(AO_PAD_2_PORT, AO_PAD_PIN_2, AO_PAD_2, 0);
+ ao_enable_output(AO_PAD_2_PORT, AO_PAD_PIN_2, 0);
#endif
#if AO_PAD_NUM > 3
- ao_enable_output(AO_PAD_3_PORT, AO_PAD_PIN_3, AO_PAD_3, 0);
+ ao_enable_output(AO_PAD_3_PORT, AO_PAD_PIN_3, 0);
#endif
#if AO_PAD_NUM > 4
- ao_enable_output(AO_PAD_4_PORT, AO_PAD_PIN_4, AO_PAD_4, 0);
+ ao_enable_output(AO_PAD_4_PORT, AO_PAD_PIN_4, 0);
#endif
#if AO_PAD_NUM > 5
- ao_enable_output(AO_PAD_5_PORT, AO_PAD_PIN_5, AO_PAD_5, 0);
+ ao_enable_output(AO_PAD_5_PORT, AO_PAD_PIN_5, 0);
#endif
#if AO_PAD_NUM > 5
- ao_enable_output(AO_PAD_6_PORT, AO_PAD_PIN_6, AO_PAD_6, 0);
+ ao_enable_output(AO_PAD_6_PORT, AO_PAD_PIN_6, 0);
#endif
#if AO_PAD_NUM > 7
- ao_enable_output(AO_PAD_7_PORT, AO_PAD_PIN_7, AO_PAD_7, 0);
+ ao_enable_output(AO_PAD_7_PORT, AO_PAD_PIN_7, 0);
#endif
#ifdef AO_STROBE
- ao_enable_output(AO_STROBE_PORT, AO_STROBE_PIN, AO_STROBE, 0);
+ ao_enable_output(AO_STROBE_PORT, AO_STROBE_PIN, 0);
#endif
#ifdef AO_SIREN
- ao_enable_output(AO_SIREN_PORT, AO_SIREN_PIN, AO_SIREN, 0);
+ ao_enable_output(AO_SIREN_PORT, AO_SIREN_PIN, 0);
#endif
ao_cmd_register(&ao_pad_cmds[0]);
ao_add_task(&ao_pad_task, ao_pad, "pad listener");
diff --git a/src/drivers/ao_pca9922.c b/src/drivers/ao_pca9922.c
index 09f52a0e..91d62026 100644
--- a/src/drivers/ao_pca9922.c
+++ b/src/drivers/ao_pca9922.c
@@ -23,7 +23,7 @@
#include <ao.h>
-static __xdata uint8_t ao_led_state;
+static uint8_t ao_led_state;
static void
ao_led_apply(void)
@@ -72,11 +72,11 @@ ao_led_set_mask(uint8_t colors, uint8_t mask)
static void
ao_led_test(void)
{
- ao_cmd_hexbyte();
+ AO_LED_TYPE r = ao_cmd_hexbyte();
if (ao_cmd_status != ao_cmd_success)
return;
- ao_led_set(ao_cmd_lex_i);
- printf("LEDs set to %02x\n", ao_cmd_lex_i);
+ ao_led_set(r);
+ printf("LEDs set to %x\n", r);
}
static const struct ao_cmds ao_led_cmds[] = {
@@ -93,7 +93,7 @@ ao_led_toggle(uint8_t colors)
}
void
-ao_led_for(uint8_t colors, uint16_t ticks) __reentrant
+ao_led_for(uint8_t colors, uint16_t ticks)
{
ao_led_on(colors);
ao_delay(ticks);
diff --git a/src/drivers/ao_ps2.c b/src/drivers/ao_ps2.c
index 29eecea8..c7520b3a 100644
--- a/src/drivers/ao_ps2.c
+++ b/src/drivers/ao_ps2.c
@@ -91,11 +91,11 @@ ao_ps2_put(uint8_t c)
ao_arch_release_interrupts();
/* pull the clock pin down */
- ao_enable_output(AO_PS2_CLOCK_PORT, AO_PS2_CLOCK_BIT, AO_PS2_CLOCK_PIN, 0);
+ ao_enable_output(AO_PS2_CLOCK_PORT, AO_PS2_CLOCK_BIT, 0);
ao_delay(0);
/* pull the data pin down for the start bit */
- ao_enable_output(AO_PS2_DATA_PORT, AO_PS2_DATA_BIT, AO_PS2_DATA_PIN, 0);
+ ao_enable_output(AO_PS2_DATA_PORT, AO_PS2_DATA_BIT, 0);
ao_delay(0);
/* switch back to input mode for the interrupt to work */
@@ -369,7 +369,7 @@ ao_ps2_isr(void)
uint8_t bit;
if (ao_ps2_tx_count) {
- ao_gpio_set(AO_PS2_DATA_PORT, AO_PS2_DATA_BIT, AO_PS2_DATA_PIN, ao_ps2_tx&1);
+ ao_gpio_set(AO_PS2_DATA_PORT, AO_PS2_DATA_BIT, ao_ps2_tx&1);
ao_ps2_tx >>= 1;
ao_ps2_tx_count--;
if (!ao_ps2_tx_count) {
@@ -383,7 +383,7 @@ ao_ps2_isr(void)
ao_ps2_count = 0;
ao_ps2_tick = ao_tick_count;
- bit = ao_gpio_get(AO_PS2_DATA_PORT, AO_PS2_DATA_BIT, AO_PS2_DATA_PIN);
+ bit = ao_gpio_get(AO_PS2_DATA_PORT, AO_PS2_DATA_BIT);
if (ao_ps2_count == 0) {
/* check for start bit, ignore if not zero */
if (bit)
diff --git a/src/drivers/ao_pyro_slave.c b/src/drivers/ao_pyro_slave.c
index a293d929..8ea6d858 100644
--- a/src/drivers/ao_pyro_slave.c
+++ b/src/drivers/ao_pyro_slave.c
@@ -33,7 +33,7 @@ static const struct ao_companion_setup ao_telepyro_setup = {
struct ao_config ao_config;
-extern volatile __data uint16_t ao_tick_count;
+extern volatile uint16_t ao_tick_count;
uint16_t ao_boost_tick;
void ao_spi_slave(void)
diff --git a/src/drivers/ao_quadrature.c b/src/drivers/ao_quadrature.c
index 250e035f..a5fbd1da 100644
--- a/src/drivers/ao_quadrature.c
+++ b/src/drivers/ao_quadrature.c
@@ -22,7 +22,7 @@
#include <ao_fast_timer.h>
#include <ao_event.h>
-__xdata int32_t ao_quadrature_count[AO_QUADRATURE_COUNT];
+int32_t ao_quadrature_count[AO_QUADRATURE_COUNT];
#ifndef AO_QUADRATURE_SINGLE_CODE
static int8_t ao_quadrature_step[AO_QUADRATURE_COUNT];
#endif
@@ -170,8 +170,7 @@ ao_quadrature_test(void)
int8_t t = 0;
#endif
- ao_cmd_decimal();
- q = ao_cmd_lex_i;
+ q = ao_cmd_decimal();
if (q >= AO_QUADRATURE_COUNT)
ao_cmd_status = ao_cmd_syntax_error;
if (ao_cmd_status != ao_cmd_success)
diff --git a/src/drivers/ao_quadrature.h b/src/drivers/ao_quadrature.h
index a99e4cc5..ee551f65 100644
--- a/src/drivers/ao_quadrature.h
+++ b/src/drivers/ao_quadrature.h
@@ -19,7 +19,7 @@
#ifndef _AO_QUADRATURE_H_
#define _AO_QUADRATURE_H_
-extern __xdata int32_t ao_quadrature_count[AO_QUADRATURE_COUNT];
+extern int32_t ao_quadrature_count[AO_QUADRATURE_COUNT];
int32_t
ao_quadrature_wait(uint8_t q);
diff --git a/src/drivers/ao_radio_master.c b/src/drivers/ao_radio_master.c
index 79e4b22b..8b62a4de 100644
--- a/src/drivers/ao_radio_master.c
+++ b/src/drivers/ao_radio_master.c
@@ -21,15 +21,15 @@
#include <ao_exti.h>
#include <ao_radio_cmac.h>
-static __xdata struct ao_radio_spi_reply ao_radio_spi_reply;
-static __xdata struct ao_radio_spi_request ao_radio_spi_request;
-static volatile __xdata uint8_t ao_radio_wait_mode;
-static volatile __xdata uint8_t ao_radio_done = 0;
-static volatile __xdata uint8_t ao_radio_ready = 1;
-static __xdata uint8_t ao_radio_mutex;
-static __xdata uint8_t ao_radio_aes_seq;
+static struct ao_radio_spi_reply ao_radio_spi_reply;
+static struct ao_radio_spi_request ao_radio_spi_request;
+static volatile uint8_t ao_radio_wait_mode;
+static volatile uint8_t ao_radio_done = 0;
+static volatile uint8_t ao_radio_ready = 1;
+static uint8_t ao_radio_mutex;
+static uint8_t ao_radio_aes_seq;
-__xdata int8_t ao_radio_cmac_rssi;
+int8_t ao_radio_cmac_rssi;
#if 0
#define PRINTD(...) do { printf ("\r%5u %s: ", ao_tick_count, __func__); printf(__VA_ARGS__); flush(); } while(0)
@@ -126,7 +126,7 @@ ao_radio_put(void)
}
static void
-ao_radio_get_data(__xdata void *d, uint8_t size)
+ao_radio_get_data(void *d, uint8_t size)
{
PRINTD ("fetch\n");
ao_radio_master_start();
@@ -157,7 +157,7 @@ ao_radio_send(const void *d, uint8_t size)
uint8_t
-ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout)
+ao_radio_recv(void *d, uint8_t size, uint8_t timeout)
{
int8_t ret;
uint8_t recv;
@@ -198,7 +198,7 @@ ao_radio_cmac_set_key(void)
}
int8_t
-ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant
+ao_radio_cmac_send(void *packet, uint8_t len)
{
if (len > AO_CMAC_MAX_LEN)
return AO_RADIO_CMAC_LEN_ERROR;
@@ -220,7 +220,7 @@ ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant
}
int8_t
-ao_radio_cmac_recv(__xdata void *packet, uint8_t len, uint16_t timeout) __reentrant
+ao_radio_cmac_recv(void *packet, uint8_t len, uint16_t timeout)
{
int8_t ret;
int8_t recv;
@@ -296,7 +296,7 @@ ao_radio_test_cmd(void)
ao_radio_test(0);
}
-__code struct ao_cmds ao_radio_cmds[] = {
+const struct ao_cmds ao_radio_cmds[] = {
{ ao_radio_test_cmd, "C <1 start, 0 stop, none both>\0Radio carrier test" },
{ 0, NULL },
};
diff --git a/src/drivers/ao_radio_slave.c b/src/drivers/ao_radio_slave.c
index 2f1dab29..7859d6b6 100644
--- a/src/drivers/ao_radio_slave.c
+++ b/src/drivers/ao_radio_slave.c
@@ -20,11 +20,11 @@
#include <ao_radio_spi.h>
#include <ao_radio_cmac.h>
-static __xdata struct ao_radio_spi_reply ao_radio_spi_reply;
+static struct ao_radio_spi_reply ao_radio_spi_reply;
-static __xdata struct ao_radio_spi_request ao_radio_spi_request;
+static struct ao_radio_spi_request ao_radio_spi_request;
-static __xdata uint8_t slave_state;
+static uint8_t slave_state;
static void
ao_radio_slave_low(void)
@@ -123,7 +123,7 @@ ao_radio_slave_spi(void)
}
}
-static __xdata struct ao_task ao_radio_slave_spi_task;
+static struct ao_task ao_radio_slave_spi_task;
void
ao_radio_slave_init(void)
diff --git a/src/drivers/ao_rn4678.c b/src/drivers/ao_rn4678.c
index 98dc35b5..4ace4b78 100644
--- a/src/drivers/ao_rn4678.c
+++ b/src/drivers/ao_rn4678.c
@@ -335,7 +335,7 @@ ao_rn_get_name(char *name, int len)
static void
ao_rn_check_link(void)
{
- ao_rn_connected = 1 - ao_gpio_get(AO_RN_CONNECTED_PORT, AO_RN_CONNECTED_PIN, foo);
+ ao_rn_connected = 1 - ao_gpio_get(AO_RN_CONNECTED_PORT, AO_RN_CONNECTED_PIN);
}
static void
@@ -384,17 +384,17 @@ ao_rn(void)
ao_rn_dbg("ao_rn top\n");
/* Select CMD mode after the device gets out of reset */
- ao_gpio_set(AO_RN_CMD_PORT, AO_RN_CMD_PIN, foo, AO_RN_CMD_CMD);
+ ao_gpio_set(AO_RN_CMD_PORT, AO_RN_CMD_PIN, AO_RN_CMD_CMD);
for (i = 0; i < 3; i++) {
ao_rn_dbg("reset device\n");
- ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, foo, 0);
+ ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, 0);
ao_delay(AO_MS_TO_TICKS(100));
/* Reboot the RN4678 and wait for it to start talking */
ao_rn_drain();
- ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, foo, 1);
+ ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, 1);
status = ao_rn_wait_for(AO_RN_REBOOT_TIMEOUT, AO_RN_REBOOT_MSG);
if (status != AO_RN_OK) {
ao_rn_dbg("reboot failed\n");
@@ -468,7 +468,7 @@ ao_rn(void)
if (status != AO_RN_OK)
ao_bt_panic(4);
- ao_gpio_set(AO_RN_CMD_PORT, AO_RN_CMD_PIN, foo, AO_RN_CMD_DATA);
+ ao_gpio_set(AO_RN_CMD_PORT, AO_RN_CMD_PIN, AO_RN_CMD_DATA);
/* Wait for the hardware to finish sending messages, then clear the queue */
ao_delay(AO_MS_TO_TICKS(200));
@@ -530,16 +530,16 @@ ao_rn_factory(void)
*/
/* Select our target output pin */
- ao_enable_output(AO_RN_P3_1_PORT, AO_RN_P3_1_PIN, foo, v);
+ ao_enable_output(AO_RN_P3_1_PORT, AO_RN_P3_1_PIN, v);
/* Turn off the BT device using the SW_BTN pin */
printf("Power down BT\n"); flush();
- ao_gpio_set(AO_RN_SW_BTN_PORT, AO_RN_SW_BTN_PIN, foo, 0);
+ ao_gpio_set(AO_RN_SW_BTN_PORT, AO_RN_SW_BTN_PIN, 0);
ao_delay(AO_MS_TO_TICKS(1000));
/* And turn it back on */
printf("Power up BT\n"); flush();
- ao_gpio_set(AO_RN_SW_BTN_PORT, AO_RN_SW_BTN_PIN, foo, 1);
+ ao_gpio_set(AO_RN_SW_BTN_PORT, AO_RN_SW_BTN_PIN, 1);
/* Right after power on, poke P3_1 five times to force a
* factory reset
@@ -547,7 +547,7 @@ ao_rn_factory(void)
for (i = 0; i < 20; i++) {
v = 1-v;
ao_delay(AO_MS_TO_TICKS(50));
- ao_gpio_set(AO_RN_P3_1_PORT, AO_RN_P3_1_PIN, foo, v);
+ ao_gpio_set(AO_RN_P3_1_PORT, AO_RN_P3_1_PIN, v);
ao_led_toggle(AO_BT_LED);
}
@@ -556,9 +556,9 @@ ao_rn_factory(void)
printf("Reboot BT\n"); flush();
ao_delay(AO_MS_TO_TICKS(100));
- ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, foo, 0);
+ ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, 0);
ao_delay(AO_MS_TO_TICKS(100));
- ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, foo, 1);
+ ao_gpio_set(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, 1);
}
#if AO_RN_DEBUG
@@ -588,13 +588,13 @@ ao_rn4678_init(void)
ao_serial_rn_set_speed(AO_SERIAL_SPEED_115200);
/* Reset line */
- ao_enable_output(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, foo, 0);
+ ao_enable_output(AO_RN_RST_N_PORT, AO_RN_RST_N_PIN, 0);
/* SW_BTN */
- ao_enable_output(AO_RN_SW_BTN_PORT, AO_RN_SW_BTN_PIN, foo, 1);
+ ao_enable_output(AO_RN_SW_BTN_PORT, AO_RN_SW_BTN_PIN, 1);
/* P3_7 command/data selector */
- ao_enable_output(AO_RN_CMD_PORT, AO_RN_CMD_PIN, foo, AO_RN_CMD_CMD);
+ ao_enable_output(AO_RN_CMD_PORT, AO_RN_CMD_PIN, AO_RN_CMD_CMD);
ao_enable_input(AO_RN_CONNECTED_PORT, AO_RN_CONNECTED_PIN, AO_EXTI_MODE_PULL_NONE);
ao_exti_setup(AO_RN_CONNECTED_PORT, AO_RN_CONNECTED_PIN,
diff --git a/src/drivers/ao_sdcard.c b/src/drivers/ao_sdcard.c
index 45454000..9d36c397 100644
--- a/src/drivers/ao_sdcard.c
+++ b/src/drivers/ao_sdcard.c
@@ -34,8 +34,8 @@ extern uint8_t ao_radio_mutex;
#define ao_sdcard_send_fixed(d,l) ao_spi_send_fixed((d), (l), AO_SDCARD_SPI_BUS)
#define ao_sdcard_send(d,l) ao_spi_send((d), (l), AO_SDCARD_SPI_BUS)
#define ao_sdcard_recv(d,l) ao_spi_recv((d), (l), AO_SDCARD_SPI_BUS)
-#define ao_sdcard_select() ao_gpio_set(AO_SDCARD_SPI_CS_PORT,AO_SDCARD_SPI_CS_PIN,AO_SDCARD_SPI_CS,0)
-#define ao_sdcard_deselect() ao_gpio_set(AO_SDCARD_SPI_CS_PORT,AO_SDCARD_SPI_CS_PIN,AO_SDCARD_SPI_CS,1)
+#define ao_sdcard_select() ao_gpio_set(AO_SDCARD_SPI_CS_PORT,AO_SDCARD_SPI_CS_PIN,0)
+#define ao_sdcard_deselect() ao_gpio_set(AO_SDCARD_SPI_CS_PORT,AO_SDCARD_SPI_CS_PIN,1)
/* Include SD card commands */
#ifndef SDCARD_DEBUG
diff --git a/src/drivers/ao_seven_segment.c b/src/drivers/ao_seven_segment.c
index d2e1248f..1be305e5 100644
--- a/src/drivers/ao_seven_segment.c
+++ b/src/drivers/ao_seven_segment.c
@@ -209,10 +209,8 @@ static void
ao_seven_segment_show(void)
{
uint8_t digit, value;
- ao_cmd_decimal();
- digit = ao_cmd_lex_i;
- ao_cmd_decimal();
- value = ao_cmd_lex_i;
+ digit = ao_cmd_decimal();
+ value = ao_cmd_decimal();
ao_seven_segment_set(digit, value);
}
diff --git a/src/drivers/ao_trng_send.c b/src/drivers/ao_trng_send.c
index 4e02c0ce..adeed590 100644
--- a/src/drivers/ao_trng_send.c
+++ b/src/drivers/ao_trng_send.c
@@ -48,7 +48,7 @@ ao_trng_start(void)
* aren't of poor quality
*/
ao_delay(delay);
- trng_running = TRUE;
+ trng_running = true;
}
ao_mutex_put(&random_mutex);
}
@@ -140,7 +140,7 @@ ao_trng_send(void)
usb_buf_id = ao_usb_alloc(buffer);
#ifdef AO_TRNG_ENABLE_PORT
- ao_gpio_set(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, AO_TRNG_ENABLE_PIN, 1);
+ ao_gpio_set(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, 1);
#endif
trng_power_time = ao_time();
@@ -211,16 +211,16 @@ static void ao_trng_suspend(void *arg)
{
(void) arg;
#ifdef AO_TRNG_ENABLE_PORT
- ao_gpio_set(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, AO_TRNG_ENABLE_PIN, 0);
+ ao_gpio_set(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, 0);
#endif
- trng_running = FALSE;
+ trng_running = false;
}
static void ao_trng_resume(void *arg)
{
(void) arg;
#ifdef AO_TRNG_ENABLE_PORT
- ao_gpio_set(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, AO_TRNG_ENABLE_PIN, 1);
+ ao_gpio_set(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, 1);
#endif
trng_power_time = ao_time();
}
@@ -236,7 +236,7 @@ void
ao_trng_send_init(void)
{
#ifdef AO_TRNG_ENABLE_PORT
- ao_enable_output(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, AO_TRNG_ENABLE_PIN, 0);
+ ao_enable_output(AO_TRNG_ENABLE_PORT, AO_TRNG_ENABLE_BIT, 0);
ao_power_register(&ao_trng_power);
#endif
ao_enable_input(AO_RAW_PORT, AO_RAW_BIT, AO_EXTI_MODE_PULL_UP);
diff --git a/src/drivers/ao_watchdog.c b/src/drivers/ao_watchdog.c
index 1a877fcb..612496bc 100644
--- a/src/drivers/ao_watchdog.c
+++ b/src/drivers/ao_watchdog.c
@@ -18,7 +18,7 @@
#include <ao.h>
-static int ao_watchdog_enabled = TRUE;
+static int ao_watchdog_enabled = true;
static void
ao_watchdog(void)
@@ -28,9 +28,9 @@ ao_watchdog(void)
ao_sleep(&ao_watchdog_enabled);
while (ao_watchdog_enabled) {
ao_delay(AO_WATCHDOG_INTERVAL);
- ao_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG_PIN, 1);
+ ao_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, 1);
ao_delay(1);
- ao_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG_PIN, 0);
+ ao_gpio_set(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, 0);
}
}
}
@@ -38,15 +38,15 @@ ao_watchdog(void)
static void
ao_watchdog_set(void)
{
- ao_cmd_hex();
+ uint32_t r = ao_cmd_hex();
if (ao_cmd_status == ao_cmd_success) {
- ao_watchdog_enabled = ao_cmd_lex_i != 0;
+ ao_watchdog_enabled = r != 0;
ao_wakeup(&ao_watchdog_enabled);
}
}
-static __code struct ao_cmds ao_watchdog_cmds[] = {
+static const struct ao_cmds ao_watchdog_cmds[] = {
{ ao_watchdog_set, "Q <0 off, 1 on>\0Enable or disable watchdog timer" },
{ 0, NULL },
};
@@ -56,7 +56,7 @@ static struct ao_task watchdog_task;
void
ao_watchdog_init(void)
{
- ao_enable_output(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, AO_WATCHDOG, 0);
+ ao_enable_output(AO_WATCHDOG_PORT, AO_WATCHDOG_BIT, 0);
ao_cmd_register(&ao_watchdog_cmds[0]);
ao_add_task(&watchdog_task, ao_watchdog, "watchdog");
}
diff --git a/src/easymega-v1.0/Makefile b/src/easymega-v1.0/Makefile
index c3b360b4..76e7319e 100644
--- a/src/easymega-v1.0/Makefile
+++ b/src/easymega-v1.0/Makefile
@@ -26,10 +26,8 @@ INC = \
ao_whiten.h \
ao_sample_profile.h \
ao_quaternion.h \
- math.h \
ao_mpu.h \
stm32l.h \
- math.h \
Makefile
#
@@ -47,21 +45,6 @@ INC = \
#STACK_GUARD=ao_mpu_stm.c
#STACK_GUARD_DEF=-DHAS_STACK_GUARD=1
-MATH_SRC=\
- ef_acos.c \
- ef_sqrt.c \
- ef_rem_pio2.c \
- kf_cos.c \
- kf_sin.c \
- kf_rem_pio2.c \
- sf_copysign.c \
- sf_cos.c \
- sf_fabs.c \
- sf_floor.c \
- sf_scalbn.c \
- sf_sin.c \
- ef_log.c
-
ALTOS_SRC = \
ao_boot_chain.c \
ao_interrupt.c \
@@ -70,7 +53,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
@@ -102,7 +85,6 @@ ALTOS_SRC = \
ao_flight.c \
ao_companion.c \
ao_pyro.c \
- $(MATH_SRC) \
$(PROFILE) \
$(SAMPLE_PROFILE) \
$(STACK_GUARD)
diff --git a/src/easymega-v1.0/ao_easymega.c b/src/easymega-v1.0/ao_easymega.c
index 9848c367..d00585f9 100644
--- a/src/easymega-v1.0/ao_easymega.c
+++ b/src/easymega-v1.0/ao_easymega.c
@@ -43,7 +43,7 @@ main(void)
#endif
ao_task_init();
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
ao_led_on(LEDS_AVAILABLE);
ao_timer_init();
diff --git a/src/easymega-v1.0/ao_pins.h b/src/easymega-v1.0/ao_pins.h
index b8016478..bfa777c6 100644
--- a/src/easymega-v1.0/ao_pins.h
+++ b/src/easymega-v1.0/ao_pins.h
@@ -77,6 +77,10 @@
#define USE_STORAGE_CONFIG 0
#define HAS_USB 1
#define HAS_BEEP 1
+#define BEEPER_TIMER 3
+#define BEEPER_CHANNEL 1
+#define BEEPER_PORT (&stm_gpioc)
+#define BEEPER_PIN 6
#define HAS_BATTERY_REPORT 1
#define HAS_RADIO 0
#define HAS_TELEMETRY 0
@@ -165,9 +169,6 @@
/* Number of general purpose pyro channels available */
#define AO_PYRO_NUM 4
-#define AO_IGNITER_SET_DROGUE(v) stm_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v)
-#define AO_IGNITER_SET_MAIN(v) stm_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, v)
-
/*
* ADC
*/
diff --git a/src/telescience-v0.2/Makefile b/src/easymega-v2.0/Makefile
index 6b7ea8c7..bfe8a849 100644
--- a/src/telescience-v0.2/Makefile
+++ b/src/easymega-v2.0/Makefile
@@ -9,14 +9,30 @@ 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 \
+ altitude-pa.h \
+ ao_kalman.h \
ao_product.h \
- ao_cc1120_CC1120.h \
+ ao_ms5607.h \
+ ao_mpu9250.h \
+ ao_adxl375.h \
+ ao_profile.h \
ao_task.h \
ao_whiten.h \
+ ao_sample_profile.h \
+ ao_quaternion.h \
+ ao_mpu.h \
stm32l.h \
Makefile
+#
+# Common AltOS sources
+#
+
#PROFILE=ao_profile.c
#PROFILE_DEF=-DAO_PROFILE=1
@@ -35,35 +51,52 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
ao_mutex.c \
+ ao_ignite.c \
+ ao_freq.c \
ao_dma_stm.c \
ao_spi_stm.c \
- ao_usb_stm.c \
- ao_adc_stm.c \
ao_data.c \
- ao_exti_stm.c \
+ ao_ms5607.c \
+ ao_mpu9250.c \
+ ao_adxl375.c \
+ ao_adc_stm.c \
+ ao_beep_stm.c \
+ ao_eeprom_stm.c \
ao_storage.c \
ao_m25.c \
- ao_science_slave.c \
- ao_spi_stm_slave.c \
- ao_log_telescience.c \
- ao_log_single.c
-
-PRODUCT=TeleScience-v0.2
-PRODUCT_DEF=-DTELESCIENCE
-IDPRODUCT=0x0011
+ ao_usb_stm.c \
+ ao_exti_stm.c \
+ ao_report.c \
+ ao_i2c_stm.c \
+ ao_convert_pa.c \
+ ao_convert_volt.c \
+ ao_log.c \
+ ao_log_mega.c \
+ ao_sample.c \
+ ao_kalman.c \
+ ao_flight.c \
+ ao_companion.c \
+ ao_pyro.c \
+ $(PROFILE) \
+ $(SAMPLE_PROFILE) \
+ $(STACK_GUARD)
+
+PRODUCT=EasyMega-v2.0
+PRODUCT_DEF=-DEASYMEGA
+IDPRODUCT=0x0028
CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) $(PROFILE_DEF) $(SAMPLE_PROFILE_DEF) $(STACK_GUARD_DEF) -Os -g
-PROGNAME=telescience-v0.2
+PROGNAME=easymega-v2.0
PROG=$(PROGNAME)-$(VERSION).elf
HEX=$(PROGNAME)-$(VERSION).ihx
-SRC=$(ALTOS_SRC) ao_telescience.c
+SRC=$(ALTOS_SRC) ao_easymega.c
OBJ=$(SRC:.c=.o)
all: $(PROG) $(HEX)
@@ -71,6 +104,9 @@ all: $(PROG) $(HEX)
$(PROG): Makefile $(OBJ) altos.ld
$(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS)
+../altitude-pa.h: make-altitude-pa
+ nickle $< > $@
+
$(OBJ): $(INC)
ao_product.h: ao-make-product.5c ../Version
diff --git a/src/telemini-v2.0/ao_telemini.c b/src/easymega-v2.0/ao_easymega.c
index a9ee423c..bb2e7cfd 100644
--- a/src/telemini-v2.0/ao_telemini.c
+++ b/src/easymega-v2.0/ao_easymega.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2011 Keith Packard <keithp@keithp.com>
+ * Copyright © 2014 Bdale Garbee <bdale@gag.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
@@ -16,11 +16,24 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "ao.h"
-#include "ao_pins.h"
+#include <ao.h>
+#include <ao_ms5607.h>
+#include <ao_mpu9250.h>
+#include <ao_adxl375.h>
+#include <ao_log.h>
#include <ao_exti.h>
+#include <ao_companion.h>
+#include <ao_profile.h>
+#include <ao_eeprom.h>
+#if HAS_SAMPLE_PROFILE
+#include <ao_sample_profile.h>
+#endif
+#include <ao_pyro.h>
+#if HAS_STACK_GUARD
+#include <ao_mpu.h>
+#endif
-void
+int
main(void)
{
ao_clock_init();
@@ -28,24 +41,26 @@ main(void)
#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_task_init();
+ ao_led_init();
+ ao_led_on(LEDS_AVAILABLE);
ao_timer_init();
+ ao_i2c_init();
ao_spi_init();
+ ao_dma_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_mpu9250_init();
+ ao_adxl375_init();
+
+ ao_eeprom_init();
ao_storage_init();
ao_flight_init();
@@ -53,12 +68,19 @@ main(void)
ao_report_init();
ao_usb_init();
- ao_telemetry_init();
- ao_radio_init();
- ao_packet_slave_init(TRUE);
-
ao_igniter_init();
+ ao_companion_init();
+ ao_pyro_init();
ao_config_init();
+#if AO_PROFILE
+ ao_profile_init();
+#endif
+#if HAS_SAMPLE_PROFILE
+ ao_sample_profile_init();
+#endif
+
+ ao_led_off(LEDS_AVAILABLE);
ao_start_scheduler();
+ return 0;
}
diff --git a/src/easymega-v2.0/ao_pins.h b/src/easymega-v2.0/ao_pins.h
new file mode 100644
index 00000000..6217b5d2
--- /dev/null
+++ b/src/easymega-v2.0/ao_pins.h
@@ -0,0 +1,354 @@
+/*
+ * Copyright © 2014 Bdale Garbee <bdale@gag.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.
+ */
+
+#ifndef _AO_PINS_H_
+#define _AO_PINS_H_
+
+#define HAS_TASK_QUEUE 1
+
+/* 16MHz High speed external crystal */
+#define AO_HSE 16000000
+
+/* PLLVCO = 96MHz (so that USB will work) */
+#define AO_PLLMUL 6
+#define AO_RCC_CFGR_PLLMUL (STM_RCC_CFGR_PLLMUL_6)
+
+/* 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_SERIAL_1 0
+#define USE_SERIAL_1_STDIN 0
+#define SERIAL_1_PB6_PB7 0
+#define SERIAL_1_PA9_PA10 0
+
+#define HAS_SERIAL_2 0
+#define USE_SERIAL_2_STDIN 0
+#define SERIAL_2_PA2_PA3 0
+#define SERIAL_2_PD5_PD6 0
+
+#define HAS_SERIAL_3 0
+#define USE_SERIAL_3_STDIN 0
+#define SERIAL_3_PB10_PB11 0
+#define SERIAL_3_PC10_PC11 0
+#define SERIAL_3_PD8_PD9 0
+
+#define ao_gps_getchar ao_serial1_getchar
+#define ao_gps_putchar ao_serial1_putchar
+#define ao_gps_set_speed ao_serial1_set_speed
+#define ao_gps_fifo (ao_stm_usart1.rx_fifo)
+
+#define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX (1024 * 1024)
+#define AO_CONFIG_MAX_SIZE 1024
+#define LOG_ERASE_MARK 0x55
+#define LOG_MAX_ERASE 128
+#define AO_LOG_FORMAT AO_LOG_FORMAT_TELEMEGA
+
+#define HAS_EEPROM 1
+#define USE_INTERNAL_FLASH 0
+#define USE_EEPROM_CONFIG 1
+#define USE_STORAGE_CONFIG 0
+#define HAS_USB 1
+#define HAS_BEEP 1
+#define BEEPER_TIMER 2
+#define BEEPER_CHANNEL 3
+#define BEEPER_PORT (&stm_gpioa)
+#define BEEPER_PIN 2
+#define HAS_BATTERY_REPORT 1
+#define HAS_RADIO 0
+#define HAS_TELEMETRY 0
+#define HAS_APRS 0
+#define HAS_COMPANION 1
+
+#define HAS_SPI_1 1
+#define SPI_1_PA5_PA6_PA7 1 /* Barometer */
+#define SPI_1_PB3_PB4_PB5 1 /* Accelerometer */
+#define SPI_1_PE13_PE14_PE15 0
+#define SPI_1_OSPEEDR STM_OSPEEDR_10MHz
+
+#define HAS_SPI_2 1
+#define SPI_2_PB13_PB14_PB15 1 /* Flash, IMU, Companion */
+#define SPI_2_PD1_PD3_PD4 0
+#define SPI_2_OSPEEDR STM_OSPEEDR_10MHz
+
+#define HAS_I2C_1 1
+#define I2C_1_PB8_PB9 1
+
+#define HAS_I2C_2 0
+#define I2C_2_PB10_PB11 0
+
+#define PACKET_HAS_SLAVE 0
+#define PACKET_HAS_MASTER 0
+
+#define LOW_LEVEL_DEBUG 0
+
+#define LED_PORT_ENABLE STM_RCC_AHBENR_GPIOAEN
+#define LED_PORT (&stm_gpioa)
+#define LED_PIN_RED 9
+#define LED_PIN_GREEN 10
+#define AO_LED_RED (1 << LED_PIN_RED)
+#define AO_LED_GREEN (1 << LED_PIN_GREEN)
+
+#define LEDS_AVAILABLE (AO_LED_RED | AO_LED_GREEN)
+
+#define HAS_GPS 0
+#define HAS_FLIGHT 1
+#define HAS_ADC 1
+#define HAS_ADC_TEMP 1
+#define HAS_LOG 1
+
+/*
+ * Igniter
+ */
+
+#define HAS_IGNITE 1
+#define HAS_IGNITE_REPORT 1
+
+#define AO_SENSE_PYRO(p,n) ((p)->adc.sense[n])
+#define AO_SENSE_DROGUE(p) ((p)->adc.sense[4])
+#define AO_SENSE_MAIN(p) ((p)->adc.sense[5])
+#define AO_IGNITER_CLOSED 400
+#define AO_IGNITER_OPEN 60
+
+/* Pyro A */
+#define AO_PYRO_PORT_0 (&stm_gpioa)
+#define AO_PYRO_PIN_0 15
+
+/* Pyro B */
+#define AO_PYRO_PORT_1 (&stm_gpioc)
+#define AO_PYRO_PIN_1 10
+
+/* Pyro C */
+#define AO_PYRO_PORT_2 (&stm_gpiob)
+#define AO_PYRO_PIN_2 11
+
+/* Pyro D */
+#define AO_PYRO_PORT_3 (&stm_gpiob)
+#define AO_PYRO_PIN_3 10
+
+/* Drogue */
+#define AO_IGNITER_DROGUE_PORT (&stm_gpioa)
+#define AO_IGNITER_DROGUE_PIN 0
+
+/* Main */
+#define AO_IGNITER_MAIN_PORT (&stm_gpioa)
+#define AO_IGNITER_MAIN_PIN 1
+
+/* Number of general purpose pyro channels available */
+#define AO_PYRO_NUM 4
+
+/*
+ * ADC
+ */
+#define AO_DATA_RING 32
+#define AO_ADC_NUM_SENSE 6
+
+struct ao_adc {
+ int16_t sense[AO_ADC_NUM_SENSE];
+ int16_t v_batt;
+ int16_t v_pbatt;
+ int16_t temp;
+};
+
+#define AO_ADC_DUMP(p) \
+ printf("tick: %5u A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
+ (p)->tick, \
+ (p)->adc.sense[0], (p)->adc.sense[1], (p)->adc.sense[2], \
+ (p)->adc.sense[3], (p)->adc.sense[4], (p)->adc.sense[5], \
+ (p)->adc.v_batt, (p)->adc.v_pbatt, (p)->adc.temp)
+
+#define AO_ADC_SENSE_A 14
+#define AO_ADC_SENSE_A_PORT (&stm_gpioc)
+#define AO_ADC_SENSE_A_PIN 4
+
+#define AO_ADC_SENSE_B 15
+#define AO_ADC_SENSE_B_PORT (&stm_gpioc)
+#define AO_ADC_SENSE_B_PIN 5
+
+#define AO_ADC_SENSE_C 13
+#define AO_ADC_SENSE_C_PORT (&stm_gpioc)
+#define AO_ADC_SENSE_C_PIN 3
+
+#define AO_ADC_SENSE_D 12
+#define AO_ADC_SENSE_D_PORT (&stm_gpioc)
+#define AO_ADC_SENSE_D_PIN 2
+
+#define AO_ADC_SENSE_DROGUE 11
+#define AO_ADC_SENSE_DROGUE_PORT (&stm_gpioc)
+#define AO_ADC_SENSE_DROGUE_PIN 1
+
+#define AO_ADC_SENSE_MAIN 10
+#define AO_ADC_SENSE_MAIN_PORT (&stm_gpioc)
+#define AO_ADC_SENSE_MAIN_PIN 0
+
+#define AO_ADC_V_BATT 8
+#define AO_ADC_V_BATT_PORT (&stm_gpiob)
+#define AO_ADC_V_BATT_PIN 0
+
+#define AO_ADC_V_PBATT 9
+#define AO_ADC_V_PBATT_PORT (&stm_gpiob)
+#define AO_ADC_V_PBATT_PIN 1
+
+#define AO_ADC_TEMP 16
+
+#define AO_ADC_RCC_AHBENR ((1 << STM_RCC_AHBENR_GPIOAEN) | \
+ (1 << STM_RCC_AHBENR_GPIOEEN) | \
+ (1 << STM_RCC_AHBENR_GPIOBEN))
+
+#define AO_NUM_ADC_PIN (AO_ADC_NUM_SENSE + 2)
+
+#define AO_ADC_PIN0_PORT AO_ADC_SENSE_A_PORT
+#define AO_ADC_PIN0_PIN AO_ADC_SENSE_A_PIN
+#define AO_ADC_PIN1_PORT AO_ADC_SENSE_B_PORT
+#define AO_ADC_PIN1_PIN AO_ADC_SENSE_B_PIN
+#define AO_ADC_PIN2_PORT AO_ADC_SENSE_C_PORT
+#define AO_ADC_PIN2_PIN AO_ADC_SENSE_C_PIN
+#define AO_ADC_PIN3_PORT AO_ADC_SENSE_D_PORT
+#define AO_ADC_PIN3_PIN AO_ADC_SENSE_D_PIN
+#define AO_ADC_PIN4_PORT AO_ADC_SENSE_DROGUE_PORT
+#define AO_ADC_PIN4_PIN AO_ADC_SENSE_DROGUE_PIN
+#define AO_ADC_PIN5_PORT AO_ADC_SENSE_MAIN_PORT
+#define AO_ADC_PIN5_PIN AO_ADC_SENSE_MAIN_PIN
+#define AO_ADC_PIN6_PORT AO_ADC_V_BATT_PORT
+#define AO_ADC_PIN6_PIN AO_ADC_V_BATT_PIN
+#define AO_ADC_PIN7_PORT AO_ADC_V_PBATT_PORT
+#define AO_ADC_PIN7_PIN AO_ADC_V_PBATT_PIN
+
+#define AO_NUM_ADC (AO_ADC_NUM_SENSE + 3)
+
+#define AO_ADC_SQ1 AO_ADC_SENSE_A
+#define AO_ADC_SQ2 AO_ADC_SENSE_B
+#define AO_ADC_SQ3 AO_ADC_SENSE_C
+#define AO_ADC_SQ4 AO_ADC_SENSE_D
+#define AO_ADC_SQ5 AO_ADC_SENSE_DROGUE
+#define AO_ADC_SQ6 AO_ADC_SENSE_MAIN
+#define AO_ADC_SQ7 AO_ADC_V_BATT
+#define AO_ADC_SQ8 AO_ADC_V_PBATT
+#define AO_ADC_SQ9 AO_ADC_TEMP
+
+/*
+ * Voltage divider on ADC battery sampler
+ */
+#define AO_BATTERY_DIV_PLUS 56 /* 5.6k */
+#define AO_BATTERY_DIV_MINUS 100 /* 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
+
+/*
+ * Pressure sensor settings
+ */
+#define HAS_MS5607 1
+#define HAS_MS5611 0
+#define AO_MS5607_PRIVATE_PINS 1
+#define AO_MS5607_CS_PORT (&stm_gpioa)
+#define AO_MS5607_CS_PIN 3
+#define AO_MS5607_CS_MASK (1 << AO_MS5607_CS_PIN)
+#define AO_MS5607_MISO_PORT (&stm_gpioa)
+#define AO_MS5607_MISO_PIN 6
+#define AO_MS5607_MISO_MASK (1 << AO_MS5607_MISO_PIN)
+#define AO_MS5607_SPI_INDEX AO_SPI_1_PA5_PA6_PA7
+
+/*
+ * SPI Flash memory
+ */
+
+#define M25_MAX_CHIPS 1
+#define AO_M25_SPI_CS_PORT (&stm_gpiob)
+#define AO_M25_SPI_CS_PIN 12
+#define AO_M25_SPI_CS_MASK (1 << AO_M25_SPI_CS_PIN)
+#define AO_M25_SPI_BUS AO_SPI_2_PB13_PB14_PB15
+
+/*
+ * mpu9250
+ */
+
+#define HAS_MPU9250 1
+#define AO_MPU9250_INT_PORT (&stm_gpioc)
+#define AO_MPU9250_INT_PIN 15
+#define AO_MPU9250_SPI_BUS (AO_SPI_2_PB13_PB14_PB15 | AO_SPI_MODE_0)
+#define AO_MPU9250_SPI_CS_PORT (&stm_gpioc)
+#define AO_MPU9250_SPI_CS_PIN 13
+#define HAS_IMU 1
+
+/* ADXL375 */
+
+#define HAS_ADXL375 1
+#define AO_ADXL375_SPI_INDEX (AO_SPI_1_PB3_PB4_PB5 | AO_SPI_MODE_3)
+#define AO_ADXL375_CS_PORT (&stm_gpioc)
+#define AO_ADXL375_CS_PIN 12
+#define AO_ADXL375_SPI_SPEED AO_SPI_SPEED_4MHz
+
+#define AO_ADXL375_INT1_PORT (&stm_gpiob)
+#define AO_ADXL375_INT1_PIN 8
+
+#define AO_ADXL375_INT2_PORT (&stm_gpiob)
+#define AO_ADXL375_INT2_PIN 9
+
+#define AO_ADXL375_AXIS x
+#define AO_ADXL375_INVERT 1
+
+#define NUM_CMDS 16
+
+/*
+ * Companion
+ */
+
+#define AO_COMPANION_CS_PORT (&stm_gpiob)
+#define AO_COMPANION_CS_PIN (6)
+#define AO_COMPANION_SPI_BUS AO_SPI_2_PB13_PB14_PB15
+
+/*
+ * Monitor
+ */
+
+#define HAS_MONITOR 0
+#define LEGACY_MONITOR 0
+#define HAS_MONITOR_PUT 0
+#define AO_MONITOR_LED 0
+#define HAS_RSSI 0
+
+/*
+ * Profiling Viterbi decoding
+ */
+
+#ifndef AO_PROFILE
+#define AO_PROFILE 0
+#endif
+
+#endif /* _AO_PINS_H_ */
diff --git a/src/megadongle-v0.1/flash-loader/Makefile b/src/easymega-v2.0/flash-loader/Makefile
index adea5786..a5594006 100644
--- a/src/megadongle-v0.1/flash-loader/Makefile
+++ b/src/easymega-v2.0/flash-loader/Makefile
@@ -1,7 +1,8 @@
#
# AltOS flash loader build
#
+#
TOPDIR=../..
-HARDWARE=megadongle-v0.1
+HARDWARE=easymega-v2.0
include $(TOPDIR)/stm/Makefile-flash.defs
diff --git a/src/telescience-v0.2/flash-loader/ao_pins.h b/src/easymega-v2.0/flash-loader/ao_pins.h
index 8eaf9299..324b0eb9 100644
--- a/src/telescience-v0.2/flash-loader/ao_pins.h
+++ b/src/easymega-v2.0/flash-loader/ao_pins.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2013 Keith Packard <keithp@keithp.com>
+ * Copyright © 2018 Bdale Garbee <bdale@gag.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
@@ -19,16 +19,16 @@
#ifndef _AO_PINS_H_
#define _AO_PINS_H_
-/* External crystal at 8MHz */
-#define AO_HSE 8000000
+/* External crystal at 16MHz */
+#define AO_HSE 16000000
#include <ao_flash_stm_pins.h>
-/* Companion port SS PA4 */
+/* Companion port cs_companion0 PB6 */
#define AO_BOOT_PIN 1
-#define AO_BOOT_APPLICATION_GPIO stm_gpioa
-#define AO_BOOT_APPLICATION_PIN 4
+#define AO_BOOT_APPLICATION_GPIO stm_gpiob
+#define AO_BOOT_APPLICATION_PIN 6
#define AO_BOOT_APPLICATION_VALUE 1
#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP
diff --git a/src/easymini-v1.0/ao_pins.h b/src/easymini-v1.0/ao_pins.h
index 45c6891d..201b913e 100644
--- a/src/easymini-v1.0/ao_pins.h
+++ b/src/easymini-v1.0/ao_pins.h
@@ -123,11 +123,9 @@ struct ao_adc {
#define AO_IGNITER_DROGUE_PORT 0
#define AO_IGNITER_DROGUE_PIN 2
-#define AO_IGNITER_SET_DROGUE(v) ao_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, AO_IGNITER_DROGUE, v)
#define AO_IGNITER_MAIN_PORT 0
#define AO_IGNITER_MAIN_PIN 3
-#define AO_IGNITER_SET_MAIN(v) ao_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, AO_IGNITER_MAIN, v)
#define AO_SENSE_DROGUE(p) ((p)->adc.sense_a)
#define AO_SENSE_MAIN(p) ((p)->adc.sense_m)
diff --git a/src/easymini-v2.0/ao_pins.h b/src/easymini-v2.0/ao_pins.h
index 47eb577e..38d46310 100644
--- a/src/easymini-v2.0/ao_pins.h
+++ b/src/easymini-v2.0/ao_pins.h
@@ -132,11 +132,9 @@ struct ao_adc {
#define AO_IGNITER_DROGUE_PORT (&stm_gpioa)
#define AO_IGNITER_DROGUE_PIN 3
-#define AO_IGNITER_SET_DROGUE(v) ao_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, AO_IGNITER_DROGUE, v)
#define AO_IGNITER_MAIN_PORT (&stm_gpiob)
#define AO_IGNITER_MAIN_PIN 7
-#define AO_IGNITER_SET_MAIN(v) ao_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, AO_IGNITER_MAIN, v)
#define AO_SENSE_DROGUE(p) ((p)->adc.sense_a)
#define AO_SENSE_MAIN(p) ((p)->adc.sense_m)
diff --git a/src/fox1ihu/Makefile b/src/fox1ihu/Makefile
index e3226a24..61314db9 100644
--- a/src/fox1ihu/Makefile
+++ b/src/fox1ihu/Makefile
@@ -37,7 +37,7 @@ ALTOS_SRC = \
ao_romconfig.c \
ao_cmd.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/fox1ihu/ao_fox1ihu.c b/src/fox1ihu/ao_fox1ihu.c
index 2e1a2fdf..5ebb4b54 100644
--- a/src/fox1ihu/ao_fox1ihu.c
+++ b/src/fox1ihu/ao_fox1ihu.c
@@ -31,7 +31,7 @@ main(void)
#endif
ao_task_init();
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
ao_led_on(AO_LED_RED|AO_LED_GREEN|AO_LED_RED_2|AO_LED_GREEN_2);
ao_timer_init();
diff --git a/src/kernel/ao.h b/src/kernel/ao.h
index 0a3981d7..9baae8b4 100644
--- a/src/kernel/ao.h
+++ b/src/kernel/ao.h
@@ -23,22 +23,18 @@
#include <stdio.h>
#include <string.h>
#include <stddef.h>
+#include <stdbool.h>
#include <ao_pins.h>
#include <ao_arch.h>
-#define TRUE 1
-#define FALSE 0
+/* replace stdio macros with direct calls to our functions */
+#undef putchar
+#undef getchar
+#define putchar(c) ao_putchar(c)
+#define getchar ao_getchar
-/* Convert a __data pointer into an __xdata pointer */
-#ifndef DATA_TO_XDATA
-#define DATA_TO_XDATA(a) (a)
-#endif
-#ifndef PDATA_TO_XDATA
-#define PDATA_TO_XDATA(a) (a)
-#endif
-#ifndef CODE_TO_XDATA
-#define CODE_TO_XDATA(a) (a)
-#endif
+extern int ao_putchar(char c);
+extern char ao_getchar(void);
#ifndef HAS_TASK
#define HAS_TASK 1
@@ -86,6 +82,19 @@ void
ao_panic(uint8_t reason);
/*
+ * ao_romconfig.c
+ */
+
+#define AO_ROMCONFIG_VERSION 2
+
+extern AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_version;
+extern AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_check;
+extern AO_ROMCONFIG_SYMBOL uint16_t ao_serial_number;
+#if HAS_RADIO
+extern AO_ROMCONFIG_SYMBOL uint32_t ao_radio_cal;
+#endif
+
+/*
* ao_timer.c
*/
@@ -94,7 +103,7 @@ ao_panic(uint8_t reason);
#define AO_TICK_SIGNED int16_t
#endif
-extern volatile __data AO_TICK_TYPE ao_tick_count;
+extern volatile AO_TICK_TYPE ao_tick_count;
/* Our timer runs at 100Hz */
#ifndef AO_HERTZ
@@ -115,10 +124,6 @@ ao_delay(uint16_t ticks);
void
ao_timer_set_adc_interval(uint8_t interval);
-/* Timer interrupt */
-void
-ao_timer_isr(void) ao_arch_interrupt(9);
-
/* Initialize the timer */
void
ao_timer_init(void);
@@ -143,13 +148,13 @@ ao_clock_resume(void);
#ifndef ao_mutex_get
uint8_t
-ao_mutex_try(__xdata uint8_t *ao_mutex, uint8_t task_id) __reentrant;
+ao_mutex_try(uint8_t *ao_mutex, uint8_t task_id);
void
-ao_mutex_get(__xdata uint8_t *ao_mutex) __reentrant;
+ao_mutex_get(uint8_t *ao_mutex);
void
-ao_mutex_put(__xdata uint8_t *ao_mutex) __reentrant;
+ao_mutex_put(uint8_t *ao_mutex);
#endif
/*
@@ -162,16 +167,14 @@ enum ao_cmd_status {
ao_cmd_syntax_error = 2,
};
-extern __pdata uint16_t ao_cmd_lex_i;
-extern __pdata uint32_t ao_cmd_lex_u32;
-extern __pdata char ao_cmd_lex_c;
-extern __pdata enum ao_cmd_status ao_cmd_status;
+extern char ao_cmd_lex_c;
+extern enum ao_cmd_status ao_cmd_status;
void
-ao_put_string(__code char *s);
+ao_put_string(const char *s);
void
-ao_cmd_readline(void);
+ao_cmd_readline(const char *prompt);
char
ao_cmd_lex(void);
@@ -191,29 +194,29 @@ ao_cmd_white(void);
int8_t
ao_cmd_hexchar(char c);
-void
+uint8_t
ao_cmd_hexbyte(void);
-void
+uint32_t
ao_cmd_hex(void);
-void
-ao_cmd_decimal(void) __reentrant;
+uint32_t
+ao_cmd_decimal(void);
/* Read a single hex nibble off stdin. */
uint8_t
ao_getnibble(void);
uint8_t
-ao_match_word(__code char *word);
+ao_match_word(const char *word);
struct ao_cmds {
void (*func)(void);
- __code char *help;
+ const char *help;
};
void
-ao_cmd_register(const __code struct ao_cmds *cmds);
+ao_cmd_register(const struct ao_cmds *cmds);
void
ao_cmd_init(void);
@@ -240,7 +243,7 @@ ao_cmd_filter(void);
#include <ao_beep.h>
#endif
-#if LEDS_AVAILABLE
+#if LEDS_AVAILABLE || HAS_LED
#include <ao_led.h>
#endif
@@ -297,13 +300,13 @@ ao_report_init(void);
#if HAS_BARO
/* pressure from the sensor to altitude in meters */
alt_t
-ao_pres_to_altitude(pres_t pres) __reentrant;
+ao_pres_to_altitude(pres_t pres);
pres_t
-ao_altitude_to_pres(alt_t alt) __reentrant;
+ao_altitude_to_pres(alt_t alt);
int16_t
-ao_temp_to_dC(int16_t temp) __reentrant;
+ao_temp_to_dC(int16_t temp);
#endif
/*
@@ -379,11 +382,11 @@ ao_spi_slave(void);
#define AO_GPS_NEW_DATA 1
#define AO_GPS_NEW_TRACKING 2
-extern __xdata uint8_t ao_gps_new;
-extern __pdata uint16_t ao_gps_tick;
-extern __xdata uint8_t ao_gps_mutex;
-extern __xdata struct ao_telemetry_location ao_gps_data;
-extern __xdata struct ao_telemetry_satellite ao_gps_tracking_data;
+extern uint8_t ao_gps_new;
+extern uint16_t ao_gps_tick;
+extern uint8_t ao_gps_mutex;
+extern struct ao_telemetry_location ao_gps_data;
+extern struct ao_telemetry_satellite ao_gps_tracking_data;
struct ao_gps_orig {
uint8_t year;
@@ -423,13 +426,13 @@ void
ao_gps(void);
void
-ao_gps_print(__xdata struct ao_gps_orig *gps_data);
+ao_gps_print(struct ao_gps_orig *gps_data);
void
-ao_gps_tracking_print(__xdata struct ao_gps_tracking_orig *gps_tracking_data);
+ao_gps_tracking_print(struct ao_gps_tracking_orig *gps_tracking_data);
void
-ao_gps_show(void) __reentrant;
+ao_gps_show(void);
void
ao_gps_init(void);
@@ -560,9 +563,9 @@ ao_telemetry_tiny_init(void);
* ao_radio.c
*/
-extern __xdata uint8_t ao_radio_dma;
+extern uint8_t ao_radio_dma;
-extern __xdata int8_t ao_radio_rssi;
+extern int8_t ao_radio_rssi;
#ifdef PKT_APPEND_STATUS_1_CRC_OK
#define AO_RADIO_STATUS_CRC_OK PKT_APPEND_STATUS_1_CRC_OK
@@ -587,17 +590,14 @@ extern __xdata int8_t ao_radio_rssi;
#define HAS_RADIO_RATE HAS_RADIO
#endif
-void
-ao_radio_general_isr(void) ao_arch_interrupt(16);
-
#if HAS_RADIO_XMIT
void
-ao_radio_send(const __xdata void *d, uint8_t size) __reentrant;
+ao_radio_send(const void *d, uint8_t size);
#endif
#if HAS_RADIO_RECV
uint8_t
-ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout) __reentrant;
+ao_radio_recv(void *d, uint8_t size, uint8_t timeout);
void
ao_radio_recv_abort(void);
@@ -675,14 +675,14 @@ union ao_monitor {
#endif
};
-extern __xdata union ao_monitor ao_monitor_ring[AO_MONITOR_RING];
+extern union ao_monitor ao_monitor_ring[AO_MONITOR_RING];
#define ao_monitor_ring_next(n) (((n) + 1) & (AO_MONITOR_RING - 1))
#define ao_monitor_ring_prev(n) (((n) - 1) & (AO_MONITOR_RING - 1))
-extern __xdata uint8_t ao_monitoring_mutex;
-extern __data uint8_t ao_monitoring;
-extern __data uint8_t ao_monitor_head;
+extern uint8_t ao_monitoring_mutex;
+extern uint8_t ao_monitoring;
+extern uint8_t ao_monitor_head;
void
ao_monitor(void);
@@ -700,7 +700,7 @@ void
ao_monitor_enable(void);
void
-ao_monitor_init(void) __reentrant;
+ao_monitor_init(void);
#endif
@@ -712,27 +712,27 @@ ao_monitor_init(void) __reentrant;
struct ao_stdio {
int (*_pollchar)(void); /* Called with interrupts blocked */
- void (*putchar)(char c) __reentrant;
+ void (*putchar)(char c);
void (*flush)(void);
uint8_t echo;
};
-extern __xdata struct ao_stdio ao_stdios[];
-extern __pdata int8_t ao_cur_stdio;
-extern __pdata int8_t ao_num_stdios;
+extern struct ao_stdio ao_stdios[];
+extern int8_t ao_cur_stdio;
+extern int8_t ao_num_stdios;
void
flush(void);
-extern __xdata uint8_t ao_stdin_ready;
+extern uint8_t ao_stdin_ready;
uint8_t
ao_echo(void);
int8_t
ao_add_stdio(int (*pollchar)(void),
- void (*putchar)(char) __reentrant,
- void (*flush)(void)) __reentrant;
+ void (*putchar)(char) ,
+ void (*flush)(void));
/*
* ao_ignite.c
@@ -759,14 +759,14 @@ struct ao_ignition {
uint8_t firing;
};
-extern __code char * __code ao_igniter_status_names[];
+extern const char * const ao_igniter_status_names[];
-extern __xdata struct ao_ignition ao_ignition[2];
+extern struct ao_ignition ao_ignition[2];
enum ao_igniter_status
ao_igniter_status(enum ao_igniter igniter);
-extern __pdata uint8_t ao_igniter_present;
+extern uint8_t ao_igniter_present;
void
ao_ignite_set_pins(void);
@@ -787,7 +787,7 @@ ao_igniter_init(void);
/*
* Set this to force the frequency to 434.550MHz
*/
-extern __xdata uint8_t ao_force_freq;
+extern uint8_t ao_force_freq;
#endif
/*
@@ -887,8 +887,8 @@ union ao_log_single {
uint8_t bytes[AO_LOG_SINGLE_SIZE];
};
-extern __xdata union ao_log_single ao_log_single_write_data;
-extern __xdata union ao_log_single ao_log_single_read_data;
+extern union ao_log_single ao_log_single_write_data;
+extern union ao_log_single ao_log_single_read_data;
void
ao_log_single_extra_query(void);
@@ -950,9 +950,6 @@ ao_terraui_init(void);
*/
#ifdef BATTERY_PIN
-void
-ao_battery_isr(void) ao_arch_interrupt(1);
-
uint16_t
ao_battery_get(void);
@@ -971,7 +968,7 @@ ao_sqrt(uint32_t op);
* ao_freq.c
*/
-int32_t ao_freq_to_set(int32_t freq, int32_t cal) __reentrant;
+int32_t ao_freq_to_set(int32_t freq, int32_t cal);
/*
* ao_ms5607.c
diff --git a/src/kernel/ao_aes.h b/src/kernel/ao_aes.h
index 5ae98424..f41b2e87 100644
--- a/src/kernel/ao_aes.h
+++ b/src/kernel/ao_aes.h
@@ -21,7 +21,7 @@
/* ao_aes.c */
-extern __xdata uint8_t ao_aes_mutex;
+extern uint8_t ao_aes_mutex;
/* AES keys and blocks are 128 bits */
@@ -40,14 +40,14 @@ void
ao_aes_set_mode(enum ao_aes_mode mode);
void
-ao_aes_set_key(__xdata uint8_t *in);
+ao_aes_set_key(uint8_t *in);
void
ao_aes_zero_iv(void);
void
-ao_aes_run(__xdata uint8_t *in,
- __xdata uint8_t *out);
+ao_aes_run(uint8_t *in,
+ uint8_t *out);
void
ao_aes_init(void);
diff --git a/src/kernel/ao_balloon.c b/src/kernel/ao_balloon.c
index 47b69e25..a5be8c16 100644
--- a/src/kernel/ao_balloon.c
+++ b/src/kernel/ao_balloon.c
@@ -34,16 +34,16 @@
#if HAS_SENSOR_ERRORS
/* Any sensor can set this to mark the flight computer as 'broken' */
-__xdata uint8_t ao_sensor_errors;
+uint8_t ao_sensor_errors;
#endif
-__pdata uint16_t ao_motor_number; /* number of motors burned so far */
+uint16_t ao_motor_number; /* number of motors burned so far */
/* Main flight thread. */
-__pdata enum ao_flight_state ao_flight_state; /* current flight state */
+enum ao_flight_state ao_flight_state; /* current flight state */
-__pdata uint8_t ao_flight_force_idle;
+uint8_t ao_flight_force_idle;
void
ao_flight(void)
@@ -96,7 +96,7 @@ ao_flight(void)
ao_led_off(AO_LED_RED);
}
/* wakeup threads due to state change */
- ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
+ ao_wakeup(&ao_flight_state);
break;
case ao_flight_pad:
@@ -118,7 +118,7 @@ ao_flight(void)
ao_wakeup(&ao_gps_new);
#endif
- ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
+ ao_wakeup(&ao_flight_state);
}
break;
default:
@@ -127,7 +127,7 @@ ao_flight(void)
}
}
-static __xdata struct ao_task flight_task;
+static struct ao_task flight_task;
void
ao_flight_init(void)
diff --git a/src/kernel/ao_beep.h b/src/kernel/ao_beep.h
index 1306af62..fdc150f1 100644
--- a/src/kernel/ao_beep.h
+++ b/src/kernel/ao_beep.h
@@ -85,7 +85,7 @@ ao_beep(uint8_t beep);
/* Turn on the beeper for the specified time */
void
-ao_beep_for(uint8_t beep, uint16_t ticks) __reentrant;
+ao_beep_for(uint8_t beep, uint16_t ticks);
/* Initialize the beeper */
void
diff --git a/src/kernel/ao_cmd.c b/src/kernel/ao_cmd.c
index 7bb4654e..d1c049ac 100644
--- a/src/kernel/ao_cmd.c
+++ b/src/kernel/ao_cmd.c
@@ -19,10 +19,8 @@
#include "ao.h"
#include "ao_task.h"
-__pdata uint16_t ao_cmd_lex_i;
-__pdata uint32_t ao_cmd_lex_u32;
-__pdata char ao_cmd_lex_c;
-__pdata enum ao_cmd_status ao_cmd_status;
+char ao_cmd_lex_c;
+enum ao_cmd_status ao_cmd_status;
#ifndef AO_CMD_LEN
#if AO_PYRO_NUM
@@ -32,30 +30,26 @@ __pdata enum ao_cmd_status ao_cmd_status;
#endif
#endif
-static __xdata char cmd_line[AO_CMD_LEN];
-static __pdata uint8_t cmd_len;
-static __pdata uint8_t cmd_i;
+static char cmd_line[AO_CMD_LEN];
+static uint8_t cmd_len;
+static uint8_t cmd_i;
+
+static const char backspace[] = "\010 \010";
void
-ao_put_string(__code char *s)
+ao_put_string(const char *s)
{
char c;
while ((c = *s++))
putchar(c);
}
-static void
-backspace(void)
-{
- ao_put_string ("\010 \010");
-}
-
void
-ao_cmd_readline(void)
+ao_cmd_readline(const char *prompt)
{
char c;
if (ao_echo())
- ao_put_string("> ");
+ ao_put_string(prompt);
cmd_len = 0;
for (;;) {
flush();
@@ -64,7 +58,7 @@ ao_cmd_readline(void)
if (c == '\010' || c == '\177') {
if (cmd_len != 0) {
if (ao_echo())
- backspace();
+ ao_put_string(backspace);
--cmd_len;
}
continue;
@@ -74,7 +68,7 @@ ao_cmd_readline(void)
if (c == '\025') {
while (cmd_len != 0) {
if (ao_echo())
- backspace();
+ ao_put_string(backspace);
--cmd_len;
}
continue;
@@ -174,55 +168,48 @@ ao_cmd_hexchar(char c)
return -1;
}
-void
-ao_cmd_hexbyte(void)
+static uint32_t
+get_hex(uint8_t lim)
{
+ uint32_t result = 0;
uint8_t i;
- int8_t n;
- ao_cmd_lex_i = 0;
ao_cmd_white();
- for (i = 0; i < 2; i++) {
- n = ao_cmd_hexchar(ao_cmd_lex_c);
+ for (i = 0; i < lim; i++) {
+ int8_t n = ao_cmd_hexchar(ao_cmd_lex_c);
if (n < 0) {
- ao_cmd_status = ao_cmd_syntax_error;
+ if (i == 0 || lim != 0xff)
+ ao_cmd_status = ao_cmd_lex_error;
break;
}
- ao_cmd_lex_i = (ao_cmd_lex_i << 4) | n;
+ result = (result << 4) | n;
ao_cmd_lex();
}
+ return result;
}
-void
-ao_cmd_hex(void)
+uint8_t
+ao_cmd_hexbyte(void)
{
- __pdata uint8_t r = ao_cmd_lex_error;
- int8_t n;
+ return get_hex(2);
+}
- ao_cmd_lex_i = 0;
- ao_cmd_white();
- for(;;) {
- n = ao_cmd_hexchar(ao_cmd_lex_c);
- if (n < 0)
- break;
- ao_cmd_lex_i = (ao_cmd_lex_i << 4) | n;
- r = ao_cmd_success;
- ao_cmd_lex();
- }
- if (r != ao_cmd_success)
- ao_cmd_status = r;
+uint32_t
+ao_cmd_hex(void)
+{
+ return get_hex(0xff);
}
-void
-ao_cmd_decimal(void) __reentrant
+uint32_t
+ao_cmd_decimal(void)
{
+ uint32_t result = 0;
uint8_t r = ao_cmd_lex_error;
- ao_cmd_lex_u32 = 0;
ao_cmd_white();
for(;;) {
if ('0' <= ao_cmd_lex_c && ao_cmd_lex_c <= '9')
- ao_cmd_lex_u32 = (ao_cmd_lex_u32 * 10) + (ao_cmd_lex_c - '0');
+ result = result * 10 + (ao_cmd_lex_c - '0');
else
break;
r = ao_cmd_success;
@@ -230,11 +217,11 @@ ao_cmd_decimal(void) __reentrant
}
if (r != ao_cmd_success)
ao_cmd_status = r;
- ao_cmd_lex_i = (uint16_t) ao_cmd_lex_u32;
+ return result;
}
uint8_t
-ao_match_word(__code char *word)
+ao_match_word(const char *word)
{
while (*word) {
if (ao_cmd_lex_c != *word) {
@@ -250,9 +237,9 @@ ao_match_word(__code char *word)
static void
echo(void)
{
- ao_cmd_hex();
+ uint32_t v = ao_cmd_hex();
if (ao_cmd_status == ao_cmd_success)
- ao_stdios[ao_cur_stdio].echo = ao_cmd_lex_i != 0;
+ ao_stdios[ao_cur_stdio].echo = v != 0;
}
static void
@@ -321,16 +308,16 @@ version(void)
#define NUM_CMDS 11
#endif
-static __code struct ao_cmds *__xdata (ao_cmds[NUM_CMDS]);
-static __pdata uint8_t ao_ncmds;
+static const struct ao_cmds *(ao_cmds[NUM_CMDS]);
+static uint8_t ao_ncmds;
static void
help(void)
{
- __pdata uint8_t cmds;
- __pdata uint8_t cmd;
- __code struct ao_cmds * __pdata cs;
- __code const char *h;
+ uint8_t cmds;
+ uint8_t cmd;
+ const struct ao_cmds * cs;
+ const char *h;
uint8_t e;
for (cmds = 0; cmds < ao_ncmds; cmds++) {
@@ -363,7 +350,7 @@ report(void)
}
void
-ao_cmd_register(__code struct ao_cmds *cmds)
+ao_cmd_register(const struct ao_cmds *cmds)
{
if (ao_ncmds >= NUM_CMDS)
ao_panic(AO_PANIC_CMD);
@@ -373,13 +360,13 @@ ao_cmd_register(__code struct ao_cmds *cmds)
void
ao_cmd(void)
{
- __pdata char c;
+ char c;
uint8_t cmd, cmds;
- __code struct ao_cmds * __xdata cs;
- void (*__xdata func)(void);
+ const struct ao_cmds * cs;
+ void (*func)(void);
for (;;) {
- ao_cmd_readline();
+ ao_cmd_readline("> ");
ao_cmd_lex();
ao_cmd_white();
c = ao_cmd_lex_c;
@@ -424,10 +411,10 @@ ao_loader(void)
#endif
#if HAS_TASK
-__xdata struct ao_task ao_cmd_task;
+struct ao_task ao_cmd_task;
#endif
-__code struct ao_cmds ao_base_cmds[] = {
+const struct ao_cmds ao_base_cmds[] = {
{ help, "?\0Help" },
#if HAS_TASK_INFO && HAS_TASK
{ ao_task_info, "T\0Tasks" },
diff --git a/src/kernel/ao_companion.h b/src/kernel/ao_companion.h
index 4c161455..bd702fe3 100644
--- a/src/kernel/ao_companion.h
+++ b/src/kernel/ao_companion.h
@@ -44,11 +44,11 @@ struct ao_companion_setup {
uint8_t channels;
};
-extern __pdata uint8_t ao_companion_running;
-extern __xdata uint8_t ao_companion_mutex;
-extern __xdata struct ao_companion_command ao_companion_command;
-extern __xdata struct ao_companion_setup ao_companion_setup;
-extern __xdata uint16_t ao_companion_data[AO_COMPANION_MAX_CHANNELS];
+extern uint8_t ao_companion_running;
+extern uint8_t ao_companion_mutex;
+extern struct ao_companion_command ao_companion_command;
+extern struct ao_companion_setup ao_companion_setup;
+extern uint16_t ao_companion_data[AO_COMPANION_MAX_CHANNELS];
void
ao_companion_init(void);
diff --git a/src/kernel/ao_config.c b/src/kernel/ao_config.c
index 86d4838f..596a0410 100644
--- a/src/kernel/ao_config.c
+++ b/src/kernel/ao_config.c
@@ -30,13 +30,13 @@
#include <ao_tracker.h>
#endif
-__xdata struct ao_config ao_config;
-__pdata uint8_t ao_config_loaded;
-__pdata uint8_t ao_config_dirty;
-__xdata uint8_t ao_config_mutex;
+struct ao_config ao_config;
+uint8_t ao_config_loaded;
+uint8_t ao_config_dirty;
+uint8_t ao_config_mutex;
#if HAS_FORCE_FREQ
-__xdata uint8_t ao_force_freq;
+uint8_t ao_force_freq;
#endif
#ifndef AO_CONFIG_DEFAULT_APRS_INTERVAL
@@ -100,7 +100,7 @@ ao_config_put(void)
#if HAS_RADIO
#if HAS_RADIO_FORWARD
-__xdata uint32_t ao_send_radio_setting;
+uint32_t ao_send_radio_setting;
#endif
void
@@ -135,7 +135,7 @@ _ao_config_get(void)
/* Version 0 stuff */
ao_config.main_deploy = AO_CONFIG_DEFAULT_MAIN_DEPLOY;
ao_xmemset(&ao_config.callsign, '\0', sizeof (ao_config.callsign));
- ao_xmemcpy(&ao_config.callsign, CODE_TO_XDATA(AO_CONFIG_DEFAULT_CALLSIGN),
+ ao_xmemcpy(&ao_config.callsign, AO_CONFIG_DEFAULT_CALLSIGN,
sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1);
ao_config._legacy_radio_channel = 0;
}
@@ -246,7 +246,7 @@ _ao_config_get(void)
#if HAS_RADIO_RATE
ao_config.radio_rate = AO_CONFIG_DEFAULT_RADIO_RATE;
#endif
- ao_xmemcpy(&ao_config.callsign, CODE_TO_XDATA(AO_CONFIG_DEFAULT_CALLSIGN),
+ ao_xmemcpy(&ao_config.callsign, AO_CONFIG_DEFAULT_CALLSIGN,
sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1);
}
#endif
@@ -283,10 +283,10 @@ ao_config_callsign_show(void)
}
void
-ao_config_callsign_set(void) __reentrant
+ao_config_callsign_set(void)
{
uint8_t c;
- static __xdata char callsign[AO_MAX_CALLSIGN + 1];
+ static char callsign[AO_MAX_CALLSIGN + 1];
ao_xmemset(callsign, '\0', sizeof callsign);
ao_cmd_white();
@@ -309,20 +309,20 @@ ao_config_callsign_set(void) __reentrant
#if HAS_RADIO
void
-ao_config_frequency_show(void) __reentrant
+ao_config_frequency_show(void)
{
printf("Frequency: %ld\n",
ao_config.frequency);
}
void
-ao_config_frequency_set(void) __reentrant
+ao_config_frequency_set(void)
{
- ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.frequency = ao_cmd_lex_u32;
+ ao_config.frequency = r;
ao_config_set_radio();
_ao_config_edit_finish();
#if HAS_RADIO_RECV
@@ -334,14 +334,14 @@ ao_config_frequency_set(void) __reentrant
#if HAS_RADIO_FORWARD
void
-ao_config_send_frequency_show(void) __reentrant
+ao_config_send_frequency_show(void)
{
printf("Send frequency: %ld\n",
ao_config.send_frequency);
}
void
-ao_config_send_frequency_set(void) __reentrant
+ao_config_send_frequency_set(void)
{
ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
@@ -360,26 +360,26 @@ ao_config_send_frequency_set(void) __reentrant
#if HAS_FLIGHT
void
-ao_config_main_deploy_show(void) __reentrant
+ao_config_main_deploy_show(void)
{
printf("Main deploy: %d meters\n",
ao_config.main_deploy);
}
void
-ao_config_main_deploy_set(void) __reentrant
+ao_config_main_deploy_set(void)
{
- ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.main_deploy = ao_cmd_lex_i;
+ ao_config.main_deploy = r;
_ao_config_edit_finish();
}
#if HAS_ACCEL
void
-ao_config_accel_calibrate_show(void) __reentrant
+ao_config_accel_calibrate_show(void)
{
printf("Accel cal +1g: %d -1g: %d\n",
ao_config.accel_plus_g, ao_config.accel_minus_g);
@@ -401,7 +401,7 @@ static int16_t accel_cal_through;
#endif
static int16_t
-ao_config_accel_calibrate_auto(char *orientation) __reentrant
+ao_config_accel_calibrate_auto(char *orientation)
{
uint16_t i;
int32_t accel_total;
@@ -421,7 +421,7 @@ ao_config_accel_calibrate_auto(char *orientation) __reentrant
accel_total = 0;
cal_data_ring = ao_sample_data;
while (i) {
- ao_sleep(DATA_TO_XDATA(&ao_sample_data));
+ ao_sleep(&ao_sample_data);
while (i && cal_data_ring != ao_sample_data) {
accel_total += (int32_t) ao_data_accel(&ao_data_ring[cal_data_ring]);
#if HAS_GYRO
@@ -442,19 +442,20 @@ ao_config_accel_calibrate_auto(char *orientation) __reentrant
}
void
-ao_config_accel_calibrate_set(void) __reentrant
+ao_config_accel_calibrate_set(void)
{
int16_t up, down;
+ uint16_t r;
#if HAS_GYRO
int16_t accel_along_up = 0, accel_along_down = 0;
int16_t accel_across_up = 0, accel_across_down = 0;
int16_t accel_through_up = 0, accel_through_down = 0;
#endif
- ao_cmd_decimal();
+ r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- if (ao_cmd_lex_i == 0) {
+ if (r == 0) {
up = ao_config_accel_calibrate_auto("up");
#if HAS_GYRO
accel_along_up = accel_cal_along;
@@ -468,11 +469,11 @@ ao_config_accel_calibrate_set(void) __reentrant
accel_through_down = accel_cal_through;
#endif
} else {
- up = ao_cmd_lex_i;
- ao_cmd_decimal();
+ up = r;
+ r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- down = ao_cmd_lex_i;
+ down = r;
}
if (up >= down) {
printf("Invalid accel: up (%d) down (%d)\n",
@@ -483,7 +484,7 @@ ao_config_accel_calibrate_set(void) __reentrant
ao_config.accel_plus_g = up;
ao_config.accel_minus_g = down;
#if HAS_GYRO
- if (ao_cmd_lex_i == 0) {
+ if (r == 0) {
ao_config.accel_zero_along = (accel_along_up + accel_along_down) / 2;
ao_config.accel_zero_across = (accel_across_up + accel_across_down) / 2;
ao_config.accel_zero_through = (accel_through_up + accel_through_down) / 2;
@@ -494,38 +495,38 @@ ao_config_accel_calibrate_set(void) __reentrant
#endif /* HAS_ACCEL */
void
-ao_config_apogee_delay_show(void) __reentrant
+ao_config_apogee_delay_show(void)
{
printf("Apogee delay: %d seconds\n",
ao_config.apogee_delay);
}
void
-ao_config_apogee_delay_set(void) __reentrant
+ao_config_apogee_delay_set(void)
{
- ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.apogee_delay = ao_cmd_lex_i;
+ ao_config.apogee_delay = r;
_ao_config_edit_finish();
}
void
-ao_config_apogee_lockout_show(void) __reentrant
+ao_config_apogee_lockout_show(void)
{
printf ("Apogee lockout: %d seconds\n",
ao_config.apogee_lockout);
}
void
-ao_config_apogee_lockout_set(void) __reentrant
+ao_config_apogee_lockout_set(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.apogee_lockout = ao_cmd_lex_i;
+ ao_config.apogee_lockout = r;
_ao_config_edit_finish();
}
@@ -533,19 +534,19 @@ ao_config_apogee_lockout_set(void) __reentrant
#if HAS_RADIO
void
-ao_config_radio_cal_show(void) __reentrant
+ao_config_radio_cal_show(void)
{
printf("Radio cal: %ld\n", ao_config.radio_cal);
}
void
-ao_config_radio_cal_set(void) __reentrant
+ao_config_radio_cal_set(void)
{
- ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.radio_cal = ao_cmd_lex_u32;
+ ao_config.radio_cal = r;
ao_config_set_radio();
_ao_config_edit_finish();
}
@@ -558,23 +559,23 @@ ao_config_radio_cal_set(void) __reentrant
#endif
void
-ao_config_radio_rate_show(void) __reentrant
+ao_config_radio_rate_show(void)
{
printf("Telemetry rate: %d\n", ao_config.radio_rate);
}
void
-ao_config_radio_rate_set(void) __reentrant
+ao_config_radio_rate_set(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- if (AO_RADIO_RATE_MAX < ao_cmd_lex_i) {
+ if (AO_RADIO_RATE_MAX < r) {
ao_cmd_status = ao_cmd_lex_error;
return;
}
_ao_config_edit_start();
- ao_config.radio_rate = ao_cmd_lex_i;
+ ao_config.radio_rate = r;
_ao_config_edit_finish();
#if HAS_TELEMETRY
ao_telemetry_reset_interval();
@@ -588,7 +589,7 @@ ao_config_radio_rate_set(void) __reentrant
#if HAS_LOG
void
-ao_config_log_show(void) __reentrant
+ao_config_log_show(void)
{
printf("Max flight log: %d kB\n", (int16_t) (ao_config.flight_log_max >> 10));
#if FLIGHT_LOG_APPEND
@@ -611,26 +612,27 @@ ao_config_log_fix_append(void)
#endif
void
-ao_config_log_set(void) __reentrant
+ao_config_log_set(void)
{
#if FLIGHT_LOG_APPEND
printf("Flight log fixed size %d kB\n", ao_storage_log_max >> 10);
#else
uint16_t block = (uint16_t) (ao_storage_block >> 10);
uint16_t log_max = (uint16_t) (ao_storage_log_max >> 10);
+ uint32_t r;
- ao_cmd_decimal();
+ r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
if (ao_log_present())
printf("Storage must be empty before changing log size\n");
- else if (block > 1024 && (ao_cmd_lex_i & (block - 1)))
+ else if (block > 1024 && (r & (block - 1)))
printf("Flight log size must be multiple of %d kB\n", block);
- else if (ao_cmd_lex_i > log_max)
+ else if (r > log_max)
printf("Flight log max %d kB\n", log_max);
else {
_ao_config_edit_start();
- ao_config.flight_log_max = (uint32_t) ao_cmd_lex_i << 10;
+ ao_config.flight_log_max = r << 10;
_ao_config_edit_finish();
}
#endif
@@ -639,26 +641,26 @@ ao_config_log_set(void) __reentrant
#if HAS_IGNITE
void
-ao_config_ignite_mode_show(void) __reentrant
+ao_config_ignite_mode_show(void)
{
printf("Ignite mode: %d\n", ao_config.ignite_mode);
}
void
-ao_config_ignite_mode_set(void) __reentrant
+ao_config_ignite_mode_set(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.ignite_mode = ao_cmd_lex_i;
+ ao_config.ignite_mode = r;
_ao_config_edit_finish();
}
#endif
#if HAS_ACCEL
void
-ao_config_pad_orientation_show(void) __reentrant
+ao_config_pad_orientation_show(void)
{
printf("Pad orientation: %d\n", ao_config.pad_orientation);
}
@@ -668,39 +670,38 @@ ao_config_pad_orientation_show(void) __reentrant
#endif
void
-ao_config_pad_orientation_set(void) __reentrant
+ao_config_pad_orientation_set(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal() & 1;
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_cmd_lex_i &= 1;
- if (ao_config.pad_orientation != ao_cmd_lex_i) {
+ if (ao_config.pad_orientation != r) {
int16_t t;
t = ao_config.accel_plus_g;
ao_config.accel_plus_g = AO_ACCEL_INVERT - ao_config.accel_minus_g;
ao_config.accel_minus_g = AO_ACCEL_INVERT - t;
}
- ao_config.pad_orientation = ao_cmd_lex_i;
+ ao_config.pad_orientation = r;
_ao_config_edit_finish();
}
#endif
#if HAS_RADIO
void
-ao_config_radio_enable_show(void) __reentrant
+ao_config_radio_enable_show(void)
{
printf("Radio enable: %d\n", ao_config.radio_enable);
}
void
-ao_config_radio_enable_set(void) __reentrant
+ao_config_radio_enable_set(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.radio_enable = ao_cmd_lex_i;
+ ao_config.radio_enable = r;
_ao_config_edit_finish();
#if HAS_TELEMETRY && HAS_RADIO_RATE
ao_telemetry_reset_interval();
@@ -710,10 +711,10 @@ ao_config_radio_enable_set(void) __reentrant
#if HAS_AES
-__xdata uint8_t ao_config_aes_seq = 1;
+uint8_t ao_config_aes_seq = 1;
void
-ao_config_key_show(void) __reentrant
+ao_config_key_show(void)
{
uint8_t i;
printf("AES key: ");
@@ -723,16 +724,16 @@ ao_config_key_show(void) __reentrant
}
void
-ao_config_key_set(void) __reentrant
+ao_config_key_set(void)
{
uint8_t i;
_ao_config_edit_start();
for (i = 0; i < AO_AES_LEN; i++) {
- ao_cmd_hexbyte();
+ uint8_t b = ao_cmd_hexbyte();
if (ao_cmd_status != ao_cmd_success)
break;
- ao_config.aes_key[i] = ao_cmd_lex_i;
+ ao_config.aes_key[i] = b;
}
++ao_config_aes_seq;
_ao_config_edit_finish();
@@ -750,11 +751,11 @@ ao_config_aprs_show(void)
void
ao_config_aprs_set(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.aprs_interval = ao_cmd_lex_i;
+ ao_config.aprs_interval = r;
_ao_config_edit_finish();
ao_telemetry_reset_interval();
}
@@ -772,11 +773,11 @@ ao_config_radio_amp_show(void)
void
ao_config_radio_amp_set(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.radio_amp = ao_cmd_lex_i;
+ ao_config.radio_amp = r;
_ao_config_edit_finish();
}
@@ -793,11 +794,11 @@ ao_config_radio_power_show(void)
void
ao_config_radio_power_set(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.radio_power = ao_cmd_lex_i;
+ ao_config.radio_power = r;
_ao_config_edit_finish();
}
@@ -813,11 +814,11 @@ ao_config_beep_show(void)
void
ao_config_beep_set(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.mid_beep = ao_cmd_lex_i;
+ ao_config.mid_beep = r;
_ao_config_edit_finish();
}
#endif
@@ -835,14 +836,12 @@ void
ao_config_tracker_set(void)
{
uint16_t m, i;
- ao_cmd_decimal();
+ m = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- m = ao_cmd_lex_i;
- ao_cmd_decimal();
+ i = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- i = ao_cmd_lex_i;
_ao_config_edit_start();
ao_config.tracker_motion = m;
ao_config.tracker_interval = i;
@@ -863,11 +862,11 @@ ao_config_pyro_time_show(void)
void
ao_config_pyro_time_set(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.pyro_time = ao_cmd_lex_i;
+ ao_config.pyro_time = r;
_ao_config_edit_finish();
}
#endif
@@ -883,26 +882,26 @@ ao_config_aprs_ssid_show(void)
void
ao_config_aprs_ssid_set(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- if (15 < ao_cmd_lex_i) {
+ if (15 < r) {
ao_cmd_status = ao_cmd_lex_error;
return;
}
_ao_config_edit_start();
- ao_config.aprs_ssid = ao_cmd_lex_i;
+ ao_config.aprs_ssid = r;
_ao_config_edit_finish();
}
void
ao_config_aprs_format_set(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.aprs_format = ao_cmd_lex_i != 0;
+ ao_config.aprs_format = r != 0;
_ao_config_edit_finish();
}
@@ -923,11 +922,11 @@ ao_config_pad_box_show(void)
void
ao_config_pad_box_set(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.pad_box = ao_cmd_lex_i;
+ ao_config.pad_box = r;
_ao_config_edit_finish();
}
@@ -940,33 +939,33 @@ ao_config_pad_idle_show(void)
void
ao_config_pad_idle_set(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.pad_idle = ao_cmd_lex_i;
+ ao_config.pad_idle = r;
_ao_config_edit_finish();
}
#endif
struct ao_config_var {
- __code char *str;
- void (*set)(void) __reentrant;
- void (*show)(void) __reentrant;
+ const char *str;
+ void (*set)(void);
+ void (*show)(void);
};
static void
-ao_config_help(void) __reentrant;
+ao_config_help(void);
static void
-ao_config_show(void) __reentrant;
+ao_config_show(void);
#if HAS_EEPROM
static void
-ao_config_save(void) __reentrant;
+ao_config_save(void);
#endif
-__code struct ao_config_var ao_config_vars[] = {
+const struct ao_config_var ao_config_vars[] = {
#if HAS_FLIGHT
{ "m <meters>\0Main deploy (m)",
ao_config_main_deploy_set, ao_config_main_deploy_show, },
@@ -1078,7 +1077,7 @@ ao_config_set(void)
}
static void
-ao_config_help(void) __reentrant
+ao_config_help(void)
{
uint8_t cmd;
for (cmd = 0; ao_config_vars[cmd].str != NULL; cmd++)
@@ -1089,7 +1088,7 @@ ao_config_help(void) __reentrant
}
static void
-ao_config_show(void) __reentrant
+ao_config_show(void)
{
uint8_t cmd;
ao_config_get();
@@ -1105,7 +1104,7 @@ ao_config_show(void) __reentrant
#if HAS_EEPROM
static void
-ao_config_save(void) __reentrant
+ao_config_save(void)
{
uint8_t saved = 0;
ao_mutex_get(&ao_config_mutex);
@@ -1122,7 +1121,7 @@ ao_config_save(void) __reentrant
}
#endif
-__code struct ao_cmds ao_config_cmds[] = {
+const struct ao_cmds ao_config_cmds[] = {
{ ao_config_set, "c <var> <value>\0Set config (? for help, s to show)" },
{ 0, NULL },
};
diff --git a/src/kernel/ao_config.h b/src/kernel/ao_config.h
index f730c73c..41aafcca 100644
--- a/src/kernel/ao_config.h
+++ b/src/kernel/ao_config.h
@@ -62,7 +62,7 @@
#define AO_AES_LEN 16
-extern __xdata uint8_t ao_config_aes_seq;
+extern uint8_t ao_config_aes_seq;
struct ao_config {
uint8_t major;
@@ -130,7 +130,7 @@ struct ao_config {
#define AO_CONFIG_DEFAULT_APRS_FORMAT AO_APRS_FORMAT_COMPRESSED
#if HAS_RADIO_FORWARD
-extern __xdata uint32_t ao_send_radio_setting;
+extern uint32_t ao_send_radio_setting;
#endif
#define AO_IGNITE_MODE_DUAL 0
@@ -151,8 +151,8 @@ extern __xdata uint32_t ao_send_radio_setting;
/* Make sure AO_CONFIG_MAX_SIZE is big enough */
typedef uint8_t config_check_space[(int) (AO_CONFIG_MAX_SIZE - sizeof (struct ao_config))];
-extern __xdata struct ao_config ao_config;
-extern __pdata uint8_t ao_config_loaded;
+extern struct ao_config ao_config;
+extern uint8_t ao_config_loaded;
void
_ao_config_edit_start(void);
diff --git a/src/kernel/ao_convert.c b/src/kernel/ao_convert.c
index 1cd62345..f3e523ec 100644
--- a/src/kernel/ao_convert.c
+++ b/src/kernel/ao_convert.c
@@ -30,7 +30,7 @@ static const ao_v_t altitude_table[] = {
#define ALT_FRAC_MASK (ALT_FRAC_SCALE - 1)
ao_v_t
-ao_pres_to_altitude(int16_t pres) __reentrant
+ao_pres_to_altitude(int16_t pres)
{
uint8_t o;
int16_t part;
@@ -46,7 +46,7 @@ ao_pres_to_altitude(int16_t pres) __reentrant
#if AO_NEED_ALTITUDE_TO_PRES
int16_t
-ao_altitude_to_pres(ao_v_t alt) __reentrant
+ao_altitude_to_pres(ao_v_t alt)
{
ao_v_t span, sub_span;
uint8_t l, h, m;
@@ -74,7 +74,7 @@ ao_altitude_to_pres(ao_v_t alt) __reentrant
#if 0
int16_t
-ao_temp_to_dC(int16_t temp) __reentrant
+ao_temp_to_dC(int16_t temp)
{
int16_t ret;
diff --git a/src/kernel/ao_data.c b/src/kernel/ao_data.c
index 35d42b8f..536ffa2b 100644
--- a/src/kernel/ao_data.c
+++ b/src/kernel/ao_data.c
@@ -19,13 +19,13 @@
#include <ao.h>
#include <ao_data.h>
-volatile __xdata struct ao_data ao_data_ring[AO_DATA_RING];
-volatile __data uint8_t ao_data_head;
-volatile __data uint8_t ao_data_present;
+volatile struct ao_data ao_data_ring[AO_DATA_RING];
+volatile uint8_t ao_data_head;
+volatile uint8_t ao_data_present;
#ifndef ao_data_count
void
-ao_data_get(__xdata struct ao_data *packet)
+ao_data_get(struct ao_data *packet)
{
#if HAS_FLIGHT
uint8_t i = ao_data_ring_prev(ao_sample_data);
diff --git a/src/kernel/ao_data.h b/src/kernel/ao_data.h
index 88d0e916..3918f4e0 100644
--- a/src/kernel/ao_data.h
+++ b/src/kernel/ao_data.h
@@ -62,9 +62,16 @@
#define AO_DATA_MMA655X 0
#endif
+#if HAS_ADXL375
+#include <ao_adxl375.h>
+#define AO_DATA_ADXL375 (1 << 4)
+#else
+#define AO_DATA_ADXL375 0
+#endif
+
#ifdef AO_DATA_RING
-#define AO_DATA_ALL (AO_DATA_ADC|AO_DATA_MS5607|AO_DATA_MPU6000|AO_DATA_HMC5883|AO_DATA_MMA655X|AO_DATA_MPU9250)
+#define AO_DATA_ALL (AO_DATA_ADC|AO_DATA_MS5607|AO_DATA_MPU6000|AO_DATA_HMC5883|AO_DATA_MMA655X|AO_DATA_MPU9250|AO_DATA_ADXL375)
struct ao_data {
uint16_t tick;
@@ -90,6 +97,9 @@ struct ao_data {
#if HAS_MMA655X
uint16_t mma655x;
#endif
+#if HAS_ADXL375
+ struct ao_adxl375_sample adxl375;
+#endif
};
#define ao_data_ring_next(n) (((n) + 1) & (AO_DATA_RING - 1))
@@ -97,12 +107,12 @@ struct ao_data {
/* Get a copy of the last complete sample set */
void
-ao_data_get(__xdata struct ao_data *packet);
+ao_data_get(struct ao_data *packet);
-extern volatile __xdata struct ao_data ao_data_ring[AO_DATA_RING];
-extern volatile __data uint8_t ao_data_head;
-extern volatile __data uint8_t ao_data_present;
-extern volatile __data uint8_t ao_data_count;
+extern volatile struct ao_data ao_data_ring[AO_DATA_RING];
+extern volatile uint8_t ao_data_head;
+extern volatile uint8_t ao_data_present;
+extern volatile uint8_t ao_data_count;
/*
* Mark a section of data as ready, check for data complete
@@ -113,9 +123,7 @@ extern volatile __data uint8_t ao_data_count;
* Wait until it is time to write a sensor sample; this is
* signaled by the timer tick
*/
-#define AO_DATA_WAIT() do { \
- ao_sleep(DATA_TO_XDATA ((void *) &ao_data_count)); \
- } while (0)
+#define AO_DATA_WAIT() ao_sleep((void *) &ao_data_count)
#endif /* AO_DATA_RING */
@@ -295,6 +303,27 @@ typedef int16_t accel_t;
#endif
+#if !HAS_ACCEL && HAS_ADXL375
+
+#define HAS_ACCEL 1
+
+typedef int16_t accel_t;
+
+#ifndef AO_ADXL375_INVERT
+#error AO_ADXL375_INVERT not defined
+#endif
+
+#define ao_data_accel(packet) ((packet)->adxl375.AO_ADXL375_AXIS)
+#if AO_ADXL375_INVERT
+#define ao_data_accel_cook(packet) (-ao_data_accel(packet))
+#else
+#define ao_data_accel_cook(packet) ao_data_accel(packet)
+#endif
+#define ao_data_set_accel(packet, accel) (ao_data_accel(packet) = (accel))
+#define ao_data_accel_invert(accel) (-(accel))
+
+#endif /* HAS_ADXL375 */
+
#if !HAS_ACCEL && HAS_MPU6000
#define HAS_ACCEL 1
@@ -402,4 +431,35 @@ typedef int16_t ao_mag_t; /* in raw sample units */
#endif
+#ifdef AO_DATA_RING
+
+static inline void
+ao_data_fill(int head) {
+ if (ao_data_present == AO_DATA_ALL) {
+#if HAS_MS5607
+ ao_data_ring[head].ms5607_raw = ao_ms5607_current;
+#endif
+#if HAS_MMA655X
+ ao_data_ring[head].mma655x = ao_mma655x_current;
+#endif
+#if HAS_HMC5883
+ ao_data_ring[head].hmc5883 = ao_hmc5883_current;
+#endif
+#if HAS_MPU6000
+ ao_data_ring[head].mpu6000 = ao_mpu6000_current;
+#endif
+#if HAS_MPU9250
+ ao_data_ring[head].mpu9250 = ao_mpu9250_current;
+#endif
+#if HAS_ADXL375
+ ao_data_ring[head].adxl375 = ao_adxl375_current;
+#endif
+ ao_data_ring[head].tick = ao_tick_count;
+ ao_data_head = ao_data_ring_next(head);
+ ao_wakeup((void *) &ao_data_head);
+ }
+}
+
+#endif
+
#endif /* _AO_DATA_H_ */
diff --git a/src/kernel/ao_ee_fake.c b/src/kernel/ao_ee_fake.c
index 84c13000..cef0a438 100644
--- a/src/kernel/ao_ee_fake.c
+++ b/src/kernel/ao_ee_fake.c
@@ -23,7 +23,7 @@
* wants to call these functions
*/
uint8_t
-ao_ee_write_config(uint8_t *buf, uint16_t len) __reentrant
+ao_ee_write_config(uint8_t *buf, uint16_t len)
{
(void) buf;
(void) len;
@@ -31,7 +31,7 @@ ao_ee_write_config(uint8_t *buf, uint16_t len) __reentrant
}
uint8_t
-ao_ee_read_config(uint8_t *buf, uint16_t len) __reentrant
+ao_ee_read_config(uint8_t *buf, uint16_t len)
{
ao_xmemset(buf, '\0', len);
return 1;
diff --git a/src/kernel/ao_eeprom.h b/src/kernel/ao_eeprom.h
index bd8b6725..f258c48c 100644
--- a/src/kernel/ao_eeprom.h
+++ b/src/kernel/ao_eeprom.h
@@ -26,13 +26,13 @@ extern const ao_pos_t ao_eeprom_total;
*/
uint8_t
-ao_eeprom_write(ao_pos_t pos32, __xdata void *v, uint16_t len);
+ao_eeprom_write(ao_pos_t pos32, void *v, uint16_t len);
/*
* Read from eeprom
*/
uint8_t
-ao_eeprom_read(ao_pos_t pos, __xdata void *v, uint16_t len);
+ao_eeprom_read(ao_pos_t pos, void *v, uint16_t len);
/*
* Initialize eeprom
diff --git a/src/kernel/ao_fake_flight.c b/src/kernel/ao_fake_flight.c
index 5880cf2b..ec8691e9 100644
--- a/src/kernel/ao_fake_flight.c
+++ b/src/kernel/ao_fake_flight.c
@@ -54,7 +54,7 @@ ao_fake_data_read(void)
uint8_t *d = (void *) &ao_fake_next;
if (getchar() == 0)
- return FALSE;
+ return false;
for (i = 0; i < sizeof (struct ao_data); i++)
*d++ = getchar();
if (!ao_fake_has_offset) {
@@ -64,7 +64,7 @@ ao_fake_data_read(void)
} else
ao_fake_next.tick += ao_fake_tick_offset;
ao_fake_has_next = 1;
- return TRUE;
+ return true;
}
static void
@@ -118,10 +118,10 @@ ao_fake_calib_read(void)
) {
printf ("Calibration data major version mismatch %d.%d <= %d.%d\n",
ao_calib.major, ao_calib.minor, AO_FAKE_CALIB_MAJOR, AO_FAKE_CALIB_MINOR);
- return FALSE;
+ return false;
}
ao_fake_calib_set(&ao_calib);
- return TRUE;
+ return true;
}
static void
@@ -133,14 +133,12 @@ ao_fake_flight(void)
enum ao_flight_state my_state = ao_flight_invalid;
int i;
- ao_cmd_hex();
+ calib_size = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
- calib_size = ao_cmd_lex_i;
- ao_cmd_hex();
+ data_size = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
- data_size = ao_cmd_lex_i;
if ((unsigned) calib_size != sizeof (struct ao_fake_calib)) {
printf ("calib size %d larger than actual size %d\n",
calib_size, sizeof (struct ao_fake_calib));
diff --git a/src/kernel/ao_flight.c b/src/kernel/ao_flight.c
index c2700d20..f72efa06 100644
--- a/src/kernel/ao_flight.c
+++ b/src/kernel/ao_flight.c
@@ -47,28 +47,28 @@
/* Main flight thread. */
-__pdata enum ao_flight_state ao_flight_state; /* current flight state */
-__pdata uint16_t ao_boost_tick; /* time of most recent boost detect */
-__pdata uint16_t ao_launch_tick; /* time of first boost detect */
-__pdata uint16_t ao_motor_number; /* number of motors burned so far */
+enum ao_flight_state ao_flight_state; /* current flight state */
+uint16_t ao_boost_tick; /* time of most recent boost detect */
+uint16_t ao_launch_tick; /* time of first boost detect */
+uint16_t ao_motor_number; /* number of motors burned so far */
#if HAS_SENSOR_ERRORS
/* Any sensor can set this to mark the flight computer as 'broken' */
-__xdata uint8_t ao_sensor_errors;
+uint8_t ao_sensor_errors;
#endif
/*
* track min/max data over a long interval to detect
* resting
*/
-static __data uint16_t ao_interval_end;
-static __data ao_v_t ao_interval_min_height;
-static __data ao_v_t ao_interval_max_height;
+static uint16_t ao_interval_end;
+static ao_v_t ao_interval_min_height;
+static ao_v_t ao_interval_max_height;
#if HAS_ACCEL
-static __data ao_v_t ao_coast_avg_accel;
+static ao_v_t ao_coast_avg_accel;
#endif
-__pdata uint8_t ao_flight_force_idle;
+uint8_t ao_flight_force_idle;
/* We also have a clock, which can be used to sanity check things in
* case of other failures
@@ -175,7 +175,7 @@ ao_flight(void)
#endif
}
/* wakeup threads due to state change */
- ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
+ ao_wakeup(&ao_flight_state);
break;
case ao_flight_pad:
@@ -219,7 +219,7 @@ ao_flight(void)
ao_wakeup(&ao_gps_new);
#endif
- ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
+ ao_wakeup(&ao_flight_state);
}
break;
case ao_flight_boost:
@@ -244,7 +244,7 @@ ao_flight(void)
ao_flight_state = ao_flight_coast;
#endif
++ao_motor_number;
- ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
+ ao_wakeup(&ao_flight_state);
}
break;
#if HAS_ACCEL
@@ -257,7 +257,7 @@ ao_flight(void)
if (ao_speed < AO_MS_TO_SPEED(AO_MAX_BARO_SPEED))
{
ao_flight_state = ao_flight_coast;
- ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
+ ao_wakeup(&ao_flight_state);
} else
goto check_re_boost;
break;
@@ -306,7 +306,7 @@ ao_flight(void)
/* and enter drogue state */
ao_flight_state = ao_flight_drogue;
- ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
+ ao_wakeup(&ao_flight_state);
}
#if HAS_ACCEL
else {
@@ -315,7 +315,7 @@ ao_flight(void)
if (ao_coast_avg_accel > AO_MSS_TO_ACCEL(20)) {
ao_boost_tick = ao_sample_tick;
ao_flight_state = ao_flight_boost;
- ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
+ ao_wakeup(&ao_flight_state);
}
}
#endif
@@ -352,7 +352,7 @@ ao_flight(void)
ao_interval_min_height = ao_interval_max_height = ao_avg_height;
ao_flight_state = ao_flight_main;
- ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
+ ao_wakeup(&ao_flight_state);
}
break;
@@ -379,7 +379,7 @@ ao_flight(void)
ao_timer_set_adc_interval(0);
#endif
- ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
+ ao_wakeup(&ao_flight_state);
}
ao_interval_min_height = ao_interval_max_height = ao_avg_height;
ao_interval_end = ao_sample_tick + AO_INTERVAL_TICKS;
@@ -463,7 +463,7 @@ ao_orient_test_select(void)
ao_orient_test = !ao_orient_test;
}
-__code struct ao_cmds ao_flight_cmds[] = {
+const struct ao_cmds ao_flight_cmds[] = {
{ ao_flight_dump, "F\0Dump flight status" },
{ ao_gyro_test, "G\0Test gyro code" },
{ ao_orient_test_select,"O\0Test orientation code" },
@@ -471,7 +471,7 @@ __code struct ao_cmds ao_flight_cmds[] = {
};
#endif
-static __xdata struct ao_task flight_task;
+static struct ao_task flight_task;
void
ao_flight_init(void)
diff --git a/src/kernel/ao_flight.h b/src/kernel/ao_flight.h
index 005c7e84..af6b0c55 100644
--- a/src/kernel/ao_flight.h
+++ b/src/kernel/ao_flight.h
@@ -38,21 +38,21 @@ enum ao_flight_state {
ao_flight_test = 10
};
-extern __pdata enum ao_flight_state ao_flight_state;
-extern __pdata uint16_t ao_boost_tick;
-extern __pdata uint16_t ao_launch_tick;
-extern __pdata uint16_t ao_motor_number;
+extern enum ao_flight_state ao_flight_state;
+extern uint16_t ao_boost_tick;
+extern uint16_t ao_launch_tick;
+extern uint16_t ao_motor_number;
#if HAS_IMU || HAS_MMA655X
#define HAS_SENSOR_ERRORS 1
#endif
#if HAS_SENSOR_ERRORS
-extern __xdata uint8_t ao_sensor_errors;
+extern uint8_t ao_sensor_errors;
#endif
-extern __pdata uint16_t ao_launch_time;
-extern __pdata uint8_t ao_flight_force_idle;
+extern uint16_t ao_launch_time;
+extern uint8_t ao_flight_force_idle;
/* Flight thread */
void
diff --git a/src/kernel/ao_flight_nano.c b/src/kernel/ao_flight_nano.c
index d849dc64..96d47fac 100644
--- a/src/kernel/ao_flight_nano.c
+++ b/src/kernel/ao_flight_nano.c
@@ -20,18 +20,18 @@
/* Main flight thread. */
-__pdata enum ao_flight_state ao_flight_state; /* current flight state */
-__pdata uint16_t ao_launch_tick; /* time of launch detect */
+enum ao_flight_state ao_flight_state; /* current flight state */
+uint16_t ao_launch_tick; /* time of launch detect */
/*
* track min/max data over a long interval to detect
* resting
*/
-__pdata uint16_t ao_interval_end;
-__pdata alt_t ao_interval_min_height;
-__pdata alt_t ao_interval_max_height;
+uint16_t ao_interval_end;
+alt_t ao_interval_min_height;
+alt_t ao_interval_max_height;
-__pdata uint8_t ao_flight_force_idle;
+uint8_t ao_flight_force_idle;
/* Landing is detected by getting constant readings from both pressure and accelerometer
* for a fairly long time (AO_INTERVAL_TICKS)
@@ -70,7 +70,7 @@ ao_flight_nano(void)
ao_led_off(AO_LED_RED);
/* wakeup threads due to state change */
- ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
+ ao_wakeup(&ao_flight_state);
break;
case ao_flight_pad:
if (ao_height> AO_M_TO_HEIGHT(20)) {
@@ -80,7 +80,7 @@ ao_flight_nano(void)
/* start logging data */
ao_log_start();
- ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
+ ao_wakeup(&ao_flight_state);
}
break;
case ao_flight_drogue:
@@ -101,7 +101,7 @@ ao_flight_nano(void)
/* turn off the ADC capture */
ao_timer_set_adc_interval(0);
- ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
+ ao_wakeup(&ao_flight_state);
}
ao_interval_min_height = ao_interval_max_height = ao_height;
ao_interval_end = ao_sample_tick + AO_INTERVAL_TICKS;
@@ -111,7 +111,7 @@ ao_flight_nano(void)
}
}
-static __xdata struct ao_task flight_task;
+static struct ao_task flight_task;
void
ao_flight_nano_init(void)
diff --git a/src/kernel/ao_forward.c b/src/kernel/ao_forward.c
index 721b52d0..6f664b60 100644
--- a/src/kernel/ao_forward.c
+++ b/src/kernel/ao_forward.c
@@ -23,11 +23,11 @@ static void
ao_monitor_forward(void)
{
uint32_t recv_radio_setting;
- static __xdata struct ao_telemetry_all_recv packet;
+ static struct ao_telemetry_all_recv packet;
for (;;) {
while (ao_monitoring)
- ao_sleep(DATA_TO_XDATA(&ao_monitoring));
+ ao_sleep(&ao_monitoring);
if (!ao_radio_recv(&packet, sizeof(packet), 0))
continue;
@@ -40,10 +40,10 @@ ao_monitor_forward(void)
}
}
-static __xdata struct ao_task ao_monitor_forward_task;
+static struct ao_task ao_monitor_forward_task;
void
-ao_monitor_forward_init(void) __reentrant
+ao_monitor_forward_init(void)
{
ao_add_task(&ao_monitor_forward_task, ao_monitor_forward, "monitor_forward");
}
diff --git a/src/kernel/ao_forward.h b/src/kernel/ao_forward.h
index 2fe28f66..5b21bf3c 100644
--- a/src/kernel/ao_forward.h
+++ b/src/kernel/ao_forward.h
@@ -20,6 +20,6 @@
#define _AO_FORWARD_H_
void
-ao_monitor_forward_init(void) __reentrant;
+ao_monitor_forward_init(void);
#endif /* _AO_FORWARD_H_ */
diff --git a/src/kernel/ao_freq.c b/src/kernel/ao_freq.c
index 6478dae2..81640ce8 100644
--- a/src/kernel/ao_freq.c
+++ b/src/kernel/ao_freq.c
@@ -26,11 +26,11 @@
* frequency, and updating the radio setting along the way
*/
-int32_t ao_freq_to_set(int32_t freq, int32_t cal) __reentrant
+int32_t ao_freq_to_set(int32_t freq, int32_t cal)
{
- static __pdata int32_t set;
- static __pdata uint8_t neg;
- static __pdata int32_t error;
+ static int32_t set;
+ static uint8_t neg;
+ static int32_t error;
set = 0;
neg = 0;
diff --git a/src/kernel/ao_gps_print.c b/src/kernel/ao_gps_print.c
index b1183bad..6dfd1bdd 100644
--- a/src/kernel/ao_gps_print.c
+++ b/src/kernel/ao_gps_print.c
@@ -26,7 +26,7 @@
#endif
void
-ao_gps_print(__xdata struct ao_gps_orig *gps_data) __reentrant
+ao_gps_print(struct ao_gps_orig *gps_data)
{
char state;
@@ -82,10 +82,10 @@ ao_gps_print(__xdata struct ao_gps_orig *gps_data) __reentrant
}
void
-ao_gps_tracking_print(__xdata struct ao_gps_tracking_orig *gps_tracking_data) __reentrant
+ao_gps_tracking_print(struct ao_gps_tracking_orig *gps_tracking_data)
{
uint8_t c, n, v;
- __xdata struct ao_gps_sat_orig *sat;
+ struct ao_gps_sat_orig *sat;
n = gps_tracking_data->channels;
if (n == 0)
diff --git a/src/kernel/ao_gps_report.c b/src/kernel/ao_gps_report.c
index 75c2f367..0ef9a725 100644
--- a/src/kernel/ao_gps_report.c
+++ b/src/kernel/ao_gps_report.c
@@ -21,9 +21,9 @@
void
ao_gps_report(void)
{
- static __xdata struct ao_log_record gps_log;
- static __xdata struct ao_telemetry_location gps_data;
- static __xdata struct ao_telemetry_satellite gps_tracking_data;
+ static struct ao_log_record gps_log;
+ static struct ao_telemetry_location gps_data;
+ static struct ao_telemetry_satellite gps_tracking_data;
uint8_t date_reported = 0;
uint8_t new;
@@ -85,7 +85,7 @@ ao_gps_report(void)
}
}
-__xdata struct ao_task ao_gps_report_task;
+struct ao_task ao_gps_report_task;
void
ao_gps_report_init(void)
diff --git a/src/kernel/ao_gps_report_mega.c b/src/kernel/ao_gps_report_mega.c
index 85614b85..37f1beaa 100644
--- a/src/kernel/ao_gps_report_mega.c
+++ b/src/kernel/ao_gps_report_mega.c
@@ -59,9 +59,9 @@ ao_gps_sparse_should_log(int32_t lat, int32_t lon, int16_t alt)
void
ao_gps_report_mega(void)
{
- static __xdata struct ao_log_mega gps_log;
- static __xdata struct ao_telemetry_location gps_data;
- static __xdata struct ao_telemetry_satellite gps_tracking_data;
+ static struct ao_log_mega gps_log;
+ static struct ao_telemetry_location gps_data;
+ static struct ao_telemetry_satellite gps_tracking_data;
uint8_t new;
uint8_t c, n, i;
@@ -125,7 +125,7 @@ ao_gps_report_mega(void)
}
}
-__xdata struct ao_task ao_gps_report_mega_task;
+struct ao_task ao_gps_report_mega_task;
void
ao_gps_report_mega_init(void)
diff --git a/src/kernel/ao_gps_report_metrum.c b/src/kernel/ao_gps_report_metrum.c
index 523fb17f..06863fe4 100644
--- a/src/kernel/ao_gps_report_metrum.c
+++ b/src/kernel/ao_gps_report_metrum.c
@@ -22,9 +22,9 @@
void
ao_gps_report_metrum(void)
{
- static __xdata struct ao_log_metrum gps_log;
- static __xdata struct ao_telemetry_location gps_data;
- static __xdata struct ao_telemetry_satellite gps_tracking_data;
+ static struct ao_log_metrum gps_log;
+ static struct ao_telemetry_location gps_data;
+ static struct ao_telemetry_satellite gps_tracking_data;
uint8_t c, n, i;
uint8_t svid;
uint8_t new;
@@ -88,7 +88,7 @@ ao_gps_report_metrum(void)
}
}
-__xdata struct ao_task ao_gps_report_metrum_task;
+struct ao_task ao_gps_report_metrum_task;
void
ao_gps_report_metrum_init(void)
diff --git a/src/kernel/ao_gps_show.c b/src/kernel/ao_gps_show.c
index ec197769..ab29e5e5 100644
--- a/src/kernel/ao_gps_show.c
+++ b/src/kernel/ao_gps_show.c
@@ -23,7 +23,7 @@
#include <ao_data.h>
void
-ao_gps_show(void) __reentrant
+ao_gps_show(void)
{
uint8_t i;
ao_mutex_get(&ao_gps_mutex);
diff --git a/src/kernel/ao_host.h b/src/kernel/ao_host.h
index 50583f52..592de54c 100644
--- a/src/kernel/ao_host.h
+++ b/src/kernel/ao_host.h
@@ -41,15 +41,11 @@ struct ao_adc {
int16_t sense_m; /* main continuity sense */
};
-#define __pdata
-#define __data
-#define __xdata
-#define __code
-#define __reentrant
-
-#define DATA_TO_XDATA(a) (a)
-#define PDATA_TO_XDATA(a) (a)
-#define CODE_TO_XDATA(a) (a)
+#define const
+
+#define a (a)
+#define a (a)
+#define a (a)
enum ao_flight_state {
ao_flight_startup = 0,
diff --git a/src/kernel/ao_ignite.c b/src/kernel/ao_ignite.c
index 52d9d77e..a6ff9979 100644
--- a/src/kernel/ao_ignite.c
+++ b/src/kernel/ao_ignite.c
@@ -23,7 +23,7 @@
#endif
#if HAS_IGNITE
-__xdata struct ao_ignition ao_ignition[2];
+struct ao_ignition ao_ignition[2];
void
ao_ignite(enum ao_igniter igniter)
@@ -42,9 +42,9 @@ ao_ignite(enum ao_igniter igniter)
enum ao_igniter_status
ao_igniter_status(enum ao_igniter igniter)
{
- __xdata struct ao_data packet;
- __pdata int16_t value;
- __pdata uint8_t request, firing, fired;
+ struct ao_data packet;
+ int16_t value;
+ uint8_t request, firing, fired;
ao_arch_critical(
ao_data_get(&packet);
@@ -72,10 +72,8 @@ ao_igniter_status(enum ao_igniter igniter)
return ao_igniter_unknown;
}
-#ifndef AO_IGNITER_SET_DROGUE
-#define AO_IGNITER_SET_DROGUE(v) AO_IGNITER_DROGUE = (v)
-#define AO_IGNITER_SET_MAIN(v) AO_IGNITER_MAIN = (v)
-#endif
+#define AO_IGNITER_SET_DROGUE(v) ao_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v)
+#define AO_IGNITER_SET_MAIN(v) ao_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, v)
#ifndef AO_IGNITER_FIRE_TIME
#define AO_IGNITER_FIRE_TIME AO_MS_TO_TICKS(50)
@@ -141,7 +139,7 @@ ao_igniter_fire(enum ao_igniter igniter)
void
ao_igniter(void)
{
- __xdata enum ao_igniter igniter;
+ enum ao_igniter igniter;
ao_config_get();
for (;;) {
@@ -187,13 +185,13 @@ ao_ignite_manual(void)
ao_cmd_status = ao_cmd_syntax_error;
}
-__code char * __code ao_igniter_status_names[] = {
+const char * const ao_igniter_status_names[] = {
"unknown", "ready", "active", "open"
};
#if HAS_IGNITE
void
-ao_ignite_print_status(enum ao_igniter igniter, __code char *name) __reentrant
+ao_ignite_print_status(enum ao_igniter igniter, const char *name)
{
enum ao_igniter_status status = ao_igniter_status(igniter);
printf("Igniter: %6s Status: %s\n",
@@ -214,20 +212,20 @@ ao_ignite_test(void)
#endif
}
-__code struct ao_cmds ao_ignite_cmds[] = {
+const struct ao_cmds ao_ignite_cmds[] = {
{ ao_ignite_manual, "i <key> {main|drogue}\0Fire igniter. <key> is doit with D&I" },
{ ao_ignite_test, "t\0Test igniter" },
{ 0, NULL },
};
#if HAS_IGNITE
-__xdata struct ao_task ao_igniter_task;
+struct ao_task ao_igniter_task;
void
ao_ignite_set_pins(void)
{
- ao_enable_output(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, AO_IGNITER_DROGUE, 0);
- ao_enable_output(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, AO_IGNITER_MAIN, 0);
+ ao_enable_output(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, 0);
+ ao_enable_output(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, 0);
}
#endif
diff --git a/src/kernel/ao_int64.c b/src/kernel/ao_int64.c
index fdea61c0..dffb8556 100644
--- a/src/kernel/ao_int64.c
+++ b/src/kernel/ao_int64.c
@@ -18,7 +18,7 @@
#include <ao_int64.h>
-void ao_plus64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, __pdata ao_int64_t *b) __FATTR {
+void ao_plus64(ao_int64_t *r, ao_int64_t *a, ao_int64_t *b) __FATTR {
__LOCAL uint32_t t;
r->high = a->high + b->high;
@@ -28,7 +28,7 @@ void ao_plus64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, __pdata ao_int64_t
r->low = t;
}
-void ao_minus64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, __pdata ao_int64_t *b) __FATTR {
+void ao_minus64(ao_int64_t *r, ao_int64_t *a, ao_int64_t *b) __FATTR {
__LOCAL uint32_t t;
r->high = a->high - b->high;
@@ -38,7 +38,7 @@ void ao_minus64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, __pdata ao_int64_t
r->low = t;
}
-void ao_rshift64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, uint8_t d) __FATTR {
+void ao_rshift64(ao_int64_t *r, ao_int64_t *a, uint8_t d) __FATTR {
if (d < 32) {
r->low = a->low >> d;
if (d)
@@ -51,7 +51,7 @@ void ao_rshift64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, uint8_t d) __FATT
}
}
-void ao_lshift64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, uint8_t d) __FATTR {
+void ao_lshift64(ao_int64_t *r, ao_int64_t *a, uint8_t d) __FATTR {
if (d < 32) {
r->high = a->high << d;
if (d)
@@ -64,7 +64,7 @@ void ao_lshift64(__pdata ao_int64_t *r, __pdata ao_int64_t *a, uint8_t d) __FATT
}
}
-static void ao_umul64_32_32(__ARG ao_int64_t *r, uint32_t a, uint32_t b) __reentrant {
+static void ao_umul64_32_32(__ARG ao_int64_t *r, uint32_t a, uint32_t b) {
__LOCAL uint32_t s;
__LOCAL ao_int64_t t;
r->low = (uint32_t) (uint16_t) a * (uint16_t) b;
@@ -83,7 +83,7 @@ static void ao_umul64_32_32(__ARG ao_int64_t *r, uint32_t a, uint32_t b) __reent
ao_plus64(r, r, &t);
}
-void ao_neg64(__pdata ao_int64_t *r, __pdata ao_int64_t *a) __FATTR {
+void ao_neg64(ao_int64_t *r, ao_int64_t *a) __FATTR {
r->high = ~a->high;
if (!(r->low = ~a->low + 1))
r->high++;
@@ -105,7 +105,7 @@ void ao_mul64_32_32(__ARG ao_int64_t *r, int32_t a, int32_t b) __FATTR {
ao_neg64(r, r);
}
-static void ao_umul64(__ARG ao_int64_t *r, __ARG ao_int64_t *a, __ARG ao_int64_t *b) __reentrant {
+static void ao_umul64(__ARG ao_int64_t *r, __ARG ao_int64_t *a, __ARG ao_int64_t *b) {
__LOCAL ao_int64_t r2, r3;
ao_umul64_32_32(&r2, a->high, b->low);
@@ -135,7 +135,7 @@ void ao_mul64(__ARG ao_int64_t *r, __ARG ao_int64_t *a, __ARG ao_int64_t *b) __F
ao_neg64(r, r);
}
-static void ao_umul64_64_16(__ARG ao_int64_t *r, __ARG ao_int64_t *a, uint16_t b) __reentrant {
+static void ao_umul64_64_16(__ARG ao_int64_t *r, __ARG ao_int64_t *a, uint16_t b) {
__LOCAL uint32_t h;
h = a->high * b;
diff --git a/src/kernel/ao_int64.h b/src/kernel/ao_int64.h
index 11c16404..3014182a 100644
--- a/src/kernel/ao_int64.h
+++ b/src/kernel/ao_int64.h
@@ -27,14 +27,14 @@ typedef struct {
} ao_int64_t;
#define __FATTR
-#define __ARG __pdata
-#define __LOCAL static __pdata
-
-void ao_plus64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a, __pdata ao_int64_t *ao_64b) __FATTR;
-void ao_minus64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a, __pdata ao_int64_t *ao_64b) __FATTR;
-void ao_neg64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a) __FATTR;
-void ao_rshift64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a, uint8_t d) __FATTR;
-void ao_lshift64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a, uint8_t d) __FATTR;
+#define __ARG
+#define __LOCAL static
+
+void ao_plus64(ao_int64_t *ao_64r, ao_int64_t *ao_64a, ao_int64_t *ao_64b) __FATTR;
+void ao_minus64(ao_int64_t *ao_64r, ao_int64_t *ao_64a, ao_int64_t *ao_64b) __FATTR;
+void ao_neg64(ao_int64_t *ao_64r, ao_int64_t *ao_64a) __FATTR;
+void ao_rshift64(ao_int64_t *ao_64r, ao_int64_t *ao_64a, uint8_t d) __FATTR;
+void ao_lshift64(ao_int64_t *ao_64r, ao_int64_t *ao_64a, uint8_t d) __FATTR;
void ao_mul64_32_32(__ARG ao_int64_t *r, __ARG int32_t a, __ARG int32_t b) __FATTR;
void ao_mul64_64_16(__ARG ao_int64_t *r, __ARG ao_int64_t *a, __ARG uint16_t b) __FATTR;
void ao_mul64(__ARG ao_int64_t * __ARG r, __ARG ao_int64_t * __ARG a, __ARG ao_int64_t *__ARG b) __FATTR;
diff --git a/src/kernel/ao_kalman.c b/src/kernel/ao_kalman.c
index e4cc6d4b..4f4ffe8f 100644
--- a/src/kernel/ao_kalman.c
+++ b/src/kernel/ao_kalman.c
@@ -24,9 +24,9 @@
#include "ao_sample.h"
#include "ao_kalman.h"
-static __pdata ao_k_t ao_k_height;
-static __pdata ao_k_t ao_k_speed;
-static __pdata ao_k_t ao_k_accel;
+static ao_k_t ao_k_height;
+static ao_k_t ao_k_speed;
+static ao_k_t ao_k_accel;
#define AO_K_STEP_100 to_fix_v(0.01)
#define AO_K_STEP_2_2_100 to_fix_v(0.00005)
@@ -37,24 +37,24 @@ static __pdata ao_k_t ao_k_accel;
#define AO_K_STEP_1 to_fix_v(1)
#define AO_K_STEP_2_2_1 to_fix_v(0.5)
-__pdata ao_v_t ao_height;
-__pdata ao_v_t ao_speed;
-__pdata ao_v_t ao_accel;
-__xdata ao_v_t ao_max_height;
-static __pdata ao_k_t ao_avg_height_scaled;
-__xdata ao_v_t ao_avg_height;
+ao_v_t ao_height;
+ao_v_t ao_speed;
+ao_v_t ao_accel;
+ao_v_t ao_max_height;
+static ao_k_t ao_avg_height_scaled;
+ao_v_t ao_avg_height;
-__pdata ao_v_t ao_error_h;
+ao_v_t ao_error_h;
#if !HAS_ACCEL || AO_FLIGHT_TEST
#define AO_ERROR_H_SQ_AVG 1
#endif
#if AO_ERROR_H_SQ_AVG
-__pdata ao_v_t ao_error_h_sq_avg;
+ao_v_t ao_error_h_sq_avg;
#endif
#if HAS_ACCEL
-__pdata ao_v_t ao_error_a;
+ao_v_t ao_error_a;
#endif
static void
diff --git a/src/kernel/ao_led.h b/src/kernel/ao_led.h
index 7de09237..5d982ca6 100644
--- a/src/kernel/ao_led.h
+++ b/src/kernel/ao_led.h
@@ -26,7 +26,7 @@
#define AO_LED_NONE 0
#ifndef AO_LED_TYPE
-#define AO_LED_TYPE uint8_t
+#define AO_LED_TYPE uint32_t
#endif
/* Turn on the specified LEDs */
@@ -51,10 +51,208 @@ ao_led_toggle(AO_LED_TYPE colors);
/* Turn on the specified LEDs for the indicated interval */
void
-ao_led_for(AO_LED_TYPE colors, uint16_t ticks) __reentrant;
+ao_led_for(AO_LED_TYPE colors, uint16_t ticks);
/* Initialize the LEDs */
void
-ao_led_init(AO_LED_TYPE enable);
+ao_led_init(void);
+
+#ifdef LED_0_PORT
+#define AO_LED_0 (1 << 0)
+#else
+#define AO_LED_0 0
+#endif
+#ifdef LED_1_PORT
+#define AO_LED_1 (1 << 1)
+#else
+#define AO_LED_1 0
+#endif
+#ifdef LED_2_PORT
+#define AO_LED_2 (1 << 2)
+#else
+#define AO_LED_2 0
+#endif
+#ifdef LED_3_PORT
+#define AO_LED_3 (1 << 3)
+#else
+#define AO_LED_3 0
+#endif
+#ifdef LED_4_PORT
+#define AO_LED_4 (1 << 4)
+#else
+#define AO_LED_4 0
+#endif
+#ifdef LED_5_PORT
+#define AO_LED_5 (1 << 5)
+#else
+#define AO_LED_5 0
+#endif
+#ifdef LED_6_PORT
+#define AO_LED_6 (1 << 6)
+#else
+#define AO_LED_6 0
+#endif
+#ifdef LED_7_PORT
+#define AO_LED_7 (1 << 7)
+#else
+#define AO_LED_7 0
+#endif
+#ifdef LED_8_PORT
+#define AO_LED_8 (1 << 8)
+#else
+#define AO_LED_8 0
+#endif
+#ifdef LED_9_PORT
+#define AO_LED_9 (1 << 9)
+#else
+#define AO_LED_9 0
+#endif
+#ifdef LED_10_PORT
+#define AO_LED_10 (1 << 10)
+#else
+#define AO_LED_10 0
+#endif
+#ifdef LED_11_PORT
+#define AO_LED_11 (1 << 11)
+#else
+#define AO_LED_11 0
+#endif
+#ifdef LED_12_PORT
+#define AO_LED_12 (1 << 12)
+#else
+#define AO_LED_12 0
+#endif
+#ifdef LED_13_PORT
+#define AO_LED_13 (1 << 13)
+#else
+#define AO_LED_13 0
+#endif
+#ifdef LED_14_PORT
+#define AO_LED_14 (1 << 14)
+#else
+#define AO_LED_14 0
+#endif
+#ifdef LED_15_PORT
+#define AO_LED_15 (1 << 15)
+#else
+#define AO_LED_15 0
+#endif
+#ifdef LED_16_PORT
+#define AO_LED_16 (1 << 16)
+#else
+#define AO_LED_16 0
+#endif
+#ifdef LED_17_PORT
+#define AO_LED_17 (1 << 17)
+#else
+#define AO_LED_17 0
+#endif
+#ifdef LED_18_PORT
+#define AO_LED_18 (1 << 18)
+#else
+#define AO_LED_18 0
+#endif
+#ifdef LED_19_PORT
+#define AO_LED_19 (1 << 19)
+#else
+#define AO_LED_19 0
+#endif
+#ifdef LED_20_PORT
+#define AO_LED_20 (1 << 20)
+#else
+#define AO_LED_20 0
+#endif
+#ifdef LED_21_PORT
+#define AO_LED_21 (1 << 21)
+#else
+#define AO_LED_21 0
+#endif
+#ifdef LED_22_PORT
+#define AO_LED_22 (1 << 22)
+#else
+#define AO_LED_22 0
+#endif
+#ifdef LED_23_PORT
+#define AO_LED_23 (1 << 23)
+#else
+#define AO_LED_23 0
+#endif
+#ifdef LED_24_PORT
+#define AO_LED_24 (1 << 24)
+#else
+#define AO_LED_24 0
+#endif
+#ifdef LED_25_PORT
+#define AO_LED_25 (1 << 25)
+#else
+#define AO_LED_25 0
+#endif
+#ifdef LED_26_PORT
+#define AO_LED_26 (1 << 26)
+#else
+#define AO_LED_26 0
+#endif
+#ifdef LED_27_PORT
+#define AO_LED_27 (1 << 27)
+#else
+#define AO_LED_27 0
+#endif
+#ifdef LED_28_PORT
+#define AO_LED_28 (1 << 28)
+#else
+#define AO_LED_28 0
+#endif
+#ifdef LED_29_PORT
+#define AO_LED_29 (1 << 29)
+#else
+#define AO_LED_29 0
+#endif
+#ifdef LED_30_PORT
+#define AO_LED_30 (1 << 30)
+#else
+#define AO_LED_30 0
+#endif
+#ifdef LED_31_PORT
+#define AO_LED_31 (1 << 31)
+#else
+#define AO_LED_31 0
+#endif
+
+#define AO_LEDS_AVAILABLE (AO_LED_0 | \
+ AO_LED_1 | \
+ AO_LED_2 | \
+ AO_LED_3 | \
+ AO_LED_4 | \
+ AO_LED_5 | \
+ AO_LED_6 | \
+ AO_LED_7 | \
+ AO_LED_8 | \
+ AO_LED_9 | \
+ AO_LED_10 | \
+ AO_LED_11 | \
+ AO_LED_12 | \
+ AO_LED_13 | \
+ AO_LED_14 | \
+ AO_LED_15 | \
+ AO_LED_16 | \
+ AO_LED_17 | \
+ AO_LED_18 | \
+ AO_LED_19 | \
+ AO_LED_20 | \
+ AO_LED_21 | \
+ AO_LED_22 | \
+ AO_LED_23 | \
+ AO_LED_24 | \
+ AO_LED_25 | \
+ AO_LED_26 | \
+ AO_LED_27 | \
+ AO_LED_28 | \
+ AO_LED_29 | \
+ AO_LED_30 | \
+ AO_LED_31)
+
+#ifndef LEDS_AVAILABLE
+#define LEDS_AVAILABLE AO_LEDS_AVAILABLE
+#endif
#endif /* _AO_LED_H_ */
diff --git a/src/kernel/ao_log.c b/src/kernel/ao_log.c
index 5fb086ce..fac211cf 100644
--- a/src/kernel/ao_log.c
+++ b/src/kernel/ao_log.c
@@ -23,13 +23,13 @@
#include <ao_tracker.h>
#endif
-__xdata uint8_t ao_log_mutex;
-__pdata uint32_t ao_log_current_pos;
-__pdata uint32_t ao_log_end_pos;
-__pdata uint32_t ao_log_start_pos;
-__xdata uint8_t ao_log_running;
-__pdata enum ao_flight_state ao_log_state;
-__xdata int16_t ao_flight_number;
+uint8_t ao_log_mutex;
+uint32_t ao_log_current_pos;
+uint32_t ao_log_end_pos;
+uint32_t ao_log_start_pos;
+uint8_t ao_log_running;
+enum ao_flight_state ao_log_state;
+int16_t ao_flight_number;
void
ao_log_flush(void)
@@ -47,7 +47,7 @@ struct ao_log_erase {
uint16_t flight;
};
-static __xdata struct ao_log_erase erase;
+static struct ao_log_erase erase;
#ifndef LOG_MAX_ERASE
#define LOG_MAX_ERASE 16
@@ -117,10 +117,10 @@ ao_log_erase_mark(void)
* structure.
*/
-__xdata ao_log_type ao_log_data;
+ao_log_type ao_log_data;
static uint8_t
-ao_log_csum(__xdata uint8_t *b) __reentrant
+ao_log_csum(uint8_t *b)
{
uint8_t sum = 0x5a;
uint8_t i;
@@ -131,12 +131,12 @@ ao_log_csum(__xdata uint8_t *b) __reentrant
}
uint8_t
-ao_log_write(__xdata ao_log_type *log) __reentrant
+ao_log_write(ao_log_type *log)
{
uint8_t wrote = 0;
/* set checksum */
log->csum = 0;
- log->csum = ao_log_csum((__xdata uint8_t *) log);
+ log->csum = ao_log_csum((uint8_t *) log);
ao_mutex_get(&ao_log_mutex); {
if (ao_log_current_pos >= ao_log_end_pos && ao_log_running)
ao_log_stop();
@@ -223,7 +223,7 @@ ao_log_max_flight(void)
}
static void
-ao_log_erase(uint8_t slot) __reentrant
+ao_log_erase(uint8_t slot)
{
uint32_t log_current_pos, log_end_pos;
@@ -232,7 +232,7 @@ ao_log_erase(uint8_t slot) __reentrant
log_end_pos = log_current_pos + ao_config.flight_log_max;
while (log_current_pos < log_end_pos) {
uint8_t i;
- static __xdata uint8_t b;
+ static uint8_t b;
/*
* Check to see if we've reached the end of
@@ -252,7 +252,7 @@ ao_log_erase(uint8_t slot) __reentrant
}
static void
-ao_log_find_max_erase_flight(void) __reentrant
+ao_log_find_max_erase_flight(void)
{
uint8_t log_slot;
@@ -273,7 +273,7 @@ ao_log_find_max_erase_flight(void) __reentrant
}
uint8_t
-ao_log_scan(void) __reentrant
+ao_log_scan(void)
{
uint8_t log_slot;
uint8_t log_slots;
@@ -402,11 +402,11 @@ ao_log_full(void)
#endif
#if LOG_ADC
-static __xdata struct ao_task ao_log_task;
+static struct ao_task ao_log_task;
#endif
void
-ao_log_list(void) __reentrant
+ao_log_list(void)
{
uint8_t slot;
uint8_t slots;
@@ -426,7 +426,7 @@ ao_log_list(void) __reentrant
}
void
-ao_log_delete(void) __reentrant
+ao_log_delete(void)
{
uint8_t slot;
uint8_t slots;
@@ -437,10 +437,9 @@ ao_log_delete(void) __reentrant
cmd_flight = -1;
ao_cmd_lex();
}
- ao_cmd_decimal();
+ cmd_flight *= ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- cmd_flight *= (int16_t) ao_cmd_lex_i;
slots = ao_log_slots();
/* Look for the flight log matching the requested flight */
@@ -462,7 +461,7 @@ ao_log_delete(void) __reentrant
printf("No such flight: %d\n", cmd_flight);
}
-__code struct ao_cmds ao_log_cmds[] = {
+const struct ao_cmds ao_log_cmds[] = {
{ ao_log_list, "l\0List logs" },
{ ao_log_delete, "d <flight-number>\0Delete flight" },
{ 0, NULL },
diff --git a/src/kernel/ao_log.h b/src/kernel/ao_log.h
index e2f1e0e4..a9715962 100644
--- a/src/kernel/ao_log.h
+++ b/src/kernel/ao_log.h
@@ -29,13 +29,13 @@
* the log. Tasks may wait for this to be initialized
* by sleeping on this variable.
*/
-extern __xdata int16_t ao_flight_number;
-extern __xdata uint8_t ao_log_mutex;
-extern __pdata uint32_t ao_log_current_pos;
-extern __pdata uint32_t ao_log_end_pos;
-extern __pdata uint32_t ao_log_start_pos;
-extern __xdata uint8_t ao_log_running;
-extern __pdata enum ao_flight_state ao_log_state;
+extern int16_t ao_flight_number;
+extern uint8_t ao_log_mutex;
+extern uint32_t ao_log_current_pos;
+extern uint32_t ao_log_end_pos;
+extern uint32_t ao_log_start_pos;
+extern uint8_t ao_log_running;
+extern enum ao_flight_state ao_log_state;
/* required functions from the underlying log system */
@@ -90,7 +90,7 @@ ao_log(void);
/* Figure out the current flight number */
uint8_t
-ao_log_scan(void) __reentrant;
+ao_log_scan(void);
/* Return the position of the start of the given log slot */
uint32_t
@@ -507,14 +507,14 @@ typedef struct ao_log_record ao_log_type;
#endif
#ifndef AO_LOG_UNCOMMON
-extern __xdata ao_log_type ao_log_data;
+extern ao_log_type ao_log_data;
#define AO_LOG_SIZE sizeof(ao_log_type)
/* Write a record to the eeprom log */
uint8_t
-ao_log_write(__xdata ao_log_type *log) __reentrant;
+ao_log_write(ao_log_type *log);
#endif
void
diff --git a/src/kernel/ao_log_big.c b/src/kernel/ao_log_big.c
index 7d7332e9..2a8cd63d 100644
--- a/src/kernel/ao_log_big.c
+++ b/src/kernel/ao_log_big.c
@@ -18,7 +18,7 @@
#include "ao.h"
-static __data uint8_t ao_log_data_pos;
+static uint8_t ao_log_data_pos;
/* a hack to make sure that ao_log_records fill the eeprom block in even units */
typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_record))] ;
@@ -32,7 +32,7 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_record))] ;
void
ao_log(void)
{
- __pdata uint16_t next_sensor, next_other;
+ uint16_t next_sensor, next_other;
ao_storage_setup();
diff --git a/src/kernel/ao_log_fireone.c b/src/kernel/ao_log_fireone.c
index 1a82673d..3dd52a16 100644
--- a/src/kernel/ao_log_fireone.c
+++ b/src/kernel/ao_log_fireone.c
@@ -21,12 +21,12 @@
#include <ao_data.h>
#include <ao_flight.h>
-static __xdata struct ao_log_firetwo log;
+static struct ao_log_firetwo log;
-__code uint8_t ao_log_format = AO_LOG_FORMAT_TELEFIRETWO;
+const uint8_t ao_log_format = AO_LOG_FORMAT_TELEFIRETWO;
static uint8_t
-ao_log_csum(__xdata uint8_t *b) __reentrant
+ao_log_csum(uint8_t *b)
{
uint8_t sum = 0x5a;
uint8_t i;
@@ -37,12 +37,12 @@ ao_log_csum(__xdata uint8_t *b) __reentrant
}
uint8_t
-ao_log_firetwo(__xdata struct ao_log_firetwo *log) __reentrant
+ao_log_firetwo(struct ao_log_firetwo *log)
{
uint8_t wrote = 0;
/* set checksum */
log->csum = 0;
- log->csum = ao_log_csum((__xdata uint8_t *) log);
+ log->csum = ao_log_csum((uint8_t *) log);
ao_mutex_get(&ao_log_mutex); {
if (ao_log_current_pos >= ao_log_end_pos && ao_log_running)
ao_log_stop();
@@ -66,7 +66,7 @@ ao_log_dump_check_data(void)
}
#if HAS_ADC
-static __data uint8_t ao_log_data_pos;
+static uint8_t ao_log_data_pos;
/* a hack to make sure that ao_log_metrums fill the eeprom block in even units */
typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_firetwo))] ;
diff --git a/src/kernel/ao_log_mega.c b/src/kernel/ao_log_mega.c
index 0ae4e536..341ff715 100644
--- a/src/kernel/ao_log_mega.c
+++ b/src/kernel/ao_log_mega.c
@@ -22,7 +22,7 @@
#include <ao_flight.h>
#if HAS_FLIGHT
-static __data uint8_t ao_log_data_pos;
+static uint8_t ao_log_data_pos;
/* a hack to make sure that ao_log_megas fill the eeprom block in even units */
typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_mega))] ;
@@ -36,7 +36,7 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_mega))] ;
void
ao_log(void)
{
- __pdata uint16_t next_sensor, next_other;
+ uint16_t next_sensor, next_other;
uint8_t i;
ao_storage_setup();
diff --git a/src/kernel/ao_log_metrum.c b/src/kernel/ao_log_metrum.c
index 34729070..18fb9ffb 100644
--- a/src/kernel/ao_log_metrum.c
+++ b/src/kernel/ao_log_metrum.c
@@ -22,7 +22,7 @@
#include <ao_flight.h>
#if HAS_ADC
-static __data uint8_t ao_log_data_pos;
+static uint8_t ao_log_data_pos;
/* a hack to make sure that ao_log_metrums fill the eeprom block in even units */
typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_metrum))] ;
@@ -36,7 +36,7 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_metrum))] ;
void
ao_log(void)
{
- __pdata uint16_t next_sensor, next_other;
+ uint16_t next_sensor, next_other;
ao_storage_setup();
diff --git a/src/kernel/ao_log_mini.c b/src/kernel/ao_log_mini.c
index 12c5d6bb..03bf2265 100644
--- a/src/kernel/ao_log_mini.c
+++ b/src/kernel/ao_log_mini.c
@@ -21,7 +21,7 @@
#include <ao_data.h>
#include <ao_flight.h>
-static __data uint8_t ao_log_data_pos;
+static uint8_t ao_log_data_pos;
/* a hack to make sure that ao_log_minis fill the eeprom block in even units */
typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_mini))] ;
@@ -34,7 +34,7 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_mini))] ;
void
ao_log(void)
{
- __pdata uint16_t next_sensor;
+ uint16_t next_sensor;
ao_storage_setup();
diff --git a/src/kernel/ao_log_single.c b/src/kernel/ao_log_single.c
index 63768e1a..a2b63c8d 100644
--- a/src/kernel/ao_log_single.c
+++ b/src/kernel/ao_log_single.c
@@ -26,16 +26,16 @@
#include "ao.h"
#include "ao_product.h"
-static __xdata struct ao_task ao_log_single_task;
+static struct ao_task ao_log_single_task;
-__xdata uint8_t ao_log_running;
-__xdata uint8_t ao_log_mutex;
-__pdata uint32_t ao_log_start_pos;
-__pdata uint32_t ao_log_end_pos;
-__pdata uint32_t ao_log_current_pos;
+uint8_t ao_log_running;
+uint8_t ao_log_mutex;
+uint32_t ao_log_start_pos;
+uint32_t ao_log_end_pos;
+uint32_t ao_log_current_pos;
-__xdata union ao_log_single ao_log_single_write_data;
-__xdata union ao_log_single ao_log_single_read_data;
+union ao_log_single ao_log_single_write_data;
+union ao_log_single ao_log_single_read_data;
uint8_t
ao_log_single_write(void)
@@ -59,7 +59,7 @@ ao_log_single_write(void)
static uint8_t
ao_log_single_valid(void)
{
- __xdata uint8_t *d = ao_log_single_read_data.bytes;
+ uint8_t *d = ao_log_single_read_data.bytes;
uint8_t i;
for (i = 0; i < AO_LOG_SINGLE_SIZE; i++)
if (*d++ != 0xff)
@@ -118,10 +118,11 @@ ao_log_single_restart(void)
void
ao_log_single_set(void)
{
+ uint16_t r;
printf("Logging currently %s\n", ao_log_running ? "on" : "off");
- ao_cmd_hex();
+ r = ao_cmd_hex();
if (ao_cmd_status == ao_cmd_success) {
- if (ao_cmd_lex_i) {
+ if (r) {
printf("Logging from %ld to %ld\n", ao_log_current_pos, ao_log_end_pos);
ao_log_single_start();
} else {
@@ -136,13 +137,12 @@ void
ao_log_single_delete(void)
{
uint32_t pos;
-
- ao_cmd_hex();
+ uint16_t r = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
- if (ao_cmd_lex_i != 1) {
+ if (r != 1) {
ao_cmd_status = ao_cmd_syntax_error;
- printf("No such flight: %d\n", ao_cmd_lex_i);
+ printf("No such flight: %d\n", r);
return;
}
ao_log_single_stop();
@@ -153,7 +153,7 @@ ao_log_single_delete(void)
}
ao_log_current_pos = ao_log_start_pos = 0;
if (pos == 0)
- printf("No such flight: %d\n", ao_cmd_lex_i);
+ printf("No such flight: %d\n", r);
else
printf ("Erased\n");
}
diff --git a/src/kernel/ao_log_telem.c b/src/kernel/ao_log_telem.c
index 1305a84d..8c0b88e4 100644
--- a/src/kernel/ao_log_telem.c
+++ b/src/kernel/ao_log_telem.c
@@ -20,13 +20,13 @@
#include <ao_flight.h>
#include <ao_sample.h>
-__code uint8_t ao_log_format = AO_LOG_FORMAT_TELEMETRY;
+const uint8_t ao_log_format = AO_LOG_FORMAT_TELEMETRY;
-static __data uint8_t ao_log_monitor_pos;
-__pdata enum ao_flight_state ao_flight_state;
-__xdata int16_t ao_max_height; /* max of ao_height */
-__pdata int16_t sense_d, sense_m;
-__pdata uint8_t ao_igniter_present;
+static uint8_t ao_log_monitor_pos;
+enum ao_flight_state ao_flight_state;
+int16_t ao_max_height; /* max of ao_height */
+int16_t sense_d, sense_m;
+uint8_t ao_igniter_present;
static void
ao_log_telem_track() {
@@ -50,7 +50,7 @@ ao_log_telem_track() {
ao_flight_state = ao_log_single_write_data.telemetry.sensor.state;
if (ao_flight_state == ao_flight_pad)
ao_max_height = 0;
- ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
+ ao_wakeup(&ao_flight_state);
}
}
}
@@ -111,7 +111,7 @@ ao_log_single(void)
ao_log_telem_track();
}
/* Wait for more telemetry data to arrive */
- ao_sleep(DATA_TO_XDATA(&ao_monitor_head));
+ ao_sleep(&ao_monitor_head);
}
}
}
diff --git a/src/kernel/ao_log_telescience.c b/src/kernel/ao_log_telescience.c
index 3f514f18..a21af71d 100644
--- a/src/kernel/ao_log_telescience.c
+++ b/src/kernel/ao_log_telescience.c
@@ -23,12 +23,12 @@
static uint8_t ao_log_data_pos;
-__code uint8_t ao_log_format = AO_LOG_FORMAT_TELESCIENCE;
+const uint8_t ao_log_format = AO_LOG_FORMAT_TELESCIENCE;
static void
-ao_log_telescience_csum(void) __reentrant
+ao_log_telescience_csum(void)
{
- __xdata uint8_t *b = ao_log_single_write_data.bytes;
+ uint8_t *b = ao_log_single_write_data.bytes;
uint8_t sum = 0x5a;
uint8_t i;
diff --git a/src/kernel/ao_log_tiny.c b/src/kernel/ao_log_tiny.c
index 0b8e39d6..53003111 100644
--- a/src/kernel/ao_log_tiny.c
+++ b/src/kernel/ao_log_tiny.c
@@ -18,7 +18,7 @@
#include "ao.h"
-static __data uint16_t ao_log_tiny_interval;
+static uint16_t ao_log_tiny_interval;
#define AO_LOG_TINY_INTERVAL_DEFAULT AO_MS_TO_TICKS(1000)
#if USE_FAST_ASCENT_LOG
@@ -41,13 +41,13 @@ static void ao_log_tiny_data(uint16_t d)
if (ao_log_current_pos >= ao_log_end_pos && ao_log_running)
ao_log_stop();
if (ao_log_running) {
- ao_storage_write(ao_log_current_pos, DATA_TO_XDATA(&d), 2);
+ ao_storage_write(ao_log_current_pos, &d, 2);
ao_log_current_pos += 2;
}
}
-static __xdata uint16_t ao_log_pad_ring[AO_PAD_RING];
-static __pdata uint8_t ao_log_pad_ring_pos;
+static uint16_t ao_log_pad_ring[AO_PAD_RING];
+static uint8_t ao_log_pad_ring_pos;
#define ao_pad_ring_next(n) (((n) + 1) & (AO_PAD_RING - 1))
@@ -102,7 +102,7 @@ ao_log(void)
/*
* Add in pending sample data
*/
- ao_sleep(DATA_TO_XDATA(&ao_sample_data));
+ ao_sleep(&ao_sample_data);
while (ao_log_data != ao_sample_data) {
sum += ao_data_pres(&ao_data_ring[ao_log_data]);
count++;
@@ -150,7 +150,7 @@ ao_log(void)
int16_t
ao_log_flight(uint8_t slot)
{
- static __xdata uint16_t flight;
+ static uint16_t flight;
(void) slot;
ao_storage_read(0, &flight, 2);
diff --git a/src/kernel/ao_monitor.c b/src/kernel/ao_monitor.c
index 7cbee288..3f1ff217 100644
--- a/src/kernel/ao_monitor.c
+++ b/src/kernel/ao_monitor.c
@@ -36,15 +36,15 @@
#error Must define AO_MONITOR_LED
#endif
-__xdata uint8_t ao_monitoring_mutex;
-__data uint8_t ao_monitoring;
-static __data uint8_t ao_monitor_disabled;
-static __data uint8_t ao_internal_monitoring;
-static __data uint8_t ao_external_monitoring;
+uint8_t ao_monitoring_mutex;
+uint8_t ao_monitoring;
+static uint8_t ao_monitor_disabled;
+static uint8_t ao_internal_monitoring;
+static uint8_t ao_external_monitoring;
-__xdata union ao_monitor ao_monitor_ring[AO_MONITOR_RING];
+union ao_monitor ao_monitor_ring[AO_MONITOR_RING];
-__data uint8_t ao_monitor_head;
+uint8_t ao_monitor_head;
static void
_ao_monitor_adjust(void)
@@ -59,7 +59,7 @@ _ao_monitor_adjust(void)
else
ao_monitoring = ao_internal_monitoring;
}
- ao_wakeup(DATA_TO_XDATA(&ao_monitoring));
+ ao_wakeup(&ao_monitoring);
}
void
@@ -70,7 +70,7 @@ ao_monitor_get(void)
for (;;) {
switch (ao_monitoring) {
case 0:
- ao_sleep(DATA_TO_XDATA(&ao_monitoring));
+ ao_sleep(&ao_monitoring);
continue;
#if LEGACY_MONITOR
case AO_MONITORING_ORIG:
@@ -86,12 +86,12 @@ ao_monitor_get(void)
if (!ao_radio_recv(&ao_monitor_ring[ao_monitor_head], size + 2, 0))
continue;
ao_monitor_head = ao_monitor_ring_next(ao_monitor_head);
- ao_wakeup(DATA_TO_XDATA(&ao_monitor_head));
+ ao_wakeup(&ao_monitor_head);
}
}
#if AO_MONITOR_LED
-__xdata struct ao_task ao_monitor_blink_task;
+struct ao_task ao_monitor_blink_task;
void
ao_monitor_blink(void)
@@ -100,7 +100,7 @@ ao_monitor_blink(void)
uint8_t *recv;
#endif
for (;;) {
- ao_sleep(DATA_TO_XDATA(&ao_monitor_head));
+ ao_sleep(&ao_monitor_head);
#ifdef AO_MONITOR_BAD
recv = (uint8_t *) &ao_monitor_ring[ao_monitor_ring_prev(ao_monitor_head)];
if (ao_monitoring && !(recv[ao_monitoring + 1] & AO_RADIO_STATUS_CRC_OK))
@@ -125,7 +125,7 @@ void
ao_monitor_put(void)
{
#if LEGACY_MONITOR
- __xdata char callsign[AO_MAX_CALLSIGN+1];
+ char callsign[AO_MAX_CALLSIGN+1];
#endif
#if LEGACY_MONITOR || HAS_RSSI
int16_t rssi;
@@ -133,7 +133,7 @@ ao_monitor_put(void)
uint8_t ao_monitor_tail;
uint8_t state;
uint8_t sum, byte;
- __xdata union ao_monitor *m;
+ union ao_monitor *m;
#define recv_raw ((m->raw))
#define recv_orig ((m->orig))
@@ -142,9 +142,9 @@ ao_monitor_put(void)
ao_monitor_tail = ao_monitor_head;
for (;;) {
while (!ao_external_monitoring)
- ao_sleep(DATA_TO_XDATA(&ao_external_monitoring));
+ ao_sleep(&ao_external_monitoring);
while (ao_monitor_tail == ao_monitor_head && ao_external_monitoring)
- ao_sleep(DATA_TO_XDATA(&ao_monitor_head));
+ ao_sleep(&ao_monitor_head);
if (!ao_external_monitoring)
continue;
m = &ao_monitor_ring[ao_monitor_tail];
@@ -266,10 +266,10 @@ ao_monitor_put(void)
}
}
-__xdata struct ao_task ao_monitor_put_task;
+struct ao_task ao_monitor_put_task;
#endif
-__xdata struct ao_task ao_monitor_get_task;
+struct ao_task ao_monitor_get_task;
void
ao_monitor_set(uint8_t monitoring)
@@ -296,21 +296,20 @@ ao_monitor_enable(void)
static void
set_monitor(void)
{
- ao_cmd_hex();
- ao_external_monitoring = ao_cmd_lex_i;
- ao_wakeup(DATA_TO_XDATA(&ao_external_monitoring));
- ao_wakeup(DATA_TO_XDATA(&ao_monitor_head));
+ ao_external_monitoring = ao_cmd_hex();
+ ao_wakeup(&ao_external_monitoring);
+ ao_wakeup(&ao_monitor_head);
_ao_monitor_adjust();
}
-__code struct ao_cmds ao_monitor_cmds[] = {
+const struct ao_cmds ao_monitor_cmds[] = {
{ set_monitor, "m <0 off, 1 old, 20 std>\0Set radio monitoring" },
{ 0, NULL },
};
#endif
void
-ao_monitor_init(void) __reentrant
+ao_monitor_init(void)
{
#if HAS_MONITOR_PUT
ao_cmd_register(&ao_monitor_cmds[0]);
diff --git a/src/kernel/ao_mutex.c b/src/kernel/ao_mutex.c
index ff73e3bc..4ef1a9ba 100644
--- a/src/kernel/ao_mutex.c
+++ b/src/kernel/ao_mutex.c
@@ -25,7 +25,7 @@
#if HAS_MUTEX_TRY
uint8_t
-ao_mutex_try(__xdata uint8_t *mutex, uint8_t task_id) __reentrant
+ao_mutex_try(uint8_t *mutex, uint8_t task_id)
{
uint8_t ret;
if (*mutex == task_id)
@@ -42,7 +42,7 @@ ao_mutex_try(__xdata uint8_t *mutex, uint8_t task_id) __reentrant
#endif
void
-ao_mutex_get(__xdata uint8_t *mutex) __reentrant
+ao_mutex_get(uint8_t *mutex)
{
if (*mutex == ao_cur_task->task_id)
ao_panic(AO_PANIC_MUTEX);
@@ -54,7 +54,7 @@ ao_mutex_get(__xdata uint8_t *mutex) __reentrant
}
void
-ao_mutex_put(__xdata uint8_t *mutex) __reentrant
+ao_mutex_put(uint8_t *mutex)
{
if (*mutex != ao_cur_task->task_id)
ao_panic(AO_PANIC_MUTEX);
diff --git a/src/kernel/ao_notask.c b/src/kernel/ao_notask.c
index 7207353a..a5bdc8a7 100644
--- a/src/kernel/ao_notask.c
+++ b/src/kernel/ao_notask.c
@@ -21,7 +21,7 @@
static volatile void *ao_wchan;
uint8_t
-ao_sleep(__xdata void *wchan)
+ao_sleep(void *wchan)
{
#if 1
ao_wchan = wchan;
@@ -55,7 +55,7 @@ ao_delay(uint16_t ticks)
#endif
void
-ao_wakeup(__xdata void *wchan)
+ao_wakeup(void *wchan)
{
(void) wchan;
ao_wchan = 0;
diff --git a/src/kernel/ao_notask.h b/src/kernel/ao_notask.h
index a4446726..ce622b63 100644
--- a/src/kernel/ao_notask.h
+++ b/src/kernel/ao_notask.h
@@ -20,9 +20,9 @@
#define _AO_NOTASK_H_
uint8_t
-ao_sleep(__xdata void *wchan);
+ao_sleep(void *wchan);
void
-ao_wakeup(__xdata void *wchan);
+ao_wakeup(void *wchan);
#endif /* _AO_NOTASK_H_ */
diff --git a/src/kernel/ao_packet.h b/src/kernel/ao_packet.h
index 9d99b0e6..24cd7b13 100644
--- a/src/kernel/ao_packet.h
+++ b/src/kernel/ao_packet.h
@@ -43,13 +43,13 @@ struct ao_packet_recv {
uint8_t status;
};
-extern __xdata struct ao_packet_recv ao_rx_packet;
-extern __xdata struct ao_packet ao_tx_packet;
-extern __xdata struct ao_task ao_packet_task;
-extern __xdata uint8_t ao_packet_enable;
-extern __xdata uint8_t ao_packet_master_sleeping;
-extern __pdata uint8_t ao_packet_rx_len, ao_packet_rx_used, ao_packet_tx_used;
-extern __xdata uint8_t ao_packet_restart;
+extern struct ao_packet_recv ao_rx_packet;
+extern struct ao_packet ao_tx_packet;
+extern struct ao_task ao_packet_task;
+extern uint8_t ao_packet_enable;
+extern uint8_t ao_packet_master_sleeping;
+extern uint8_t ao_packet_rx_len, ao_packet_rx_used, ao_packet_tx_used;
+extern uint8_t ao_packet_restart;
void
ao_packet_send(void);
@@ -61,7 +61,7 @@ void
ao_packet_flush(void);
void
-ao_packet_putchar(char c) __reentrant;
+ao_packet_putchar(char c);
int
_ao_packet_pollchar(void);
@@ -69,7 +69,7 @@ _ao_packet_pollchar(void);
#if PACKET_HAS_MASTER
/* ao_packet_master.c */
-extern __xdata int8_t ao_packet_last_rssi;
+extern int8_t ao_packet_last_rssi;
void
ao_packet_master_init(void);
diff --git a/src/kernel/ao_power.c b/src/kernel/ao_power.c
index bf59ab53..8c490604 100644
--- a/src/kernel/ao_power.c
+++ b/src/kernel/ao_power.c
@@ -26,7 +26,7 @@ ao_power_register(struct ao_power *power)
{
if (power->registered)
return;
- power->registered = TRUE;
+ power->registered = true;
if (tail) {
tail->next = power;
power->prev = tail;
@@ -44,7 +44,7 @@ ao_power_unregister(struct ao_power *power)
{
if (!power->registered)
return;
- power->registered = FALSE;
+ power->registered = false;
if (power->prev)
power->prev->next = power->next;
else
diff --git a/src/kernel/ao_product.c b/src/kernel/ao_product.c
index 4c2d83ef..72488654 100644
--- a/src/kernel/ao_product.c
+++ b/src/kernel/ao_product.c
@@ -61,7 +61,7 @@ const char ao_product[] = AO_iProduct_STRING;
#define NUM_INTERFACES (AO_USB_HAS_INT + 1)
/* USB descriptors in one giant block of bytes */
-AO_ROMCONFIG_SYMBOL(0x00aa) uint8_t ao_usb_descriptors [] =
+AO_ROMCONFIG_SYMBOL uint8_t ao_usb_descriptors [] =
{
/* Device descriptor */
0x12,
diff --git a/src/kernel/ao_pyro.c b/src/kernel/ao_pyro.c
index 527112ac..30d1518f 100644
--- a/src/kernel/ao_pyro.c
+++ b/src/kernel/ao_pyro.c
@@ -38,8 +38,8 @@
enum ao_igniter_status
ao_pyro_status(uint8_t p)
{
- __xdata struct ao_data packet;
- __pdata int16_t value;
+ struct ao_data packet;
+ int16_t value;
ao_arch_critical(
ao_data_get(&packet);
@@ -205,9 +205,9 @@ ao_pyro_ready(struct ao_pyro *pyro)
default:
continue;
}
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
#ifndef AO_FLIGHT_TEST
@@ -216,28 +216,28 @@ ao_pyro_pin_set(uint8_t p, uint8_t v)
{
switch (p) {
#if AO_PYRO_NUM > 0
- case 0: ao_gpio_set(AO_PYRO_PORT_0, AO_PYRO_PIN_0, AO_PYRO_0, v); break;
+ case 0: ao_gpio_set(AO_PYRO_PORT_0, AO_PYRO_PIN_0, v); break;
#endif
#if AO_PYRO_NUM > 1
- case 1: ao_gpio_set(AO_PYRO_PORT_1, AO_PYRO_PIN_1, AO_PYRO_1, v); break;
+ case 1: ao_gpio_set(AO_PYRO_PORT_1, AO_PYRO_PIN_1, v); break;
#endif
#if AO_PYRO_NUM > 2
- case 2: ao_gpio_set(AO_PYRO_PORT_2, AO_PYRO_PIN_2, AO_PYRO_2, v); break;
+ case 2: ao_gpio_set(AO_PYRO_PORT_2, AO_PYRO_PIN_2, v); break;
#endif
#if AO_PYRO_NUM > 3
- case 3: ao_gpio_set(AO_PYRO_PORT_3, AO_PYRO_PIN_3, AO_PYRO_3, v); break;
+ case 3: ao_gpio_set(AO_PYRO_PORT_3, AO_PYRO_PIN_3, v); break;
#endif
#if AO_PYRO_NUM > 4
- case 4: ao_gpio_set(AO_PYRO_PORT_4, AO_PYRO_PIN_4, AO_PYRO_4, v); break;
+ case 4: ao_gpio_set(AO_PYRO_PORT_4, AO_PYRO_PIN_4, v); break;
#endif
#if AO_PYRO_NUM > 5
- case 5: ao_gpio_set(AO_PYRO_PORT_5, AO_PYRO_PIN_5, AO_PYRO_5, v); break;
+ case 5: ao_gpio_set(AO_PYRO_PORT_5, AO_PYRO_PIN_5, v); break;
#endif
#if AO_PYRO_NUM > 6
- case 6: ao_gpio_set(AO_PYRO_PORT_6, AO_PYRO_PIN_6, AO_PYRO_6, v); break;
+ case 6: ao_gpio_set(AO_PYRO_PORT_6, AO_PYRO_PIN_6, v); break;
#endif
#if AO_PYRO_NUM > 7
- case 7: ao_gpio_set(AO_PYRO_PORT_7, AO_PYRO_PIN_7, AO_PYRO_7, v); break;
+ case 7: ao_gpio_set(AO_PYRO_PORT_7, AO_PYRO_PIN_7, v); break;
#endif
default: break;
}
@@ -404,7 +404,7 @@ ao_pyro(void)
ao_exit();
}
-__xdata struct ao_task ao_pyro_task;
+struct ao_task ao_pyro_task;
static void
@@ -484,10 +484,9 @@ ao_pyro_set(void)
}
#endif
- ao_cmd_decimal();
+ p = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- p = ao_cmd_lex_i;
if (AO_PYRO_NUM <= p) {
printf ("invalid pyro channel %d\n", p);
return;
@@ -516,25 +515,23 @@ ao_pyro_set(void)
}
pyro_tmp.flags |= ao_pyro_values[v].flag;
if (ao_pyro_values[v].offset != NO_VALUE) {
- uint8_t negative = 0;
+ int16_t r = 1;
ao_cmd_white();
if (ao_cmd_lex_c == '-') {
- negative = 1;
+ r = -1;
ao_cmd_lex();
}
- ao_cmd_decimal();
+ r *= ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
if (ao_pyro_values[v].flag & AO_PYRO_8_BIT_VALUE) {
- if (negative) {
+ if (r < 0) {
ao_cmd_status = ao_cmd_syntax_error;
return;
}
- *((uint8_t *) ((char *) &pyro_tmp + ao_pyro_values[v].offset)) = ao_cmd_lex_i;
+ *((uint8_t *) ((char *) &pyro_tmp + ao_pyro_values[v].offset)) = r;
} else {
- if (negative)
- ao_cmd_lex_i = -ao_cmd_lex_i;
- *((int16_t *) (void *) ((char *) &pyro_tmp + ao_pyro_values[v].offset)) = ao_cmd_lex_i;
+ *((int16_t *) (void *) ((char *) &pyro_tmp + ao_pyro_values[v].offset)) = r;
}
}
}
@@ -558,28 +555,28 @@ void
ao_pyro_init(void)
{
#if AO_PYRO_NUM > 0
- ao_enable_output(AO_PYRO_PORT_0, AO_PYRO_PIN_0, AO_PYRO_0, 0);
+ ao_enable_output(AO_PYRO_PORT_0, AO_PYRO_PIN_0, 0);
#endif
#if AO_PYRO_NUM > 1
- ao_enable_output(AO_PYRO_PORT_1, AO_PYRO_PIN_1, AO_PYRO_1, 0);
+ ao_enable_output(AO_PYRO_PORT_1, AO_PYRO_PIN_1, 0);
#endif
#if AO_PYRO_NUM > 2
- ao_enable_output(AO_PYRO_PORT_2, AO_PYRO_PIN_2, AO_PYRO_2, 0);
+ ao_enable_output(AO_PYRO_PORT_2, AO_PYRO_PIN_2, 0);
#endif
#if AO_PYRO_NUM > 3
- ao_enable_output(AO_PYRO_PORT_3, AO_PYRO_PIN_3, AO_PYRO_3, 0);
+ ao_enable_output(AO_PYRO_PORT_3, AO_PYRO_PIN_3, 0);
#endif
#if AO_PYRO_NUM > 4
- ao_enable_output(AO_PYRO_PORT_4, AO_PYRO_PIN_4, AO_PYRO_4, 0);
+ ao_enable_output(AO_PYRO_PORT_4, AO_PYRO_PIN_4, 0);
#endif
#if AO_PYRO_NUM > 5
- ao_enable_output(AO_PYRO_PORT_5, AO_PYRO_PIN_5, AO_PYRO_5, 0);
+ ao_enable_output(AO_PYRO_PORT_5, AO_PYRO_PIN_5, 0);
#endif
#if AO_PYRO_NUM > 6
- ao_enable_output(AO_PYRO_PORT_6, AO_PYRO_PIN_6, AO_PYRO_6, 0);
+ ao_enable_output(AO_PYRO_PORT_6, AO_PYRO_PIN_6, 0);
#endif
#if AO_PYRO_NUM > 7
- ao_enable_output(AO_PYRO_PORT_7, AO_PYRO_PIN_7, AO_PYRO_7, 0);
+ ao_enable_output(AO_PYRO_PORT_7, AO_PYRO_PIN_7, 0);
#endif
ao_add_task(&ao_pyro_task, ao_pyro, "pyro");
}
diff --git a/src/kernel/ao_radio_cmac.c b/src/kernel/ao_radio_cmac.c
index 92b365a2..155fce35 100644
--- a/src/kernel/ao_radio_cmac.c
+++ b/src/kernel/ao_radio_cmac.c
@@ -19,9 +19,9 @@
#include <ao.h>
#include <ao_radio_cmac.h>
-static __xdata uint8_t ao_radio_cmac_mutex;
-__pdata int8_t ao_radio_cmac_rssi;
-static __xdata uint8_t cmac_data[AO_CMAC_MAX_LEN + AO_CMAC_KEY_LEN + 2 + AO_CMAC_KEY_LEN];
+static uint8_t ao_radio_cmac_mutex;
+int8_t ao_radio_cmac_rssi;
+static uint8_t cmac_data[AO_CMAC_MAX_LEN + AO_CMAC_KEY_LEN + 2 + AO_CMAC_KEY_LEN];
static uint8_t
round_len(uint8_t len)
@@ -45,7 +45,7 @@ round_len(uint8_t len)
* Sign and deliver the data sitting in the cmac buffer
*/
static void
-radio_cmac_send(uint8_t len) __reentrant
+radio_cmac_send(uint8_t len)
{
uint8_t i;
@@ -77,7 +77,7 @@ radio_cmac_send(uint8_t len) __reentrant
*/
static int8_t
-radio_cmac_recv(uint8_t len, uint16_t timeout) __reentrant
+radio_cmac_recv(uint8_t len, uint16_t timeout)
{
uint8_t i;
@@ -127,7 +127,7 @@ radio_cmac_recv(uint8_t len, uint16_t timeout) __reentrant
}
int8_t
-ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant
+ao_radio_cmac_send(void *packet, uint8_t len)
{
if (len > AO_CMAC_MAX_LEN)
return AO_RADIO_CMAC_LEN_ERROR;
@@ -145,7 +145,7 @@ ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant
}
int8_t
-ao_radio_cmac_recv(__xdata void *packet, uint8_t len, uint16_t timeout) __reentrant
+ao_radio_cmac_recv(void *packet, uint8_t len, uint16_t timeout)
{
int8_t i;
if (len > AO_CMAC_MAX_LEN)
diff --git a/src/kernel/ao_radio_cmac.h b/src/kernel/ao_radio_cmac.h
index 74fe8c60..5fd6e105 100644
--- a/src/kernel/ao_radio_cmac.h
+++ b/src/kernel/ao_radio_cmac.h
@@ -24,10 +24,10 @@
#define AO_CMAC_KEY_LEN AO_AES_LEN
#define AO_CMAC_MAX_LEN (128 - AO_CMAC_KEY_LEN)
-extern __pdata int8_t ao_radio_cmac_rssi;
+extern int8_t ao_radio_cmac_rssi;
int8_t
-ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant;
+ao_radio_cmac_send(void *packet, uint8_t len);
#define AO_RADIO_CMAC_OK 0
#define AO_RADIO_CMAC_LEN_ERROR -1
@@ -36,7 +36,7 @@ ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant;
#define AO_RADIO_CMAC_TIMEOUT -4
int8_t
-ao_radio_cmac_recv(__xdata void *packet, uint8_t len, uint16_t timeout) __reentrant;
+ao_radio_cmac_recv(void *packet, uint8_t len, uint16_t timeout);
void
ao_radio_cmac_init(void);
diff --git a/src/kernel/ao_radio_cmac_cmd.c b/src/kernel/ao_radio_cmac_cmd.c
index 6d29f392..1433e96d 100644
--- a/src/kernel/ao_radio_cmac_cmd.c
+++ b/src/kernel/ao_radio_cmac_cmd.c
@@ -20,7 +20,7 @@
#include <ao_radio_cmac_cmd.h>
#include <ao_radio_cmac.h>
-static __xdata uint8_t cmac_data[AO_CMAC_MAX_LEN];
+static uint8_t cmac_data[AO_CMAC_MAX_LEN];
static uint8_t
getnibble(void)
@@ -45,21 +45,19 @@ getbyte(void)
}
static void
-radio_cmac_send_cmd(void) __reentrant
+radio_cmac_send_cmd(void)
{
uint8_t i;
uint8_t len;
- ao_cmd_decimal();
+ len = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- len = ao_cmd_lex_i;
if (len > AO_CMAC_MAX_LEN) {
ao_cmd_status = ao_cmd_syntax_error;
return;
}
flush();
- len = ao_cmd_lex_i;
for (i = 0; i < len; i++) {
cmac_data[i] = getbyte();
if (ao_cmd_status != ao_cmd_success)
@@ -69,19 +67,17 @@ radio_cmac_send_cmd(void) __reentrant
}
static void
-radio_cmac_recv_cmd(void) __reentrant
+radio_cmac_recv_cmd(void)
{
uint8_t len, i;
uint16_t timeout;
- ao_cmd_decimal();
+ len = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- len = ao_cmd_lex_i;
- ao_cmd_decimal();
+ timeout = AO_MS_TO_TICKS(ao_cmd_decimal());
if (ao_cmd_status != ao_cmd_success)
return;
- timeout = AO_MS_TO_TICKS(ao_cmd_lex_i);
i = ao_radio_cmac_recv(cmac_data, len, timeout);
if (i == AO_RADIO_CMAC_OK) {
printf ("PACKET ");
@@ -92,7 +88,7 @@ radio_cmac_recv_cmd(void) __reentrant
printf ("ERROR %d %d\n", i, ao_radio_cmac_rssi);
}
-static __code struct ao_cmds ao_radio_cmac_cmds[] = {
+static const struct ao_cmds ao_radio_cmac_cmds[] = {
{ radio_cmac_send_cmd, "s <length>\0Send AES-CMAC packet. Bytes to send follow on next line" },
{ radio_cmac_recv_cmd, "S <length> <timeout>\0Receive AES-CMAC packet. Timeout in ms" },
{ 0, NULL },
diff --git a/src/kernel/ao_report.c b/src/kernel/ao_report.c
index af48b390..08967af8 100644
--- a/src/kernel/ao_report.c
+++ b/src/kernel/ao_report.c
@@ -58,7 +58,7 @@ static const uint8_t flight_reports[] = {
#endif
#define pause(time) ao_delay(time)
-static __pdata enum ao_flight_state ao_report_state;
+static enum ao_flight_state ao_report_state;
/*
* Farnsworth spacing
@@ -115,7 +115,7 @@ static __pdata enum ao_flight_state ao_report_state;
*/
static void
-ao_report_beep(void) __reentrant
+ao_report_beep(void)
{
uint8_t r = flight_reports[ao_flight_state];
uint8_t l = r & 7;
@@ -134,7 +134,7 @@ ao_report_beep(void) __reentrant
}
static void
-ao_report_digit(uint8_t digit) __reentrant
+ao_report_digit(uint8_t digit)
{
if (!digit) {
mid(AO_MS_TO_TICKS(500));
@@ -151,8 +151,8 @@ ao_report_digit(uint8_t digit) __reentrant
static void
ao_report_number(int16_t n)
{
- __xdata uint8_t digits[10];
- __pdata uint8_t ndigits, i;
+ uint8_t digits[10];
+ uint8_t ndigits, i;
if (n < 0)
n = 0;
@@ -178,12 +178,12 @@ ao_report_altitude(void)
static void
ao_report_battery(void)
{
- __xdata struct ao_data packet;
+ struct ao_data packet;
for (;;) {
ao_data_get(&packet);
if (packet.adc.v_batt != 0)
break;
- ao_sleep(DATA_TO_XDATA(&ao_sample_data));
+ ao_sleep(&ao_sample_data);
}
ao_report_number(ao_battery_decivolt(packet.adc.v_batt));
}
@@ -204,7 +204,7 @@ ao_report_igniter(void)
}
static void
-ao_report_continuity(void) __reentrant
+ao_report_continuity(void)
{
uint8_t c;
@@ -281,11 +281,11 @@ ao_report(void)
}
#endif
while (ao_report_state == ao_flight_state)
- ao_sleep(DATA_TO_XDATA(&ao_flight_state));
+ ao_sleep(&ao_flight_state);
}
}
-static __xdata struct ao_task ao_report_task;
+static struct ao_task ao_report_task;
void
ao_report_init(void)
diff --git a/src/kernel/ao_report_micro.c b/src/kernel/ao_report_micro.c
index 9c7afdc5..efada54b 100644
--- a/src/kernel/ao_report_micro.c
+++ b/src/kernel/ao_report_micro.c
@@ -23,7 +23,7 @@
#define pause(time) ao_delay(time)
static void
-ao_report_digit(uint8_t digit) __reentrant
+ao_report_digit(uint8_t digit)
{
if (!digit) {
mid(AO_MS_TO_TICKS(1000));
@@ -40,9 +40,9 @@ ao_report_digit(uint8_t digit) __reentrant
void
ao_report_altitude(void)
{
- __pdata alt_t agl = ao_max_height;
- static __xdata uint8_t digits[11];
- __pdata uint8_t ndigits, i;
+ alt_t agl = ao_max_height;
+ static uint8_t digits[11];
+ uint8_t ndigits, i;
if (agl < 0)
agl = 0;
diff --git a/src/avr/ao_romconfig.c b/src/kernel/ao_romconfig.c
index 4acfc1c8..b75142f5 100644
--- a/src/avr/ao_romconfig.c
+++ b/src/kernel/ao_romconfig.c
@@ -18,4 +18,9 @@
#include "ao.h"
-AO_ROMCONFIG_SYMBOL (0) uint16_t ao_serial_number = 0;
+AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_version = AO_ROMCONFIG_VERSION;
+AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_check = ~AO_ROMCONFIG_VERSION;
+AO_ROMCONFIG_SYMBOL uint16_t ao_serial_number = 0;
+#if HAS_RADIO
+AO_ROMCONFIG_SYMBOL uint32_t ao_radio_cal = AO_RADIO_CAL_DEFAULT;
+#endif
diff --git a/src/kernel/ao_rssi.c b/src/kernel/ao_rssi.c
index 66fb8b57..aacc38b2 100644
--- a/src/kernel/ao_rssi.c
+++ b/src/kernel/ao_rssi.c
@@ -18,9 +18,9 @@
#include "ao.h"
-static __xdata uint16_t ao_rssi_time;
-static __pdata uint16_t ao_rssi_delay;
-static __pdata AO_LED_TYPE ao_rssi_led;
+static uint16_t ao_rssi_time;
+static uint16_t ao_rssi_delay;
+static AO_LED_TYPE ao_rssi_led;
void
ao_rssi(void)
@@ -43,7 +43,7 @@ ao_rssi_set(int16_t rssi_value)
ao_wakeup(&ao_rssi_time);
}
-__xdata struct ao_task ao_rssi_task;
+struct ao_task ao_rssi_task;
void
ao_rssi_init(AO_LED_TYPE rssi_led)
diff --git a/src/kernel/ao_sample.c b/src/kernel/ao_sample.c
index f8012e34..9cba36c1 100644
--- a/src/kernel/ao_sample.c
+++ b/src/kernel/ao_sample.c
@@ -35,63 +35,63 @@
#define ACCEL_TYPE int16_t
#endif
-__pdata uint16_t ao_sample_tick; /* time of last data */
-__pdata pres_t ao_sample_pres;
-__pdata alt_t ao_sample_alt;
-__pdata alt_t ao_sample_height;
+uint16_t ao_sample_tick; /* time of last data */
+pres_t ao_sample_pres;
+alt_t ao_sample_alt;
+alt_t ao_sample_height;
#if HAS_ACCEL
-__pdata accel_t ao_sample_accel;
+accel_t ao_sample_accel;
#endif
#if HAS_GYRO
-__pdata accel_t ao_sample_accel_along;
-__pdata accel_t ao_sample_accel_across;
-__pdata accel_t ao_sample_accel_through;
-__pdata gyro_t ao_sample_roll;
-__pdata gyro_t ao_sample_pitch;
-__pdata gyro_t ao_sample_yaw;
-__pdata angle_t ao_sample_orient;
-__pdata angle_t ao_sample_orients[AO_NUM_ORIENT];
-__pdata uint8_t ao_sample_orient_pos;
+accel_t ao_sample_accel_along;
+accel_t ao_sample_accel_across;
+accel_t ao_sample_accel_through;
+gyro_t ao_sample_roll;
+gyro_t ao_sample_pitch;
+gyro_t ao_sample_yaw;
+angle_t ao_sample_orient;
+angle_t ao_sample_orients[AO_NUM_ORIENT];
+uint8_t ao_sample_orient_pos;
#endif
-__data uint8_t ao_sample_data;
+uint8_t ao_sample_data;
/*
* Sensor calibration values
*/
-__pdata pres_t ao_ground_pres; /* startup pressure */
-__pdata alt_t ao_ground_height; /* MSL of ao_ground_pres */
+pres_t ao_ground_pres; /* startup pressure */
+alt_t ao_ground_height; /* MSL of ao_ground_pres */
#if HAS_ACCEL
-__pdata accel_t ao_ground_accel; /* startup acceleration */
-__pdata accel_t ao_accel_2g; /* factory accel calibration */
-__pdata int32_t ao_accel_scale; /* sensor to m/s² conversion */
+accel_t ao_ground_accel; /* startup acceleration */
+accel_t ao_accel_2g; /* factory accel calibration */
+int32_t ao_accel_scale; /* sensor to m/s² conversion */
#endif
#if HAS_GYRO
-__pdata accel_t ao_ground_accel_along;
-__pdata accel_t ao_ground_accel_across;
-__pdata accel_t ao_ground_accel_through;
-__pdata int32_t ao_ground_pitch;
-__pdata int32_t ao_ground_yaw;
-__pdata int32_t ao_ground_roll;
+accel_t ao_ground_accel_along;
+accel_t ao_ground_accel_across;
+accel_t ao_ground_accel_through;
+int32_t ao_ground_pitch;
+int32_t ao_ground_yaw;
+int32_t ao_ground_roll;
#endif
-static __pdata uint8_t ao_preflight; /* in preflight mode */
+static uint8_t ao_preflight; /* in preflight mode */
-static __pdata uint16_t nsamples;
-__pdata int32_t ao_sample_pres_sum;
+static uint16_t nsamples;
+int32_t ao_sample_pres_sum;
#if HAS_ACCEL
-__pdata int32_t ao_sample_accel_sum;
+int32_t ao_sample_accel_sum;
#endif
#if HAS_GYRO
-__pdata int32_t ao_sample_accel_along_sum;
-__pdata int32_t ao_sample_accel_across_sum;
-__pdata int32_t ao_sample_accel_through_sum;
-__pdata int32_t ao_sample_pitch_sum;
-__pdata int32_t ao_sample_yaw_sum;
-__pdata int32_t ao_sample_roll_sum;
+int32_t ao_sample_accel_along_sum;
+int32_t ao_sample_accel_across_sum;
+int32_t ao_sample_accel_through_sum;
+int32_t ao_sample_pitch_sum;
+int32_t ao_sample_yaw_sum;
+int32_t ao_sample_roll_sum;
static struct ao_quaternion ao_rotation;
#endif
@@ -277,7 +277,7 @@ ao_sample_preflight(void)
ao_accel_scale = to_fix_32(GRAVITY * 2 * 16) / ao_accel_2g;
#endif
ao_sample_preflight_set();
- ao_preflight = FALSE;
+ ao_preflight = false;
}
}
@@ -321,10 +321,10 @@ static gyro_t inline ao_gyro(void) {
uint8_t
ao_sample(void)
{
- ao_wakeup(DATA_TO_XDATA(&ao_sample_data));
- ao_sleep((void *) DATA_TO_XDATA(&ao_data_head));
+ ao_wakeup(&ao_sample_data);
+ ao_sleep((void *) &ao_data_head);
while (ao_sample_data != ao_data_head) {
- __xdata struct ao_data *ao_data;
+ struct ao_data *ao_data;
/* Capture a sample */
ao_data = (struct ao_data *) &ao_data_ring[ao_sample_data];
@@ -398,5 +398,5 @@ ao_sample_init(void)
ao_sample_set_all_orients();
#endif
ao_sample_data = ao_data_head;
- ao_preflight = TRUE;
+ ao_preflight = true;
}
diff --git a/src/kernel/ao_sample.h b/src/kernel/ao_sample.h
index 5ae389be..4c51a58c 100644
--- a/src/kernel/ao_sample.h
+++ b/src/kernel/ao_sample.h
@@ -115,46 +115,46 @@ typedef int16_t ao_v_t;
#define AO_MS_TO_SPEED(ms) ((ao_v_t) ((ms) * 16))
#define AO_MSS_TO_ACCEL(mss) ((ao_v_t) ((mss) * 16))
-extern __pdata uint16_t ao_sample_tick; /* time of last data */
-extern __data uint8_t ao_sample_adc; /* Ring position of last processed sample */
-extern __data uint8_t ao_sample_data; /* Ring position of last processed sample */
+extern uint16_t ao_sample_tick; /* time of last data */
+extern uint8_t ao_sample_adc; /* Ring position of last processed sample */
+extern uint8_t ao_sample_data; /* Ring position of last processed sample */
#if HAS_BARO
-extern __pdata pres_t ao_sample_pres; /* most recent pressure sensor reading */
-extern __pdata alt_t ao_sample_alt; /* MSL of ao_sample_pres */
-extern __pdata alt_t ao_sample_height; /* AGL of ao_sample_pres */
-extern __pdata pres_t ao_ground_pres; /* startup pressure */
-extern __pdata alt_t ao_ground_height; /* MSL of ao_ground_pres */
+extern pres_t ao_sample_pres; /* most recent pressure sensor reading */
+extern alt_t ao_sample_alt; /* MSL of ao_sample_pres */
+extern alt_t ao_sample_height; /* AGL of ao_sample_pres */
+extern pres_t ao_ground_pres; /* startup pressure */
+extern alt_t ao_ground_height; /* MSL of ao_ground_pres */
#endif
#if HAS_ACCEL
-extern __pdata accel_t ao_sample_accel; /* most recent accel sensor reading */
-extern __pdata accel_t ao_ground_accel; /* startup acceleration */
-extern __pdata accel_t ao_accel_2g; /* factory accel calibration */
-extern __pdata int32_t ao_accel_scale; /* sensor to m/s² conversion */
+extern accel_t ao_sample_accel; /* most recent accel sensor reading */
+extern accel_t ao_ground_accel; /* startup acceleration */
+extern accel_t ao_accel_2g; /* factory accel calibration */
+extern int32_t ao_accel_scale; /* sensor to m/s² conversion */
#endif
#if HAS_GYRO
-extern __pdata accel_t ao_ground_accel_along;
-extern __pdata accel_t ao_ground_accel_across;
-extern __pdata accel_t ao_ground_accel_through;
-extern __pdata int32_t ao_ground_pitch; /* * 512 */
-extern __pdata int32_t ao_ground_yaw; /* * 512 */
-extern __pdata int32_t ao_ground_roll; /* * 512 */
-extern __pdata accel_t ao_sample_accel_along;
-extern __pdata accel_t ao_sample_accel_across;
-extern __pdata accel_t ao_sample_accel_through;
-extern __pdata gyro_t ao_sample_roll;
-extern __pdata gyro_t ao_sample_pitch;
-extern __pdata gyro_t ao_sample_yaw;
+extern accel_t ao_ground_accel_along;
+extern accel_t ao_ground_accel_across;
+extern accel_t ao_ground_accel_through;
+extern int32_t ao_ground_pitch; /* * 512 */
+extern int32_t ao_ground_yaw; /* * 512 */
+extern int32_t ao_ground_roll; /* * 512 */
+extern accel_t ao_sample_accel_along;
+extern accel_t ao_sample_accel_across;
+extern accel_t ao_sample_accel_through;
+extern gyro_t ao_sample_roll;
+extern gyro_t ao_sample_pitch;
+extern gyro_t ao_sample_yaw;
#define AO_NUM_ORIENT 64
-extern __pdata angle_t ao_sample_orient;
-extern __pdata angle_t ao_sample_orients[AO_NUM_ORIENT];
-extern __pdata uint8_t ao_sample_orient_pos;
+extern angle_t ao_sample_orient;
+extern angle_t ao_sample_orients[AO_NUM_ORIENT];
+extern uint8_t ao_sample_orient_pos;
#endif
void ao_sample_init(void);
-/* returns FALSE in preflight mode, TRUE in flight mode */
+/* returns false in preflight mode, true in flight mode */
uint8_t ao_sample(void);
/*
@@ -176,19 +176,19 @@ uint8_t ao_sample(void);
#define from_fix(x) ((x) >> 16)
-extern __pdata ao_v_t ao_height; /* meters */
-extern __pdata ao_v_t ao_speed; /* m/s * 16 */
-extern __pdata ao_v_t ao_accel; /* m/s² * 16 */
-extern __xdata ao_v_t ao_max_height; /* max of ao_height */
-extern __xdata ao_v_t ao_avg_height; /* running average of height */
+extern ao_v_t ao_height; /* meters */
+extern ao_v_t ao_speed; /* m/s * 16 */
+extern ao_v_t ao_accel; /* m/s² * 16 */
+extern ao_v_t ao_max_height; /* max of ao_height */
+extern ao_v_t ao_avg_height; /* running average of height */
-extern __pdata ao_v_t ao_error_h;
+extern ao_v_t ao_error_h;
#if !HAS_ACCEL
-extern __pdata ao_v_t ao_error_h_sq_avg;
+extern ao_v_t ao_error_h_sq_avg;
#endif
#if HAS_ACCEL
-extern __pdata ao_v_t ao_error_a;
+extern ao_v_t ao_error_a;
#endif
#endif
diff --git a/src/kernel/ao_sample_profile.c b/src/kernel/ao_sample_profile.c
index 4819a161..b9d0e07f 100644
--- a/src/kernel/ao_sample_profile.c
+++ b/src/kernel/ao_sample_profile.c
@@ -160,7 +160,7 @@ ao_sample_profile_cmd(void)
}
}
-static __code struct ao_cmds ao_sample_profile_cmds[] = {
+static const struct ao_cmds ao_sample_profile_cmds[] = {
{ ao_sample_profile_cmd, "S <1 start,0 stop, d dump,c clear>\0Sample profile" },
{ 0, NULL }
};
diff --git a/src/kernel/ao_send_packet.c b/src/kernel/ao_send_packet.c
index c8a1d46e..cae25151 100644
--- a/src/kernel/ao_send_packet.c
+++ b/src/kernel/ao_send_packet.c
@@ -20,17 +20,16 @@
#define AO_MAX_SEND 128
-static __xdata uint8_t ao_send[AO_MAX_SEND];
+static uint8_t ao_send[AO_MAX_SEND];
static void
ao_send_packet(void)
{
- __pdata uint16_t count;
+ uint16_t count;
uint8_t b;
- __pdata uint8_t i;
+ uint8_t i;
- ao_cmd_hex();
- count = ao_cmd_lex_i;
+ count = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
if (count > AO_MAX_SEND - 2) {
@@ -47,7 +46,7 @@ ao_send_packet(void)
ao_radio_send(ao_send, count);
}
-static __code struct ao_cmds ao_send_packet_cmds[] = {
+static const struct ao_cmds ao_send_packet_cmds[] = {
{ ao_send_packet, "S <len>\0Send packet. Data on next line" },
{ 0, NULL }
};
diff --git a/src/kernel/ao_serial.h b/src/kernel/ao_serial.h
index ef3e93d7..440b562b 100644
--- a/src/kernel/ao_serial.h
+++ b/src/kernel/ao_serial.h
@@ -26,8 +26,8 @@
#define AO_SERIAL_SPEED_115200 4
#if HAS_SERIAL_0
-extern volatile __xdata struct ao_fifo ao_serial0_rx_fifo;
-extern volatile __xdata struct ao_fifo ao_serial0_tx_fifo;
+extern volatile struct ao_fifo ao_serial0_rx_fifo;
+extern volatile struct ao_fifo ao_serial0_tx_fifo;
char
ao_serial0_getchar(void);
@@ -49,8 +49,8 @@ ao_serial0_set_speed(uint8_t speed);
#endif
#if HAS_SERIAL_1
-extern volatile __xdata struct ao_fifo ao_serial1_rx_fifo;
-extern volatile __xdata struct ao_fifo ao_serial1_tx_fifo;
+extern volatile struct ao_fifo ao_serial1_rx_fifo;
+extern volatile struct ao_fifo ao_serial1_tx_fifo;
char
ao_serial1_getchar(void);
@@ -72,8 +72,8 @@ ao_serial1_set_speed(uint8_t speed);
#endif
#if HAS_SERIAL_2
-extern volatile __xdata struct ao_fifo ao_serial2_rx_fifo;
-extern volatile __xdata struct ao_fifo ao_serial2_tx_fifo;
+extern volatile struct ao_fifo ao_serial2_rx_fifo;
+extern volatile struct ao_fifo ao_serial2_tx_fifo;
char
ao_serial2_getchar(void);
@@ -95,8 +95,8 @@ ao_serial2_set_speed(uint8_t speed);
#endif
#if HAS_SERIAL_3
-extern volatile __xdata struct ao_fifo ao_serial3_rx_fifo;
-extern volatile __xdata struct ao_fifo ao_serial3_tx_fifo;
+extern volatile struct ao_fifo ao_serial3_rx_fifo;
+extern volatile struct ao_fifo ao_serial3_tx_fifo;
char
ao_serial3_getchar(void);
diff --git a/src/kernel/ao_stdio.c b/src/kernel/ao_stdio.c
index dc09b5c7..c3b51d12 100644
--- a/src/kernel/ao_stdio.c
+++ b/src/kernel/ao_stdio.c
@@ -72,18 +72,18 @@
#define AO_NUM_STDIOS (HAS_USB + PACKET_HAS_SLAVE + USE_SERIAL_STDIN + CONSOLE_STDIN)
-__xdata struct ao_stdio ao_stdios[AO_NUM_STDIOS];
+struct ao_stdio ao_stdios[AO_NUM_STDIOS];
#if AO_NUM_STDIOS > 1
-__pdata int8_t ao_cur_stdio;
-__pdata int8_t ao_num_stdios;
+int8_t ao_cur_stdio;
+int8_t ao_num_stdios;
#else
-__pdata int8_t ao_cur_stdio;
+int8_t ao_cur_stdio;
#define ao_cur_stdio 0
#define ao_num_stdios 0
#endif
-void
+int
ao_putchar(char c)
{
#if LOW_LEVEL_DEBUG
@@ -92,12 +92,13 @@ ao_putchar(char c)
if (c == '\n')
ao_debug_out('\r');
ao_debug_out(c);
- return;
+ return 0;
}
#endif
if (c == '\n')
(*ao_stdios[ao_cur_stdio].putchar)('\r');
(*ao_stdios[ao_cur_stdio].putchar)(c);
+ return 0;
}
void
@@ -107,10 +108,10 @@ flush(void)
ao_stdios[ao_cur_stdio].flush();
}
-__xdata uint8_t ao_stdin_ready;
+uint8_t ao_stdin_ready;
char
-ao_getchar(void) __reentrant
+ao_getchar(void)
{
int c;
int8_t stdio;
@@ -144,7 +145,7 @@ ao_echo(void)
int8_t
ao_add_stdio(int (*_pollchar)(void),
void (*putchar)(char),
- void (*flush)(void)) __reentrant
+ void (*flush)(void))
{
if (ao_num_stdios == AO_NUM_STDIOS)
ao_panic(AO_PANIC_STDIO);
@@ -158,3 +159,33 @@ ao_add_stdio(int (*_pollchar)(void),
return 0;
#endif
}
+
+/*
+ * Basic I/O functions to support newlib tinystdio package
+ */
+
+static int
+ao_putc(char c, FILE *ignore)
+{
+ (void) ignore;
+ return ao_putchar(c);
+}
+
+static int
+ao_getc(FILE *ignore)
+{
+ (void) ignore;
+ return ao_getchar();
+}
+
+static int
+ao_flushc(FILE *ignore)
+{
+ (void) ignore;
+ flush();
+ return 0;
+}
+
+static FILE __stdio = FDEV_SETUP_STREAM(ao_putc, ao_getc, ao_flushc, _FDEV_SETUP_RW);
+
+FILE *const __iob[3] = { &__stdio, &__stdio, &__stdio };
diff --git a/src/kernel/ao_storage.c b/src/kernel/ao_storage.c
index 400751de..890bdcae 100644
--- a/src/kernel/ao_storage.c
+++ b/src/kernel/ao_storage.c
@@ -20,7 +20,7 @@
#include <ao_storage.h>
uint8_t
-ao_storage_read(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant
+ao_storage_read(ao_pos_t pos, void *buf, uint16_t len)
{
#ifdef CC1111
return ao_storage_device_read(pos, buf, len);
@@ -54,7 +54,7 @@ ao_storage_read(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant
}
uint8_t
-ao_storage_write(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant
+ao_storage_write(ao_pos_t pos, void *buf, uint16_t len)
{
#ifdef CC1111
return ao_storage_device_write(pos, buf, len);
@@ -87,20 +87,21 @@ ao_storage_write(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant
#endif
}
-static __xdata uint8_t storage_data[128];
+static uint8_t storage_data[128];
static void
-ao_storage_dump(void) __reentrant
+ao_storage_dump(void)
{
+ uint32_t block;
uint8_t i, j;
- ao_cmd_hex();
+ block = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
for (i = 0; ; i += 8) {
- if (ao_storage_read(((uint32_t) (ao_cmd_lex_i) << 8) + i,
- storage_data,
- 8)) {
+ if (ao_storage_read((block << 8) + i,
+ storage_data,
+ 8)) {
ao_cmd_put16((uint16_t) i);
for (j = 0; j < 8; j++) {
putchar(' ');
@@ -118,28 +119,24 @@ ao_storage_dump(void) __reentrant
/* not enough space for this today
*/
static void
-ao_storage_store(void) __reentrant
+ao_storage_store(void)
{
uint16_t block;
uint8_t i;
uint16_t len;
- static __xdata uint8_t b;
+ uint8_t b;
uint32_t addr;
- ao_cmd_hex();
- block = ao_cmd_lex_i;
- ao_cmd_hex();
- i = ao_cmd_lex_i;
+ block = ao_cmd_hex();
+ i = ao_cmd_hex();
addr = ((uint32_t) block << 8) | i;
- ao_cmd_hex();
- len = ao_cmd_lex_i;
+ len = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
while (len--) {
- ao_cmd_hex();
+ b = ao_cmd_hexbyte();
if (ao_cmd_status != ao_cmd_success)
return;
- b = ao_cmd_lex_i;
ao_storage_write(addr, &b, 1);
addr++;
}
@@ -147,16 +144,16 @@ ao_storage_store(void) __reentrant
#endif
void
-ao_storage_zap(void) __reentrant
+ao_storage_zap(void)
{
- ao_cmd_hex();
+ uint32_t v = ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success)
return;
- ao_storage_erase((uint32_t) ao_cmd_lex_i << 8);
+ ao_storage_erase((uint32_t) v << 8);
}
void
-ao_storage_zapall(void) __reentrant
+ao_storage_zapall(void)
{
uint32_t pos;
@@ -272,7 +269,7 @@ ao_storage_incr_check_block(uint32_t pos)
}
static uint8_t
-ao_storage_test_block(uint32_t pos) __reentrant
+ao_storage_test_block(uint32_t pos)
{
ao_storage_erase(pos);
printf(" erase"); flush();
@@ -299,7 +296,7 @@ ao_storage_test_block(uint32_t pos) __reentrant
}
static void
-ao_storage_test(void) __reentrant
+ao_storage_test(void)
{
uint32_t pos;
@@ -316,7 +313,7 @@ ao_storage_test(void) __reentrant
#endif /* AO_STORAGE_TEST */
void
-ao_storage_info(void) __reentrant
+ao_storage_info(void)
{
ao_storage_setup();
printf("Storage size: %ld\n", (long) ao_storage_total);
@@ -324,7 +321,7 @@ ao_storage_info(void) __reentrant
ao_storage_device_info();
}
-__code struct ao_cmds ao_storage_cmds[] = {
+const struct ao_cmds ao_storage_cmds[] = {
{ ao_storage_info, "f\0Show storage" },
{ ao_storage_dump, "e <block>\0Dump flash" },
#if HAS_STORAGE_DEBUG
diff --git a/src/kernel/ao_storage.h b/src/kernel/ao_storage.h
index 59b137ad..cf37a824 100644
--- a/src/kernel/ao_storage.h
+++ b/src/kernel/ao_storage.h
@@ -31,10 +31,10 @@
typedef ao_storage_pos_t ao_pos_t;
/* Total bytes of available storage */
-extern __pdata ao_pos_t ao_storage_total;
+extern ao_pos_t ao_storage_total;
/* Block size - device is erased in these units. At least 256 bytes */
-extern __pdata ao_pos_t ao_storage_block;
+extern ao_pos_t ao_storage_block;
#ifndef USE_STORAGE_CONFIG
#define USE_STORAGE_CONFIG 1
@@ -42,7 +42,7 @@ extern __pdata ao_pos_t ao_storage_block;
#if USE_STORAGE_CONFIG
/* Byte offset of config block. Will be ao_storage_block bytes long */
-extern __pdata ao_pos_t ao_storage_config;
+extern ao_pos_t ao_storage_config;
#define ao_storage_log_max ao_storage_config
#else
@@ -50,27 +50,27 @@ extern __pdata ao_pos_t ao_storage_config;
#endif
/* Storage unit size - device reads and writes must be within blocks of this size. Usually 256 bytes. */
-extern __pdata uint16_t ao_storage_unit;
+extern uint16_t ao_storage_unit;
/* Initialize above values. Can only be called once the OS is running */
void
-ao_storage_setup(void) __reentrant;
+ao_storage_setup(void);
/* Write data. Returns 0 on failure, 1 on success */
uint8_t
-ao_storage_write(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant;
+ao_storage_write(ao_pos_t pos, void *buf, uint16_t len);
/* Read data. Returns 0 on failure, 1 on success */
uint8_t
-ao_storage_read(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant;
+ao_storage_read(ao_pos_t pos, void *buf, uint16_t len);
/* Erase a block of storage. This always clears ao_storage_block bytes */
uint8_t
-ao_storage_erase(ao_pos_t pos) __reentrant;
+ao_storage_erase(ao_pos_t pos);
/* Flush any pending writes to stable storage */
void
-ao_storage_flush(void) __reentrant;
+ao_storage_flush(void);
/* Initialize the storage code */
void
@@ -82,11 +82,11 @@ ao_storage_init(void);
/* Read data within a storage unit */
uint8_t
-ao_storage_device_read(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant;
+ao_storage_device_read(ao_pos_t pos, void *buf, uint16_t len);
/* Write data within a storage unit */
uint8_t
-ao_storage_device_write(ao_pos_t pos, __xdata void *buf, uint16_t len) __reentrant;
+ao_storage_device_write(ao_pos_t pos, void *buf, uint16_t len);
/* Initialize low-level device bits */
void
@@ -94,6 +94,6 @@ ao_storage_device_init(void);
/* Print out information about flash chips */
void
-ao_storage_device_info(void) __reentrant;
+ao_storage_device_info(void);
#endif /* _AO_STORAGE_H_ */
diff --git a/src/kernel/ao_task.c b/src/kernel/ao_task.c
index de23ea02..dc5c1913 100644
--- a/src/kernel/ao_task.c
+++ b/src/kernel/ao_task.c
@@ -29,12 +29,12 @@
#define AO_NO_TASK_INDEX 0xff
-__xdata struct ao_task * __xdata ao_tasks[AO_NUM_TASKS];
-__data uint8_t ao_num_tasks;
-__xdata struct ao_task *__data ao_cur_task;
+struct ao_task * ao_tasks[AO_NUM_TASKS];
+uint8_t ao_num_tasks;
+struct ao_task *ao_cur_task;
#if !HAS_TASK_QUEUE
-static __data uint8_t ao_cur_task_index;
+static uint8_t ao_cur_task_index;
#endif
#ifdef ao_arch_task_globals
@@ -290,7 +290,7 @@ ao_task_validate(void)
#endif /* HAS_TASK_QUEUE */
void
-ao_add_task(__xdata struct ao_task * task, void (*start)(void), __code char *name) __reentrant
+ao_add_task(struct ao_task * task, void (*start)(void), const char *name)
{
uint8_t task_id;
uint8_t t;
@@ -321,7 +321,7 @@ ao_add_task(__xdata struct ao_task * task, void (*start)(void), __code char *nam
);
}
-__data uint8_t ao_task_minimize_latency;
+uint8_t ao_task_minimize_latency;
/* Task switching function. This must not use any stack variables */
void
@@ -382,7 +382,7 @@ ao_yield(void) ao_arch_naked_define
ao_cur_task = ao_list_first_entry(&run_queue, struct ao_task, queue);
#else
{
- __pdata uint8_t ao_last_task_index = ao_cur_task_index;
+ uint8_t ao_last_task_index = ao_cur_task_index;
for (;;) {
++ao_cur_task_index;
if (ao_cur_task_index == ao_num_tasks)
@@ -418,7 +418,7 @@ ao_yield(void) ao_arch_naked_define
}
uint8_t
-ao_sleep(__xdata void *wchan)
+ao_sleep(void *wchan)
{
#if HAS_TASK_QUEUE
uint32_t flags;
@@ -439,7 +439,7 @@ ao_sleep(__xdata void *wchan)
}
void
-ao_wakeup(__xdata void *wchan) __reentrant
+ao_wakeup(void *wchan)
{
ao_validate_cur_stack();
#if HAS_TASK_QUEUE
@@ -470,7 +470,7 @@ ao_wakeup(__xdata void *wchan) __reentrant
}
uint8_t
-ao_sleep_for(__xdata void *wchan, uint16_t timeout)
+ao_sleep_for(void *wchan, uint16_t timeout)
{
uint8_t ret;
if (timeout) {
@@ -504,7 +504,7 @@ ao_sleep_for(__xdata void *wchan, uint16_t timeout)
return ret;
}
-static __xdata uint8_t ao_forever;
+static uint8_t ao_forever;
void
ao_delay(uint16_t ticks)
@@ -541,7 +541,7 @@ void
ao_task_info(void)
{
uint8_t i;
- __xdata struct ao_task *task;
+ struct ao_task *task;
uint16_t now = ao_time();
for (i = 0; i < ao_num_tasks; i++) {
@@ -569,4 +569,5 @@ ao_start_scheduler(void)
ao_arch_start_scheduler();
#endif
ao_yield();
+ __builtin_unreachable();
}
diff --git a/src/kernel/ao_task.h b/src/kernel/ao_task.h
index 7549b598..709e10c6 100644
--- a/src/kernel/ao_task.h
+++ b/src/kernel/ao_task.h
@@ -27,23 +27,21 @@
#endif
/* arm stacks must be 32-bit aligned */
+#ifndef AO_STACK_ALIGNMENT
#ifdef __arm__
#define AO_STACK_ALIGNMENT __attribute__ ((aligned(4)))
-#endif
-#ifdef SDCC
+#else
#define AO_STACK_ALIGNMENT
#endif
-#ifdef __AVR__
-#define AO_STACK_ALIGNMENT
#endif
/* An AltOS task */
struct ao_task {
- __xdata void *wchan; /* current wait channel (NULL if running) */
+ void *wchan; /* current wait channel (NULL if running) */
uint16_t alarm; /* abort ao_sleep time */
ao_arch_task_members /* any architecture-specific fields */
uint8_t task_id; /* unique id */
- __code char *name; /* task name */
+ const char *name; /* task name */
#ifdef NEWLIB
int __errno; /* storage for errno in newlib libc */
#endif
@@ -66,10 +64,10 @@ struct ao_task {
#define AO_NO_TASK 0 /* no task id */
-extern __xdata struct ao_task * __xdata ao_tasks[AO_NUM_TASKS];
-extern __data uint8_t ao_num_tasks;
-extern __xdata struct ao_task *__data ao_cur_task;
-extern __data uint8_t ao_task_minimize_latency; /* Reduce IRQ latency */
+extern struct ao_task * ao_tasks[AO_NUM_TASKS];
+extern uint8_t ao_num_tasks;
+extern struct ao_task *ao_cur_task;
+extern uint8_t ao_task_minimize_latency; /* Reduce IRQ latency */
#ifndef HAS_ARCH_VALIDATE_CUR_STACK
#define ao_validate_cur_stack()
@@ -85,7 +83,7 @@ extern __data uint8_t ao_task_minimize_latency; /* Reduce IRQ latency */
* 1 on alarm
*/
uint8_t
-ao_sleep(__xdata void *wchan);
+ao_sleep(void *wchan);
/* Suspend the current task until wchan is awoken or the timeout
* expires. returns:
@@ -93,11 +91,11 @@ ao_sleep(__xdata void *wchan);
* 1 on alarm
*/
uint8_t
-ao_sleep_for(__xdata void *wchan, uint16_t timeout);
+ao_sleep_for(void *wchan, uint16_t timeout);
/* Wake all tasks sleeping on wchan */
void
-ao_wakeup(__xdata void *wchan) __reentrant;
+ao_wakeup(void *wchan);
#if 0
/* set an alarm to go off in 'delay' ticks */
@@ -115,7 +113,7 @@ ao_yield(void) ao_arch_naked_declare;
/* Add a task to the run queue */
void
-ao_add_task(__xdata struct ao_task * task, void (*start)(void), __code char *name) __reentrant;
+ao_add_task(struct ao_task * task, void (*start)(void), const char *name);
#if HAS_TASK_QUEUE
/* Called on timer interrupt to check alarms */
@@ -134,7 +132,7 @@ ao_task_info(void);
/* Start the scheduler. This will not return */
void
-ao_start_scheduler(void);
+ao_start_scheduler(void) __attribute__((noreturn));
#if HAS_TASK_QUEUE
void
diff --git a/src/kernel/ao_telemetry.c b/src/kernel/ao_telemetry.c
index 9ed612ce..9e1304f7 100644
--- a/src/kernel/ao_telemetry.c
+++ b/src/kernel/ao_telemetry.c
@@ -20,10 +20,10 @@
#include "ao_log.h"
#include "ao_product.h"
-static __pdata uint16_t ao_telemetry_interval;
+static uint16_t ao_telemetry_interval;
#if HAS_RADIO_RATE
-static __xdata uint16_t ao_telemetry_desired_interval;
+static uint16_t ao_telemetry_desired_interval;
#endif
/* TeleMetrum v1.0 just doesn't have enough space to
@@ -37,10 +37,10 @@ static __xdata uint16_t ao_telemetry_desired_interval;
#ifdef SIMPLIFY
#define ao_telemetry_time time
-#define RDF_SPACE __pdata
+#define RDF_SPACE
#else
-#define RDF_SPACE __xdata
-static __pdata uint16_t ao_telemetry_time;
+#define RDF_SPACE
+static uint16_t ao_telemetry_time;
#endif
#if HAS_RDF
@@ -49,7 +49,7 @@ static RDF_SPACE uint16_t ao_rdf_time;
#endif
#if HAS_APRS
-static __pdata uint16_t ao_aprs_time;
+static uint16_t ao_aprs_time;
#include <ao_aprs.h>
#endif
@@ -74,7 +74,7 @@ static __pdata uint16_t ao_aprs_time;
#define AO_TELEMETRY_SENSOR AO_TELEMETRY_SENSOR_TELENANO
#endif
-static __xdata union ao_telemetry_all telemetry;
+static union ao_telemetry_all telemetry;
static void
ao_telemetry_send(void)
@@ -88,7 +88,7 @@ ao_telemetry_send(void)
static void
ao_send_sensor(void)
{
- __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
+ struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
telemetry.generic.tick = packet->tick;
telemetry.generic.type = AO_TELEMETRY_SENSOR;
@@ -136,7 +136,7 @@ ao_send_sensor(void)
static void
ao_send_mega_sensor(void)
{
- __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
+ struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
telemetry.generic.tick = packet->tick;
telemetry.generic.type = AO_TELEMETRY_MEGA_SENSOR;
@@ -181,15 +181,15 @@ ao_send_mega_sensor(void)
ao_telemetry_send();
}
-static __pdata int8_t ao_telemetry_mega_data_max;
-static __pdata int8_t ao_telemetry_mega_data_cur;
+static int8_t ao_telemetry_mega_data_max;
+static int8_t ao_telemetry_mega_data_cur;
/* Send mega data packet */
static void
ao_send_mega_data(void)
{
if (--ao_telemetry_mega_data_cur <= 0) {
- __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
+ struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
uint8_t i;
telemetry.generic.tick = packet->tick;
@@ -223,7 +223,7 @@ ao_send_mega_data(void)
static void
ao_send_metrum_sensor(void)
{
- __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
+ struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
telemetry.generic.tick = packet->tick;
telemetry.generic.type = AO_TELEMETRY_METRUM_SENSOR;
@@ -246,15 +246,15 @@ ao_send_metrum_sensor(void)
ao_telemetry_send();
}
-static __pdata int8_t ao_telemetry_metrum_data_max;
-static __pdata int8_t ao_telemetry_metrum_data_cur;
+static int8_t ao_telemetry_metrum_data_max;
+static int8_t ao_telemetry_metrum_data_cur;
/* Send telemetrum data packet */
static void
ao_send_metrum_data(void)
{
if (--ao_telemetry_metrum_data_cur <= 0) {
- __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
+ struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
telemetry.generic.tick = packet->tick;
telemetry.generic.type = AO_TELEMETRY_METRUM_DATA;
@@ -281,7 +281,7 @@ ao_send_metrum_data(void)
static void
ao_send_mini(void)
{
- __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
+ struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
telemetry.generic.tick = packet->tick;
telemetry.generic.type = AO_SEND_MINI;
@@ -306,9 +306,9 @@ ao_send_mini(void)
#endif /* AO_SEND_MINI */
-static __pdata int8_t ao_telemetry_config_max;
-static __pdata int8_t ao_telemetry_config_cur;
-static __pdata uint16_t ao_telemetry_flight_number;
+static int8_t ao_telemetry_config_max;
+static int8_t ao_telemetry_config_cur;
+static uint16_t ao_telemetry_flight_number;
#ifndef ao_telemetry_battery_convert
#define ao_telemetry_battery_convert(a) (a)
@@ -337,7 +337,7 @@ ao_send_configuration(void)
ao_config.callsign,
AO_MAX_CALLSIGN);
ao_xmemcpy (telemetry.configuration.version,
- CODE_TO_XDATA(ao_version),
+ ao_version,
AO_MAX_VERSION);
ao_telemetry_config_cur = ao_telemetry_config_max;
ao_telemetry_send();
@@ -346,9 +346,9 @@ ao_send_configuration(void)
#if HAS_GPS
-static __pdata int8_t ao_telemetry_gps_max;
-static __pdata int8_t ao_telemetry_loc_cur;
-static __pdata int8_t ao_telemetry_sat_cur;
+static int8_t ao_telemetry_gps_max;
+static int8_t ao_telemetry_loc_cur;
+static int8_t ao_telemetry_sat_cur;
static void
ao_send_location(void)
@@ -387,8 +387,8 @@ ao_send_satellite(void)
#if HAS_COMPANION
-static __pdata int8_t ao_telemetry_companion_max;
-static __pdata int8_t ao_telemetry_companion_cur;
+static int8_t ao_telemetry_companion_max;
+static int8_t ao_telemetry_companion_cur;
static void
ao_send_companion(void)
@@ -536,7 +536,7 @@ ao_telemetry_set_interval(uint16_t interval)
#if HAS_RADIO_RATE
/* Limit max telemetry rate based on available radio bandwidth.
*/
- static __xdata const uint16_t min_interval[] = {
+ static const uint16_t min_interval[] = {
/* [AO_RADIO_RATE_38400] = */ AO_MS_TO_TICKS(100),
/* [AO_RADIO_RATE_9600] = */ AO_MS_TO_TICKS(500),
/* [AO_RADIO_RATE_2400] = */ AO_MS_TO_TICKS(1000)
@@ -613,7 +613,7 @@ ao_rdf_set(uint8_t rdf)
}
#endif
-__xdata struct ao_task ao_telemetry_task;
+struct ao_task ao_telemetry_task;
void
ao_telemetry_init()
diff --git a/src/kernel/ao_tracker.c b/src/kernel/ao_tracker.c
index 46278530..1454c17c 100644
--- a/src/kernel/ao_tracker.c
+++ b/src/kernel/ao_tracker.c
@@ -30,7 +30,7 @@ static uint8_t ao_tracker_force_telem;
static inline uint8_t
ao_usb_connected(void)
{
- return ao_gpio_get(AO_USB_CONNECT_PORT, AO_USB_CONNECT_PIN, AO_USB_CONNECT) != 0;
+ return ao_gpio_get(AO_USB_CONNECT_PORT, AO_USB_CONNECT_PIN) != 0;
}
#else
#define ao_usb_connected() 1
@@ -211,9 +211,9 @@ static struct ao_task ao_tracker_task;
static void
ao_tracker_set_telem(void)
{
- ao_cmd_hex();
+ uint16_t r = ao_cmd_hex();
if (ao_cmd_status == ao_cmd_success)
- ao_tracker_force_telem = ao_cmd_lex_i;
+ ao_tracker_force_telem = r;
ao_cmd_status = ao_cmd_success;
printf ("flight: %d\n", ao_flight_number);
printf ("force_telem: %d\n", ao_tracker_force_telem);
diff --git a/src/kernel/ao_usb.h b/src/kernel/ao_usb.h
index 40516de1..6c74a042 100644
--- a/src/kernel/ao_usb.h
+++ b/src/kernel/ao_usb.h
@@ -69,7 +69,7 @@ ao_usb_disable(void);
void
ao_usb_init(void);
-extern __code __at (0x00aa) uint8_t ao_usb_descriptors [];
+extern const uint8_t ao_usb_descriptors [];
#define AO_USB_SETUP_DIR_MASK (0x01 << 7)
#define AO_USB_SETUP_TYPE_MASK (0x03 << 5)
@@ -176,8 +176,8 @@ struct ao_usb_line_coding {
uint8_t data_bits;
} ;
-extern __xdata struct ao_usb_line_coding ao_usb_line_coding;
+extern struct ao_usb_line_coding ao_usb_line_coding;
-extern __pdata uint8_t ao_usb_running;
+extern uint8_t ao_usb_running;
#endif /* _AO_USB_H_ */
diff --git a/src/lambdakey-v1.0/Makefile b/src/lambdakey-v1.0/Makefile
index 33c68cf5..f8b5c7f5 100644
--- a/src/lambdakey-v1.0/Makefile
+++ b/src/lambdakey-v1.0/Makefile
@@ -9,10 +9,6 @@ aoschemelib=$(shell pkg-config --variable=aoschemelib ao-scheme)
include $(aoschemelib)/Makefile-scheme
-NEWLIB_FULL=-lm -lc -lgcc
-
-LIBS=$(NEWLIB_FULL)
-
INC = \
ao.h \
ao_arch.h \
@@ -31,10 +27,9 @@ ALTOS_SRC = \
ao_interrupt.c \
ao_product.c \
ao_cmd.c \
- ao_led.c \
+ ao_led_stmf0.c \
ao_notask.c \
ao_stdio.c \
- ao_stdio_newlib.c \
ao_panic.c \
ao_timer.c \
ao_usb_stm.c \
@@ -45,15 +40,7 @@ PRODUCT=LambdaKey-v1.0
PRODUCT_DEF=-DLAMBDAKEY
IDPRODUCT=0x000a
-CFLAGS = $(PRODUCT_DEF) -I. $(STMF0_CFLAGS) -Os -g
-
-LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stmf0 -Wl,-Tlambda.ld
-
-MAP=$(PROG).map
-NEWLIB=/local/newlib-mini
-MAPFILE=-Wl,-Map=$(MAP)
-LDFLAGS=-L../stmf0 -L$(NEWLIB)/arm-none-eabi/lib/thumb/v6-m/ -Wl,-Tlambda.ld $(MAPFILE) -nostartfiles
-AO_CFLAGS=-I. -I../stmf0 -I../kernel -I../drivers -I.. -I$(aoschemelib) -isystem $(NEWLIB)/arm-none-eabi/include -DNEWLIB
+CFLAGS = $(PRODUCT_DEF) -I. -I$(aoschemelib) $(STMF0_CFLAGS) -Os -g
PROGNAME=lambdakey-v1.0
PROG=$(PROGNAME)-$(VERSION).elf
@@ -67,7 +54,7 @@ bletch:
all: $(PROG) $(HEX)
-$(PROG): Makefile $(OBJ) lambda.ld
+$(PROG): Makefile $(OBJ)
$(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS)
$(OBJ): $(INC)
diff --git a/src/lambdakey-v1.0/ao_lambdakey.c b/src/lambdakey-v1.0/ao_lambdakey.c
index f1a2aa38..a608d8e4 100644
--- a/src/lambdakey-v1.0/ao_lambdakey.c
+++ b/src/lambdakey-v1.0/ao_lambdakey.c
@@ -24,6 +24,21 @@ static const struct ao_cmds blink_cmds[] = {
{ 0, 0 }
};
+int
+_ao_scheme_getc(void)
+{
+ static uint8_t at_eol;
+ int c;
+
+ if (at_eol) {
+ ao_cmd_readline(ao_scheme_read_list ? "Λ " : "λ ");
+ at_eol = 0;
+ }
+ c = (unsigned char) ao_cmd_lex();
+ if (c == '\n')
+ at_eol = 1;
+ return c;
+}
void main(void)
{
diff --git a/src/lambdakey-v1.0/ao_pins.h b/src/lambdakey-v1.0/ao_pins.h
index 58a75080..92ed24ee 100644
--- a/src/lambdakey-v1.0/ao_pins.h
+++ b/src/lambdakey-v1.0/ao_pins.h
@@ -19,14 +19,6 @@
#ifndef _AO_PINS_H_
#define _AO_PINS_H_
-#define fprintf(file, ...) ({ (void) (file); printf(__VA_ARGS__); })
-#undef putc
-#define putc(c,file) ({ (void) (file); putchar(c); })
-#define fputs(s,file) ({ (void) (file); ao_put_string(s); })
-#undef getc
-#define getc(file) ({ (void) (file); getchar(); })
-#define fflush(file) ({ (void) (file); flush(); })
-
#define HAS_TASK 0
#define HAS_AO_DELAY 1
diff --git a/src/lambdakey-v1.0/ao_scheme_os.h b/src/lambdakey-v1.0/ao_scheme_os.h
index 8af199c2..41357552 100644
--- a/src/lambdakey-v1.0/ao_scheme_os.h
+++ b/src/lambdakey-v1.0/ao_scheme_os.h
@@ -19,6 +19,7 @@
#define _AO_SCHEME_OS_H_
#include "ao.h"
+#include "ao_scheme.h"
#define AO_SCHEME_POOL 3792
#define AO_SCHEME_TOKEN_MAX 64
@@ -29,22 +30,13 @@
#define __BYTE_ORDER __LITTLE_ENDIAN
#endif
-static inline int
-_ao_scheme_getc() {
- static uint8_t at_eol;
- int c;
-
- if (at_eol) {
- ao_cmd_readline();
- at_eol = 0;
- }
- c = ao_cmd_lex();
- if (c == '\n')
- at_eol = 1;
- return c;
-}
+extern int _ao_scheme_getc(void);
#define ao_scheme_getc(f) ({ (void) (f); _ao_scheme_getc(); })
+#undef putc
+#define putc(c, f) ({ (void) (f); ao_putchar(c); })
+#define fputs(s, f) ({ (void) (f); ao_put_string(s); })
+#define fiprintf(f, ...) ({ (void) (f); iprintf(__VA_ARGS__); })
static inline void
ao_scheme_abort(void)
diff --git a/src/lpc/Makefile-lpc.defs b/src/lpc/Makefile-lpc.defs
index c4521620..edeedaf0 100644
--- a/src/lpc/Makefile-lpc.defs
+++ b/src/lpc/Makefile-lpc.defs
@@ -29,15 +29,16 @@ CC=$(ARM_CC)
WARN_FLAGS=-Wall -Wextra -Werror -Wcast-align
AO_CFLAGS=-I. -I$(TOPDIR)/lpc -I$(TOPDIR)/kernel -I$(TOPDIR)/drivers \
+ -DNEWLIB_INTEGER_PRINTF_SCANF \
-I$(TOPDIR)/product -I$(TOPDIR) -I$(TOPDIR)/math -I$(TOPDIR) \
- $(PDCLIB_INCLUDES)
+ -isystem $(NEWLIB_NANO)/arm-none-eabi/include
LPC_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/lpc/altos-loader.ld b/src/lpc/altos-loader.ld
index 84d7610c..be4f115d 100644
--- a/src/lpc/altos-loader.ld
+++ b/src/lpc/altos-loader.ld
@@ -61,9 +61,9 @@ SECTIONS {
/* Data -- relocated to RAM, but written to ROM
*/
.data : {
- __data_start__ = .;
+ _start__ = .;
*(.data*) /* initialized data */
- __data_end__ = .;
+ _end__ = .;
} >ram AT>rom
diff --git a/src/lpc/altos-standalone.ld b/src/lpc/altos-standalone.ld
index db53dcaf..99d10149 100644
--- a/src/lpc/altos-standalone.ld
+++ b/src/lpc/altos-standalone.ld
@@ -65,9 +65,9 @@ SECTIONS {
/* Data -- relocated to RAM, but written to ROM
*/
.data ORIGIN(ram) : AT (ADDR(.ARM.exidx) + SIZEOF (.ARM.exidx)) {
- __data_start__ = .;
+ _start__ = .;
*(.data) /* initialized data */
- __data_end__ = .;
+ _end__ = .;
__bss_start__ = .;
} >ram
diff --git a/src/lpc/altos.ld b/src/lpc/altos.ld
index e6a6a7ed..028ad775 100644
--- a/src/lpc/altos.ld
+++ b/src/lpc/altos.ld
@@ -69,9 +69,9 @@ SECTIONS {
/* Data -- relocated to RAM, but written to ROM
*/
.data : AT (ADDR(.ARM.exidx) + SIZEOF (.ARM.exidx)) {
- __data_start__ = .;
+ _start__ = .;
*(.data) /* initialized data */
- __data_end__ = .;
+ _end__ = .;
__bss_start__ = .;
} >ram
diff --git a/src/lpc/ao_adc_lpc.c b/src/lpc/ao_adc_lpc.c
index 26a5ea08..63241559 100644
--- a/src/lpc/ao_adc_lpc.c
+++ b/src/lpc/ao_adc_lpc.c
@@ -112,23 +112,7 @@ void lpc_adc_isr(void)
}
AO_DATA_PRESENT(AO_DATA_ADC);
- 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;
}
@@ -147,7 +131,7 @@ ao_adc_poll(void)
}
static void
-ao_adc_dump(void) __reentrant
+ao_adc_dump(void)
{
struct ao_data packet;
#ifndef AO_ADC_DUMP
@@ -167,7 +151,7 @@ ao_adc_dump(void) __reentrant
#endif
}
-__code struct ao_cmds ao_adc_cmds[] = {
+const struct ao_cmds ao_adc_cmds[] = {
{ ao_adc_dump, "a\0Display current ADC values" },
{ 0, NULL },
};
diff --git a/src/lpc/ao_arch.h b/src/lpc/ao_arch.h
index da21dc9d..35dcc9de 100644
--- a/src/lpc/ao_arch.h
+++ b/src/lpc/ao_arch.h
@@ -42,11 +42,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,26 +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);
-
/*
* ao_romconfig.c
*/
-#define AO_ROMCONFIG_VERSION 2
-
-#define AO_ROMCONFIG_SYMBOL(a) __attribute__((section(".romconfig"))) const
-
-extern const uint16_t ao_romconfig_version;
-extern const uint16_t ao_romconfig_check;
-extern const uint16_t ao_serial_number;
-extern const uint32_t ao_radio_cal;
+#define AO_ROMCONFIG_SYMBOL __attribute__((section(".romconfig"))) const
#define ao_arch_task_members\
uint32_t *sp; /* saved stack pointer */
diff --git a/src/lpc/ao_arch_funcs.h b/src/lpc/ao_arch_funcs.h
index 15106dea..0454b38b 100644
--- a/src/lpc/ao_arch_funcs.h
+++ b/src/lpc/ao_arch_funcs.h
@@ -19,17 +19,17 @@
#ifndef _AO_ARCH_FUNCS_H_
#define _AO_ARCH_FUNCS_H_
-#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)
#define ao_enable_port(port) (lpc_scb.sysahbclkctrl |= (1 << LPC_SCB_SYSAHBCLKCTRL_GPIO))
#define ao_disable_port(port) (lpc_scb.sysahbclkctrl &= ~(1 << LPC_SCB_SYSAHBCLKCTRL_GPIO))
#define lpc_all_bit(port,bit) (((port) << 5) | (bit))
-#define ao_gpio_set(port, bit, pin, v) (lpc_gpio.byte[lpc_all_bit(port,bit)] = (v))
+#define ao_gpio_set(port, bit, v) (lpc_gpio.byte[lpc_all_bit(port,bit)] = (v))
-#define ao_gpio_get(port, bit, pin) (lpc_gpio.byte[lpc_all_bit(port,bit)])
+#define ao_gpio_get(port, bit) (lpc_gpio.byte[lpc_all_bit(port,bit)])
#define PORT0_JTAG_REGS ((1 << 11) | (1 << 12) | (1 << 14))
@@ -41,10 +41,10 @@ static inline void lpc_set_gpio(int port, int bit) {
}
}
-#define ao_enable_output(port,bit,pin,v) do { \
+#define ao_enable_output(port,bit,v) do { \
ao_enable_port(port); \
lpc_set_gpio(port,bit); \
- ao_gpio_set(port, bit, pin, v); \
+ ao_gpio_set(port, bit, v); \
lpc_gpio.dir[port] |= (1 << bit); \
} while (0)
@@ -204,8 +204,8 @@ static inline void ao_arch_restore_stack(void) {
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)
void
ao_spi_get(uint8_t spi_index, uint32_t speed);
@@ -254,7 +254,7 @@ static inline void ao_spi_send_byte(uint8_t byte, uint8_t spi_index)
uint8_t __bit__; \
for (__bit__ = 0; __bit__ < 32; __bit__++) { \
if (mask & (1 << __bit__)) \
- ao_enable_output(port, __bit__, PIN, 1); \
+ ao_enable_output(port, __bit__, 1); \
} \
} while (0)
diff --git a/src/lpc/ao_beep_lpc.c b/src/lpc/ao_beep_lpc.c
index b1211752..eab86ee6 100644
--- a/src/lpc/ao_beep_lpc.c
+++ b/src/lpc/ao_beep_lpc.c
@@ -59,7 +59,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);
diff --git a/src/lpc/ao_boot_pin.c b/src/lpc/ao_boot_pin.c
index e3c7d0c1..a51c7f8d 100644
--- a/src/lpc/ao_boot_pin.c
+++ b/src/lpc/ao_boot_pin.c
@@ -36,7 +36,7 @@ ao_boot_check_pin(void)
ao_arch_nop();
/* Read the value */
- v = ao_gpio_get(AO_BOOT_APPLICATION_GPIO, AO_BOOT_APPLICATION_PIN, AO_BOOT_APPLICATION);
+ v = ao_gpio_get(AO_BOOT_APPLICATION_GPIO, AO_BOOT_APPLICATION_PIN);
/* Reset the chip to turn off the port and the power interface clock */
ao_gpio_set_mode(AO_BOOT_APPLICATION_GPIO, AO_BOOT_APPLICATION_PIN, 0);
diff --git a/src/lpc/ao_interrupt.c b/src/lpc/ao_interrupt.c
index 3e0119c6..8d71f43f 100644
--- a/src/lpc/ao_interrupt.c
+++ b/src/lpc/ao_interrupt.c
@@ -32,7 +32,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__;
@@ -61,7 +61,7 @@ void start(void) {
memcpy(&__interrupt_start__, &__interrupt_rom__, &__interrupt_end__ - &__interrupt_start__);
lpc_scb.sysmemremap = LPC_SCB_SYSMEMREMAP_MAP_RAM << LPC_SCB_SYSMEMREMAP_MAP;
#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/lpc/ao_led_lpc.c b/src/lpc/ao_led_lpc.c
index 2d2c3972..3a2d4c98 100644
--- a/src/lpc/ao_led_lpc.c
+++ b/src/lpc/ao_led_lpc.c
@@ -18,7 +18,7 @@
#include <ao.h>
-__pdata AO_PORT_TYPE ao_led_enable;
+AO_PORT_TYPE ao_led_enable;
void
ao_led_on(AO_PORT_TYPE colors)
@@ -35,8 +35,8 @@ ao_led_off(AO_PORT_TYPE colors)
void
ao_led_set(AO_PORT_TYPE colors)
{
- AO_PORT_TYPE on = colors & ao_led_enable;
- AO_PORT_TYPE off = ~colors & ao_led_enable;
+ AO_PORT_TYPE on = colors & LEDS_AVAILABLE;
+ AO_PORT_TYPE off = ~colors & LEDS_AVAILABLE;
ao_led_off(off);
ao_led_on(on);
@@ -49,7 +49,7 @@ ao_led_toggle(AO_PORT_TYPE colors)
}
void
-ao_led_for(AO_PORT_TYPE colors, uint16_t ticks) __reentrant
+ao_led_for(AO_PORT_TYPE colors, uint16_t ticks)
{
ao_led_on(colors);
ao_delay(ticks);
@@ -57,18 +57,17 @@ ao_led_for(AO_PORT_TYPE colors, uint16_t ticks) __reentrant
}
void
-ao_led_init(AO_PORT_TYPE enable)
+ao_led_init(void)
{
- ao_led_enable = enable;
ao_enable_port(LED_PORT);
if (LED_PORT == 0) {
- if (enable & (1 << 11))
+ if (LEDS_AVAILABLE & (1 << 11))
lpc_ioconf.pio0_11 = LPC_IOCONF_FUNC_PIO0_11 | (1 << LPC_IOCONF_ADMODE);
- if (enable & (1 << 12))
+ if (LEDS_AVAILABLE & (1 << 12))
lpc_ioconf.pio0_12 = LPC_IOCONF_FUNC_PIO0_12 | (1 << LPC_IOCONF_ADMODE);
- if (enable & (1 << 14))
+ if (LEDS_AVAILABLE & (1 << 14))
lpc_ioconf.pio0_14 = LPC_IOCONF_FUNC_PIO0_14 | (1 << LPC_IOCONF_ADMODE);
}
- lpc_gpio.dir[LED_PORT] |= enable;
- ao_led_off(enable);
+ lpc_gpio.dir[LED_PORT] |= LEDS_AVAILABLE;
+ ao_led_off(LEDS_AVAILABLE);
}
diff --git a/src/lpc/ao_romconfig.c b/src/lpc/ao_romconfig.c
deleted file mode 100644
index 4e7bab8d..00000000
--- a/src/lpc/ao_romconfig.c
+++ /dev/null
@@ -1,26 +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;
-#ifdef AO_RADIO_CAL_DEFAULT
-AO_ROMCONFIG_SYMBOL (0) uint32_t ao_radio_cal = AO_RADIO_CAL_DEFAULT;
-#endif
diff --git a/src/lpc/ao_timer_lpc.c b/src/lpc/ao_timer_lpc.c
index 166e2f15..8999c7ac 100644
--- a/src/lpc/ao_timer_lpc.c
+++ b/src/lpc/ao_timer_lpc.c
@@ -18,7 +18,7 @@
#include <ao.h>
-volatile __data AO_TICK_TYPE ao_tick_count;
+volatile AO_TICK_TYPE ao_tick_count;
uint16_t
ao_time(void)
@@ -27,8 +27,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 lpc_systick_isr(void)
diff --git a/src/lpc/ao_usb_lpc.c b/src/lpc/ao_usb_lpc.c
index d26a1437..594114b6 100644
--- a/src/lpc/ao_usb_lpc.c
+++ b/src/lpc/ao_usb_lpc.c
@@ -857,7 +857,7 @@ ao_usb_disable(void)
ao_arch_block_interrupts();
#if HAS_USB_PULLUP
- ao_gpio_set(AO_USB_PULLUP_PORT, AO_USB_PULLUP_PIN, AO_USB_PULLUP, 0);
+ ao_gpio_set(AO_USB_PULLUP_PORT, AO_USB_PULLUP_PIN, 0);
#endif
/* Disable interrupts */
lpc_usb.inten = 0;
@@ -975,7 +975,7 @@ ao_usb_enable(void)
ao_usb_set_ep0();
#if HAS_USB_PULLUP
- ao_gpio_set(AO_USB_PULLUP_PORT, AO_USB_PULLUP_PIN, AO_USB_PULLUP, 1);
+ ao_gpio_set(AO_USB_PULLUP_PORT, AO_USB_PULLUP_PIN, 1);
#endif
}
@@ -1003,7 +1003,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 }
};
@@ -1014,7 +1014,7 @@ ao_usb_init(void)
{
#if HAS_USB_PULLUP
int i;
- ao_enable_output(AO_USB_PULLUP_PORT, AO_USB_PULLUP_PIN, AO_USB_PULLUP, 0);
+ ao_enable_output(AO_USB_PULLUP_PORT, AO_USB_PULLUP_PIN, 0);
for (i = 0; i < 40000; i++)
ao_arch_nop();
diff --git a/src/math/ef_acos.c b/src/math/ef_acos.c
deleted file mode 100644
index f73f97de..00000000
--- a/src/math/ef_acos.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* ef_acos.c -- float version of e_acos.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "fdlibm.h"
-
-#ifdef __STDC__
-static const float
-#else
-static float
-#endif
-one = 1.0000000000e+00, /* 0x3F800000 */
-pi = 3.1415925026e+00, /* 0x40490fda */
-pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */
-pio2_lo = 7.5497894159e-08, /* 0x33a22168 */
-pS0 = 1.6666667163e-01, /* 0x3e2aaaab */
-pS1 = -3.2556581497e-01, /* 0xbea6b090 */
-pS2 = 2.0121252537e-01, /* 0x3e4e0aa8 */
-pS3 = -4.0055535734e-02, /* 0xbd241146 */
-pS4 = 7.9153501429e-04, /* 0x3a4f7f04 */
-pS5 = 3.4793309169e-05, /* 0x3811ef08 */
-qS1 = -2.4033949375e+00, /* 0xc019d139 */
-qS2 = 2.0209457874e+00, /* 0x4001572d */
-qS3 = -6.8828397989e-01, /* 0xbf303361 */
-qS4 = 7.7038154006e-02; /* 0x3d9dc62e */
-
-#ifdef __STDC__
- float __ieee754_acosf(float x)
-#else
- float __ieee754_acosf(x)
- float x;
-#endif
-{
- float z,p,q,r,w,s,c,df;
- __int32_t hx,ix;
- GET_FLOAT_WORD(hx,x);
- ix = hx&0x7fffffff;
- if(ix==0x3f800000) { /* |x|==1 */
- if(hx>0) return 0.0; /* acos(1) = 0 */
- else return pi+(float)2.0*pio2_lo; /* acos(-1)= pi */
- } else if(ix>0x3f800000) { /* |x| >= 1 */
- return (x-x)/(x-x); /* acos(|x|>1) is NaN */
- }
- if(ix<0x3f000000) { /* |x| < 0.5 */
- if(ix<=0x23000000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/
- z = x*x;
- p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
- q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
- r = p/q;
- return pio2_hi - (x - (pio2_lo-x*r));
- } else if (hx<0) { /* x < -0.5 */
- z = (one+x)*(float)0.5;
- p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
- q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
- s = __ieee754_sqrtf(z);
- r = p/q;
- w = r*s-pio2_lo;
- return pi - (float)2.0*(s+w);
- } else { /* x > 0.5 */
- __int32_t idf;
- z = (one-x)*(float)0.5;
- s = __ieee754_sqrtf(z);
- df = s;
- GET_FLOAT_WORD(idf,df);
- SET_FLOAT_WORD(df,idf&0xfffff000);
- c = (z-df*df)/(s+df);
- p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
- q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
- r = p/q;
- w = r*s+c;
- return (float)2.0*(df+w);
- }
-}
diff --git a/src/math/ef_log.c b/src/math/ef_log.c
deleted file mode 100644
index 619fe909..00000000
--- a/src/math/ef_log.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ef_log.c -- float version of e_log.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "fdlibm.h"
-
-#ifdef __STDC__
-static const float
-#else
-static float
-#endif
-ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
-ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
-two25 = 3.355443200e+07, /* 0x4c000000 */
-Lg1 = 6.6666668653e-01, /* 3F2AAAAB */
-Lg2 = 4.0000000596e-01, /* 3ECCCCCD */
-Lg3 = 2.8571429849e-01, /* 3E924925 */
-Lg4 = 2.2222198546e-01, /* 3E638E29 */
-Lg5 = 1.8183572590e-01, /* 3E3A3325 */
-Lg6 = 1.5313838422e-01, /* 3E1CD04F */
-Lg7 = 1.4798198640e-01; /* 3E178897 */
-
-#ifdef __STDC__
-static const float zero = 0.0;
-#else
-static float zero = 0.0;
-#endif
-
-#ifdef __STDC__
- float __ieee754_logf(float x)
-#else
- float __ieee754_logf(x)
- float x;
-#endif
-{
- float hfsq,f,s,z,R,w,t1,t2,dk;
- __int32_t k,ix,i,j;
-
- GET_FLOAT_WORD(ix,x);
-
- k=0;
- if (FLT_UWORD_IS_ZERO(ix&0x7fffffff))
- return -two25/zero; /* log(+-0)=-inf */
- if (ix<0) return (x-x)/zero; /* log(-#) = NaN */
- if (!FLT_UWORD_IS_FINITE(ix)) return x+x;
- if (FLT_UWORD_IS_SUBNORMAL(ix)) {
- k -= 25; x *= two25; /* subnormal number, scale up x */
- GET_FLOAT_WORD(ix,x);
- }
- k += (ix>>23)-127;
- ix &= 0x007fffff;
- i = (ix+(0x95f64<<3))&0x800000;
- SET_FLOAT_WORD(x,ix|(i^0x3f800000)); /* normalize x or x/2 */
- k += (i>>23);
- f = x-(float)1.0;
- if((0x007fffff&(15+ix))<16) { /* |f| < 2**-20 */
- if(f==zero) { if(k==0) return zero; else {dk=(float)k;
- return dk*ln2_hi+dk*ln2_lo;}}
- R = f*f*((float)0.5-(float)0.33333333333333333*f);
- if(k==0) return f-R; else {dk=(float)k;
- return dk*ln2_hi-((R-dk*ln2_lo)-f);}
- }
- s = f/((float)2.0+f);
- dk = (float)k;
- z = s*s;
- i = ix-(0x6147a<<3);
- w = z*z;
- j = (0x6b851<<3)-ix;
- t1= w*(Lg2+w*(Lg4+w*Lg6));
- t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
- i |= j;
- R = t2+t1;
- if(i>0) {
- hfsq=(float)0.5*f*f;
- if(k==0) return f-(hfsq-s*(hfsq+R)); else
- return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f);
- } else {
- if(k==0) return f-s*(f-R); else
- return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
- }
-}
diff --git a/src/math/ef_rem_pio2.c b/src/math/ef_rem_pio2.c
deleted file mode 100644
index 3e58f809..00000000
--- a/src/math/ef_rem_pio2.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/* ef_rem_pio2.c -- float version of e_rem_pio2.c
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- */
-
-/* __ieee754_rem_pio2f(x,y)
- *
- * return the remainder of x rem pi/2 in y[0]+y[1]
- * use __kernel_rem_pio2f()
- */
-
-#include "fdlibm.h"
-
-/*
- * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
- */
-#ifdef __STDC__
-static const __int32_t two_over_pi[] = {
-#else
-static __int32_t two_over_pi[] = {
-#endif
-0xA2, 0xF9, 0x83, 0x6E, 0x4E, 0x44, 0x15, 0x29, 0xFC,
-0x27, 0x57, 0xD1, 0xF5, 0x34, 0xDD, 0xC0, 0xDB, 0x62,
-0x95, 0x99, 0x3C, 0x43, 0x90, 0x41, 0xFE, 0x51, 0x63,
-0xAB, 0xDE, 0xBB, 0xC5, 0x61, 0xB7, 0x24, 0x6E, 0x3A,
-0x42, 0x4D, 0xD2, 0xE0, 0x06, 0x49, 0x2E, 0xEA, 0x09,
-0xD1, 0x92, 0x1C, 0xFE, 0x1D, 0xEB, 0x1C, 0xB1, 0x29,
-0xA7, 0x3E, 0xE8, 0x82, 0x35, 0xF5, 0x2E, 0xBB, 0x44,
-0x84, 0xE9, 0x9C, 0x70, 0x26, 0xB4, 0x5F, 0x7E, 0x41,
-0x39, 0x91, 0xD6, 0x39, 0x83, 0x53, 0x39, 0xF4, 0x9C,
-0x84, 0x5F, 0x8B, 0xBD, 0xF9, 0x28, 0x3B, 0x1F, 0xF8,
-0x97, 0xFF, 0xDE, 0x05, 0x98, 0x0F, 0xEF, 0x2F, 0x11,
-0x8B, 0x5A, 0x0A, 0x6D, 0x1F, 0x6D, 0x36, 0x7E, 0xCF,
-0x27, 0xCB, 0x09, 0xB7, 0x4F, 0x46, 0x3F, 0x66, 0x9E,
-0x5F, 0xEA, 0x2D, 0x75, 0x27, 0xBA, 0xC7, 0xEB, 0xE5,
-0xF1, 0x7B, 0x3D, 0x07, 0x39, 0xF7, 0x8A, 0x52, 0x92,
-0xEA, 0x6B, 0xFB, 0x5F, 0xB1, 0x1F, 0x8D, 0x5D, 0x08,
-0x56, 0x03, 0x30, 0x46, 0xFC, 0x7B, 0x6B, 0xAB, 0xF0,
-0xCF, 0xBC, 0x20, 0x9A, 0xF4, 0x36, 0x1D, 0xA9, 0xE3,
-0x91, 0x61, 0x5E, 0xE6, 0x1B, 0x08, 0x65, 0x99, 0x85,
-0x5F, 0x14, 0xA0, 0x68, 0x40, 0x8D, 0xFF, 0xD8, 0x80,
-0x4D, 0x73, 0x27, 0x31, 0x06, 0x06, 0x15, 0x56, 0xCA,
-0x73, 0xA8, 0xC9, 0x60, 0xE2, 0x7B, 0xC0, 0x8C, 0x6B,
-};
-
-/* This array is like the one in e_rem_pio2.c, but the numbers are
- single precision and the last 8 bits are forced to 0. */
-#ifdef __STDC__
-static const __int32_t npio2_hw[] = {
-#else
-static __int32_t npio2_hw[] = {
-#endif
-0x3fc90f00, 0x40490f00, 0x4096cb00, 0x40c90f00, 0x40fb5300, 0x4116cb00,
-0x412fed00, 0x41490f00, 0x41623100, 0x417b5300, 0x418a3a00, 0x4196cb00,
-0x41a35c00, 0x41afed00, 0x41bc7e00, 0x41c90f00, 0x41d5a000, 0x41e23100,
-0x41eec200, 0x41fb5300, 0x4203f200, 0x420a3a00, 0x42108300, 0x4216cb00,
-0x421d1400, 0x42235c00, 0x4229a500, 0x422fed00, 0x42363600, 0x423c7e00,
-0x4242c700, 0x42490f00
-};
-
-/*
- * invpio2: 24 bits of 2/pi
- * pio2_1: first 17 bit of pi/2
- * pio2_1t: pi/2 - pio2_1
- * pio2_2: second 17 bit of pi/2
- * pio2_2t: pi/2 - (pio2_1+pio2_2)
- * pio2_3: third 17 bit of pi/2
- * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3)
- */
-
-#ifdef __STDC__
-static const float
-#else
-static float
-#endif
-zero = 0.0000000000e+00, /* 0x00000000 */
-half = 5.0000000000e-01, /* 0x3f000000 */
-two8 = 2.5600000000e+02, /* 0x43800000 */
-invpio2 = 6.3661980629e-01, /* 0x3f22f984 */
-pio2_1 = 1.5707855225e+00, /* 0x3fc90f80 */
-pio2_1t = 1.0804334124e-05, /* 0x37354443 */
-pio2_2 = 1.0804273188e-05, /* 0x37354400 */
-pio2_2t = 6.0770999344e-11, /* 0x2e85a308 */
-pio2_3 = 6.0770943833e-11, /* 0x2e85a300 */
-pio2_3t = 6.1232342629e-17; /* 0x248d3132 */
-
-#ifdef __STDC__
- __int32_t __ieee754_rem_pio2f(float x, float *y)
-#else
- __int32_t __ieee754_rem_pio2f(x,y)
- float x,y[];
-#endif
-{
- float z,w,t,r,fn;
- float tx[3];
- __int32_t i,j,n,ix,hx;
- int e0,nx;
-
- GET_FLOAT_WORD(hx,x);
- ix = hx&0x7fffffff;
- if(ix<=0x3f490fd8) /* |x| ~<= pi/4 , no need for reduction */
- {y[0] = x; y[1] = 0; return 0;}
- if(ix<0x4016cbe4) { /* |x| < 3pi/4, special case with n=+-1 */
- if(hx>0) {
- z = x - pio2_1;
- if((ix&0xfffffff0)!=0x3fc90fd0) { /* 24+24 bit pi OK */
- y[0] = z - pio2_1t;
- y[1] = (z-y[0])-pio2_1t;
- } else { /* near pi/2, use 24+24+24 bit pi */
- z -= pio2_2;
- y[0] = z - pio2_2t;
- y[1] = (z-y[0])-pio2_2t;
- }
- return 1;
- } else { /* negative x */
- z = x + pio2_1;
- if((ix&0xfffffff0)!=0x3fc90fd0) { /* 24+24 bit pi OK */
- y[0] = z + pio2_1t;
- y[1] = (z-y[0])+pio2_1t;
- } else { /* near pi/2, use 24+24+24 bit pi */
- z += pio2_2;
- y[0] = z + pio2_2t;
- y[1] = (z-y[0])+pio2_2t;
- }
- return -1;
- }
- }
- if(ix<=0x43490f80) { /* |x| ~<= 2^7*(pi/2), medium size */
- t = fabsf(x);
- n = (__int32_t) (t*invpio2+half);
- fn = (float)n;
- r = t-fn*pio2_1;
- w = fn*pio2_1t; /* 1st round good to 40 bit */
- if(n<32&&(ix&(__int32_t)0xffffff00)!=npio2_hw[n-1]) {
- y[0] = r-w; /* quick check no cancellation */
- } else {
- __uint32_t high;
- j = ix>>23;
- y[0] = r-w;
- GET_FLOAT_WORD(high,y[0]);
- i = j-((high>>23)&0xff);
- if(i>8) { /* 2nd iteration needed, good to 57 */
- t = r;
- w = fn*pio2_2;
- r = t-w;
- w = fn*pio2_2t-((t-r)-w);
- y[0] = r-w;
- GET_FLOAT_WORD(high,y[0]);
- i = j-((high>>23)&0xff);
- if(i>25) { /* 3rd iteration need, 74 bits acc */
- t = r; /* will cover all possible cases */
- w = fn*pio2_3;
- r = t-w;
- w = fn*pio2_3t-((t-r)-w);
- y[0] = r-w;
- }
- }
- }
- y[1] = (r-y[0])-w;
- if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
- else return n;
- }
- /*
- * all other (large) arguments
- */
- if(!FLT_UWORD_IS_FINITE(ix)) {
- y[0]=y[1]=x-x; return 0;
- }
- /* set z = scalbn(|x|,ilogb(x)-7) */
- e0 = (int)((ix>>23)-134); /* e0 = ilogb(z)-7; */
- SET_FLOAT_WORD(z, ix - ((__int32_t)e0<<23));
- for(i=0;i<2;i++) {
- tx[i] = (float)((__int32_t)(z));
- z = (z-tx[i])*two8;
- }
- tx[2] = z;
- nx = 3;
- while(tx[nx-1]==zero) nx--; /* skip zero term */
- n = __kernel_rem_pio2f(tx,y,e0,nx,2,two_over_pi);
- if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
- return n;
-}
diff --git a/src/math/ef_sqrt.c b/src/math/ef_sqrt.c
deleted file mode 100644
index 80e7f360..00000000
--- a/src/math/ef_sqrt.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ef_sqrtf.c -- float version of e_sqrt.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "fdlibm.h"
-
-#ifdef __STDC__
-static const float one = 1.0, tiny=1.0e-30;
-#else
-static float one = 1.0, tiny=1.0e-30;
-#endif
-
-#ifdef __STDC__
- float __ieee754_sqrtf(float x)
-#else
- float __ieee754_sqrtf(x)
- float x;
-#endif
-{
- float z;
- __uint32_t r,hx;
- __int32_t ix,s,q,m,t,i;
-
- GET_FLOAT_WORD(ix,x);
- hx = ix&0x7fffffff;
-
- /* take care of Inf and NaN */
- if(!FLT_UWORD_IS_FINITE(hx))
- return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf
- sqrt(-inf)=sNaN */
- /* take care of zero and -ves */
- if(FLT_UWORD_IS_ZERO(hx)) return x;/* sqrt(+-0) = +-0 */
- if(ix<0) return (x-x)/(x-x); /* sqrt(-ve) = sNaN */
-
- /* normalize x */
- m = (ix>>23);
- if(FLT_UWORD_IS_SUBNORMAL(hx)) { /* subnormal x */
- for(i=0;(ix&0x00800000L)==0;i++) ix<<=1;
- m -= i-1;
- }
- m -= 127; /* unbias exponent */
- ix = (ix&0x007fffffL)|0x00800000L;
- if(m&1) /* odd m, double x to make it even */
- ix += ix;
- m >>= 1; /* m = [m/2] */
-
- /* generate sqrt(x) bit by bit */
- ix += ix;
- q = s = 0; /* q = sqrt(x) */
- r = 0x01000000L; /* r = moving bit from right to left */
-
- while(r!=0) {
- t = s+r;
- if(t<=ix) {
- s = t+r;
- ix -= t;
- q += r;
- }
- ix += ix;
- r>>=1;
- }
-
- /* use floating add to find out rounding direction */
- if(ix!=0) {
- z = one-tiny; /* trigger inexact flag */
- if (z>=one) {
- z = one+tiny;
- if (z>one)
- q += 2;
- else
- q += (q&1);
- }
- }
- ix = (q>>1)+0x3f000000L;
- ix += (m <<23);
- SET_FLOAT_WORD(z,ix);
- return z;
-}
diff --git a/src/math/fdlibm.h b/src/math/fdlibm.h
deleted file mode 100644
index ee9fcb22..00000000
--- a/src/math/fdlibm.h
+++ /dev/null
@@ -1,414 +0,0 @@
-
-/* @(#)fdlibm.h 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/* AltOS local */
-#include <math.h>
-#include <stdint.h>
-#define __int32_t int32_t
-#define __uint32_t uint32_t
-
-#define __ieee754_acosf acosf
-#define __ieee754_sqrtf sqrtf
-#define __ieee754_logf logf
-
-/* REDHAT LOCAL: Include files. */
-#include <math.h>
-/* #include <sys/types.h> */
-#include <machine/ieeefp.h>
-
-/* REDHAT LOCAL: Default to XOPEN_MODE. */
-#define _XOPEN_MODE
-
-/* Most routines need to check whether a float is finite, infinite, or not a
- number, and many need to know whether the result of an operation will
- overflow. These conditions depend on whether the largest exponent is
- used for NaNs & infinities, or whether it's used for finite numbers. The
- macros below wrap up that kind of information:
-
- FLT_UWORD_IS_FINITE(X)
- True if a positive float with bitmask X is finite.
-
- FLT_UWORD_IS_NAN(X)
- True if a positive float with bitmask X is not a number.
-
- FLT_UWORD_IS_INFINITE(X)
- True if a positive float with bitmask X is +infinity.
-
- FLT_UWORD_MAX
- The bitmask of FLT_MAX.
-
- FLT_UWORD_HALF_MAX
- The bitmask of FLT_MAX/2.
-
- FLT_UWORD_EXP_MAX
- The bitmask of the largest finite exponent (129 if the largest
- exponent is used for finite numbers, 128 otherwise).
-
- FLT_UWORD_LOG_MAX
- The bitmask of log(FLT_MAX), rounded down. This value is the largest
- input that can be passed to exp() without producing overflow.
-
- FLT_UWORD_LOG_2MAX
- The bitmask of log(2*FLT_MAX), rounded down. This value is the
- largest input than can be passed to cosh() without producing
- overflow.
-
- FLT_LARGEST_EXP
- The largest biased exponent that can be used for finite numbers
- (255 if the largest exponent is used for finite numbers, 254
- otherwise) */
-
-#ifdef _FLT_LARGEST_EXPONENT_IS_NORMAL
-#define FLT_UWORD_IS_FINITE(x) 1
-#define FLT_UWORD_IS_NAN(x) 0
-#define FLT_UWORD_IS_INFINITE(x) 0
-#define FLT_UWORD_MAX 0x7fffffff
-#define FLT_UWORD_EXP_MAX 0x43010000
-#define FLT_UWORD_LOG_MAX 0x42b2d4fc
-#define FLT_UWORD_LOG_2MAX 0x42b437e0
-#define HUGE ((float)0X1.FFFFFEP128)
-#else
-#define FLT_UWORD_IS_FINITE(x) ((x)<0x7f800000L)
-#define FLT_UWORD_IS_NAN(x) ((x)>0x7f800000L)
-#define FLT_UWORD_IS_INFINITE(x) ((x)==0x7f800000L)
-#define FLT_UWORD_MAX 0x7f7fffffL
-#define FLT_UWORD_EXP_MAX 0x43000000
-#define FLT_UWORD_LOG_MAX 0x42b17217
-#define FLT_UWORD_LOG_2MAX 0x42b2d4fc
-#define HUGE ((float)3.40282346638528860e+38)
-#endif
-#define FLT_UWORD_HALF_MAX (FLT_UWORD_MAX-(1L<<23))
-#define FLT_LARGEST_EXP (FLT_UWORD_MAX>>23)
-
-/* Many routines check for zero and subnormal numbers. Such things depend
- on whether the target supports denormals or not:
-
- FLT_UWORD_IS_ZERO(X)
- True if a positive float with bitmask X is +0. Without denormals,
- any float with a zero exponent is a +0 representation. With
- denormals, the only +0 representation is a 0 bitmask.
-
- FLT_UWORD_IS_SUBNORMAL(X)
- True if a non-zero positive float with bitmask X is subnormal.
- (Routines should check for zeros first.)
-
- FLT_UWORD_MIN
- The bitmask of the smallest float above +0. Call this number
- REAL_FLT_MIN...
-
- FLT_UWORD_EXP_MIN
- The bitmask of the float representation of REAL_FLT_MIN's exponent.
-
- FLT_UWORD_LOG_MIN
- The bitmask of |log(REAL_FLT_MIN)|, rounding down.
-
- FLT_SMALLEST_EXP
- REAL_FLT_MIN's exponent - EXP_BIAS (1 if denormals are not supported,
- -22 if they are).
-*/
-
-#ifdef _FLT_NO_DENORMALS
-#define FLT_UWORD_IS_ZERO(x) ((x)<0x00800000L)
-#define FLT_UWORD_IS_SUBNORMAL(x) 0
-#define FLT_UWORD_MIN 0x00800000
-#define FLT_UWORD_EXP_MIN 0x42fc0000
-#define FLT_UWORD_LOG_MIN 0x42aeac50
-#define FLT_SMALLEST_EXP 1
-#else
-#define FLT_UWORD_IS_ZERO(x) ((x)==0)
-#define FLT_UWORD_IS_SUBNORMAL(x) ((x)<0x00800000L)
-#define FLT_UWORD_MIN 0x00000001
-#define FLT_UWORD_EXP_MIN 0x43160000
-#define FLT_UWORD_LOG_MIN 0x42cff1b5
-#define FLT_SMALLEST_EXP -22
-#endif
-
-#ifdef __STDC__
-#undef __P
-#define __P(p) p
-#else
-#define __P(p) ()
-#endif
-
-/*
- * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
- * (one may replace the following line by "#include <values.h>")
- */
-
-#define X_TLOSS 1.41484755040568800000e+16
-
-/* Functions that are not documented, and are not in <math.h>. */
-
-#ifdef _SCALB_INT
-extern double scalb __P((double, int));
-#else
-extern double scalb __P((double, double));
-#endif
-extern double significand __P((double));
-
-/* ieee style elementary functions */
-extern double __ieee754_sqrt __P((double));
-extern double __ieee754_acos __P((double));
-extern double __ieee754_acosh __P((double));
-extern double __ieee754_log __P((double));
-extern double __ieee754_atanh __P((double));
-extern double __ieee754_asin __P((double));
-extern double __ieee754_atan2 __P((double,double));
-extern double __ieee754_exp __P((double));
-extern double __ieee754_cosh __P((double));
-extern double __ieee754_fmod __P((double,double));
-extern double __ieee754_pow __P((double,double));
-extern double __ieee754_lgamma_r __P((double,int *));
-extern double __ieee754_gamma_r __P((double,int *));
-extern double __ieee754_log10 __P((double));
-extern double __ieee754_sinh __P((double));
-extern double __ieee754_hypot __P((double,double));
-extern double __ieee754_j0 __P((double));
-extern double __ieee754_j1 __P((double));
-extern double __ieee754_y0 __P((double));
-extern double __ieee754_y1 __P((double));
-extern double __ieee754_jn __P((int,double));
-extern double __ieee754_yn __P((int,double));
-extern double __ieee754_remainder __P((double,double));
-extern __int32_t __ieee754_rem_pio2 __P((double,double*));
-#ifdef _SCALB_INT
-extern double __ieee754_scalb __P((double,int));
-#else
-extern double __ieee754_scalb __P((double,double));
-#endif
-
-/* fdlibm kernel function */
-extern double __kernel_standard __P((double,double,int));
-extern double __kernel_sin __P((double,double,int));
-extern double __kernel_cos __P((double,double));
-extern double __kernel_tan __P((double,double,int));
-extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const __int32_t*));
-
-/* Undocumented float functions. */
-#ifdef _SCALB_INT
-extern float scalbf __P((float, int));
-#else
-extern float scalbf __P((float, float));
-#endif
-extern float significandf __P((float));
-
-/* ieee style elementary float functions */
-extern float __ieee754_sqrtf __P((float));
-extern float __ieee754_acosf __P((float));
-extern float __ieee754_acoshf __P((float));
-extern float __ieee754_logf __P((float));
-extern float __ieee754_atanhf __P((float));
-extern float __ieee754_asinf __P((float));
-extern float __ieee754_atan2f __P((float,float));
-extern float __ieee754_expf __P((float));
-extern float __ieee754_coshf __P((float));
-extern float __ieee754_fmodf __P((float,float));
-extern float __ieee754_powf __P((float,float));
-extern float __ieee754_lgammaf_r __P((float,int *));
-extern float __ieee754_gammaf_r __P((float,int *));
-extern float __ieee754_log10f __P((float));
-extern float __ieee754_sinhf __P((float));
-extern float __ieee754_hypotf __P((float,float));
-extern float __ieee754_j0f __P((float));
-extern float __ieee754_j1f __P((float));
-extern float __ieee754_y0f __P((float));
-extern float __ieee754_y1f __P((float));
-extern float __ieee754_jnf __P((int,float));
-extern float __ieee754_ynf __P((int,float));
-extern float __ieee754_remainderf __P((float,float));
-extern __int32_t __ieee754_rem_pio2f __P((float,float*));
-#ifdef _SCALB_INT
-extern float __ieee754_scalbf __P((float,int));
-#else
-extern float __ieee754_scalbf __P((float,float));
-#endif
-
-/* float versions of fdlibm kernel functions */
-extern float __kernel_sinf __P((float,float,int));
-extern float __kernel_cosf __P((float,float));
-extern float __kernel_tanf __P((float,float,int));
-extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const __int32_t*));
-
-/* The original code used statements like
- n0 = ((*(int*)&one)>>29)^1; * index of high word *
- ix0 = *(n0+(int*)&x); * high word of x *
- ix1 = *((1-n0)+(int*)&x); * low word of x *
- to dig two 32 bit words out of the 64 bit IEEE floating point
- value. That is non-ANSI, and, moreover, the gcc instruction
- scheduler gets it wrong. We instead use the following macros.
- Unlike the original code, we determine the endianness at compile
- time, not at run time; I don't see much benefit to selecting
- endianness at run time. */
-
-#ifndef __IEEE_BIG_ENDIAN
-#ifndef __IEEE_LITTLE_ENDIAN
- #error Must define endianness
-#endif
-#endif
-
-/* A union which permits us to convert between a double and two 32 bit
- ints. */
-
-#ifdef __IEEE_BIG_ENDIAN
-
-typedef union
-{
- double value;
- struct
- {
- __uint32_t msw;
- __uint32_t lsw;
- } parts;
-} ieee_double_shape_type;
-
-#endif
-
-#ifdef __IEEE_LITTLE_ENDIAN
-
-typedef union
-{
- double value;
- struct
- {
- __uint32_t lsw;
- __uint32_t msw;
- } parts;
-} ieee_double_shape_type;
-
-#endif
-
-/* Get two 32 bit ints from a double. */
-
-#define EXTRACT_WORDS(ix0,ix1,d) \
-do { \
- ieee_double_shape_type ew_u; \
- ew_u.value = (d); \
- (ix0) = ew_u.parts.msw; \
- (ix1) = ew_u.parts.lsw; \
-} while (0)
-
-/* Get the more significant 32 bit int from a double. */
-
-#define GET_HIGH_WORD(i,d) \
-do { \
- ieee_double_shape_type gh_u; \
- gh_u.value = (d); \
- (i) = gh_u.parts.msw; \
-} while (0)
-
-/* Get the less significant 32 bit int from a double. */
-
-#define GET_LOW_WORD(i,d) \
-do { \
- ieee_double_shape_type gl_u; \
- gl_u.value = (d); \
- (i) = gl_u.parts.lsw; \
-} while (0)
-
-/* Set a double from two 32 bit ints. */
-
-#define INSERT_WORDS(d,ix0,ix1) \
-do { \
- ieee_double_shape_type iw_u; \
- iw_u.parts.msw = (ix0); \
- iw_u.parts.lsw = (ix1); \
- (d) = iw_u.value; \
-} while (0)
-
-/* Set the more significant 32 bits of a double from an int. */
-
-#define SET_HIGH_WORD(d,v) \
-do { \
- ieee_double_shape_type sh_u; \
- sh_u.value = (d); \
- sh_u.parts.msw = (v); \
- (d) = sh_u.value; \
-} while (0)
-
-/* Set the less significant 32 bits of a double from an int. */
-
-#define SET_LOW_WORD(d,v) \
-do { \
- ieee_double_shape_type sl_u; \
- sl_u.value = (d); \
- sl_u.parts.lsw = (v); \
- (d) = sl_u.value; \
-} while (0)
-
-/* A union which permits us to convert between a float and a 32 bit
- int. */
-
-typedef union
-{
- float value;
- __uint32_t word;
-} ieee_float_shape_type;
-
-/* Get a 32 bit int from a float. */
-
-#define GET_FLOAT_WORD(i,d) \
-do { \
- ieee_float_shape_type gf_u; \
- gf_u.value = (d); \
- (i) = gf_u.word; \
-} while (0)
-
-/* Set a float from a 32 bit int. */
-
-#define SET_FLOAT_WORD(d,i) \
-do { \
- ieee_float_shape_type sf_u; \
- sf_u.word = (i); \
- (d) = sf_u.value; \
-} while (0)
-
-/* Macros to avoid undefined behaviour that can arise if the amount
- of a shift is exactly equal to the size of the shifted operand. */
-
-#define SAFE_LEFT_SHIFT(op,amt) \
- (((amt) < 8 * sizeof(op)) ? ((op) << (amt)) : 0)
-
-#define SAFE_RIGHT_SHIFT(op,amt) \
- (((amt) < 8 * sizeof(op)) ? ((op) >> (amt)) : 0)
-
-#ifdef _COMPLEX_H
-
-/*
- * Quoting from ISO/IEC 9899:TC2:
- *
- * 6.2.5.13 Types
- * Each complex type has the same representation and alignment requirements as
- * an array type containing exactly two elements of the corresponding real type;
- * the first element is equal to the real part, and the second element to the
- * imaginary part, of the complex number.
- */
-typedef union {
- float complex z;
- float parts[2];
-} float_complex;
-
-typedef union {
- double complex z;
- double parts[2];
-} double_complex;
-
-typedef union {
- long double complex z;
- long double parts[2];
-} long_double_complex;
-
-#define REAL_PART(z) ((z).parts[0])
-#define IMAG_PART(z) ((z).parts[1])
-
-#endif /* _COMPLEX_H */
-
diff --git a/src/math/ieeefp.h b/src/math/ieeefp.h
deleted file mode 100644
index 0b06fb78..00000000
--- a/src/math/ieeefp.h
+++ /dev/null
@@ -1,256 +0,0 @@
-#ifndef _IEEE_FP_H_
-#define _IEEE_FP_H_
-
-#include "_ansi.h"
-
-#include <machine/ieeefp.h>
-
-_BEGIN_STD_C
-
-/* FIXME FIXME FIXME:
- Neither of __ieee_{float,double}_shape_tape seem to be used anywhere
- except in libm/test. If that is the case, please delete these from here.
- If that is not the case, please insert documentation here describing why
- they're needed. */
-
-#ifdef __IEEE_BIG_ENDIAN
-
-typedef union
-{
- double value;
- struct
- {
- unsigned int sign : 1;
- unsigned int exponent: 11;
- unsigned int fraction0:4;
- unsigned int fraction1:16;
- unsigned int fraction2:16;
- unsigned int fraction3:16;
-
- } number;
- struct
- {
- unsigned int sign : 1;
- unsigned int exponent: 11;
- unsigned int quiet:1;
- unsigned int function0:3;
- unsigned int function1:16;
- unsigned int function2:16;
- unsigned int function3:16;
- } nan;
- struct
- {
- unsigned long msw;
- unsigned long lsw;
- } parts;
- long aslong[2];
-} __ieee_double_shape_type;
-
-#endif
-
-#ifdef __IEEE_LITTLE_ENDIAN
-
-typedef union
-{
- double value;
- struct
- {
-#ifdef __SMALL_BITFIELDS
- unsigned int fraction3:16;
- unsigned int fraction2:16;
- unsigned int fraction1:16;
- unsigned int fraction0: 4;
-#else
- unsigned int fraction1:32;
- unsigned int fraction0:20;
-#endif
- unsigned int exponent :11;
- unsigned int sign : 1;
- } number;
- struct
- {
-#ifdef __SMALL_BITFIELDS
- unsigned int function3:16;
- unsigned int function2:16;
- unsigned int function1:16;
- unsigned int function0:3;
-#else
- unsigned int function1:32;
- unsigned int function0:19;
-#endif
- unsigned int quiet:1;
- unsigned int exponent: 11;
- unsigned int sign : 1;
- } nan;
- struct
- {
- unsigned long lsw;
- unsigned long msw;
- } parts;
-
- long aslong[2];
-
-} __ieee_double_shape_type;
-
-#endif
-
-#ifdef __IEEE_BIG_ENDIAN
-
-typedef union
-{
- float value;
- struct
- {
- unsigned int sign : 1;
- unsigned int exponent: 8;
- unsigned int fraction0: 7;
- unsigned int fraction1: 16;
- } number;
- struct
- {
- unsigned int sign:1;
- unsigned int exponent:8;
- unsigned int quiet:1;
- unsigned int function0:6;
- unsigned int function1:16;
- } nan;
- long p1;
-
-} __ieee_float_shape_type;
-
-#endif
-
-#ifdef __IEEE_LITTLE_ENDIAN
-
-typedef union
-{
- float value;
- struct
- {
- unsigned int fraction0: 7;
- unsigned int fraction1: 16;
- unsigned int exponent: 8;
- unsigned int sign : 1;
- } number;
- struct
- {
- unsigned int function1:16;
- unsigned int function0:6;
- unsigned int quiet:1;
- unsigned int exponent:8;
- unsigned int sign:1;
- } nan;
- long p1;
-
-} __ieee_float_shape_type;
-
-#endif
-
-
-
-
-
-/* FLOATING ROUNDING */
-
-typedef int fp_rnd;
-#define FP_RN 0 /* Round to nearest */
-#define FP_RM 1 /* Round down */
-#define FP_RP 2 /* Round up */
-#define FP_RZ 3 /* Round to zero (trunate) */
-
-fp_rnd _EXFUN(fpgetround,(void));
-fp_rnd _EXFUN(fpsetround, (fp_rnd));
-
-/* EXCEPTIONS */
-
-typedef int fp_except;
-#define FP_X_INV 0x10 /* Invalid operation */
-#define FP_X_DX 0x80 /* Divide by zero */
-#define FP_X_OFL 0x04 /* Overflow exception */
-#define FP_X_UFL 0x02 /* Underflow exception */
-#define FP_X_IMP 0x01 /* imprecise exception */
-
-fp_except _EXFUN(fpgetmask,(void));
-fp_except _EXFUN(fpsetmask,(fp_except));
-fp_except _EXFUN(fpgetsticky,(void));
-fp_except _EXFUN(fpsetsticky, (fp_except));
-
-/* INTEGER ROUNDING */
-
-typedef int fp_rdi;
-#define FP_RDI_TOZ 0 /* Round to Zero */
-#define FP_RDI_RD 1 /* Follow float mode */
-
-fp_rdi _EXFUN(fpgetroundtoi,(void));
-fp_rdi _EXFUN(fpsetroundtoi,(fp_rdi));
-
-#undef isnan
-#undef isinf
-
-int _EXFUN(isnan, (double));
-int _EXFUN(isinf, (double));
-int _EXFUN(finite, (double));
-
-
-
-int _EXFUN(isnanf, (float));
-int _EXFUN(isinff, (float));
-int _EXFUN(finitef, (float));
-
-#define __IEEE_DBL_EXPBIAS 1023
-#define __IEEE_FLT_EXPBIAS 127
-
-#define __IEEE_DBL_EXPLEN 11
-#define __IEEE_FLT_EXPLEN 8
-
-
-#define __IEEE_DBL_FRACLEN (64 - (__IEEE_DBL_EXPLEN + 1))
-#define __IEEE_FLT_FRACLEN (32 - (__IEEE_FLT_EXPLEN + 1))
-
-#define __IEEE_DBL_MAXPOWTWO ((double)(1L << 32 - 2) * (1L << (32-11) - 32 + 1))
-#define __IEEE_FLT_MAXPOWTWO ((float)(1L << (32-8) - 1))
-
-#define __IEEE_DBL_NAN_EXP 0x7ff
-#define __IEEE_FLT_NAN_EXP 0xff
-
-#ifndef __ieeefp_isnanf
-#define __ieeefp_isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
- ((*(long *)&(x) & 0x007fffffL)!=0000000000L))
-#endif
-#define isnanf(x) __ieeefp_isnanf(x)
-
-#ifndef __ieeefp_isinff
-#define __ieeefp_isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
- ((*(long *)&(x) & 0x007fffffL)==0000000000L))
-#endif
-#define isinff(x) __ieeefp_isinff(x)
-
-#ifndef __ieeefp_finitef
-#define __ieeefp_finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L))
-#endif
-#define finitef(x) __ieeefp_finitef(x)
-
-#ifdef _DOUBLE_IS_32BITS
-#undef __IEEE_DBL_EXPBIAS
-#define __IEEE_DBL_EXPBIAS __IEEE_FLT_EXPBIAS
-
-#undef __IEEE_DBL_EXPLEN
-#define __IEEE_DBL_EXPLEN __IEEE_FLT_EXPLEN
-
-#undef __IEEE_DBL_FRACLEN
-#define __IEEE_DBL_FRACLEN __IEEE_FLT_FRACLEN
-
-#undef __IEEE_DBL_MAXPOWTWO
-#define __IEEE_DBL_MAXPOWTWO __IEEE_FLT_MAXPOWTWO
-
-#undef __IEEE_DBL_NAN_EXP
-#define __IEEE_DBL_NAN_EXP __IEEE_FLT_NAN_EXP
-
-#undef __ieee_double_shape_type
-#define __ieee_double_shape_type __ieee_float_shape_type
-
-#endif /* _DOUBLE_IS_32BITS */
-
-_END_STD_C
-
-#endif /* _IEEE_FP_H_ */
diff --git a/src/math/kf_cos.c b/src/math/kf_cos.c
deleted file mode 100644
index 4f71af23..00000000
--- a/src/math/kf_cos.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* kf_cos.c -- float version of k_cos.c
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "fdlibm.h"
-
-#ifdef __STDC__
-static const float
-#else
-static float
-#endif
-one = 1.0000000000e+00, /* 0x3f800000 */
-C1 = 4.1666667908e-02, /* 0x3d2aaaab */
-C2 = -1.3888889225e-03, /* 0xbab60b61 */
-C3 = 2.4801587642e-05, /* 0x37d00d01 */
-C4 = -2.7557314297e-07, /* 0xb493f27c */
-C5 = 2.0875723372e-09, /* 0x310f74f6 */
-C6 = -1.1359647598e-11; /* 0xad47d74e */
-
-#ifdef __STDC__
- float __kernel_cosf(float x, float y)
-#else
- float __kernel_cosf(x, y)
- float x,y;
-#endif
-{
- float a,hz,z,r,qx;
- __int32_t ix;
- GET_FLOAT_WORD(ix,x);
- ix &= 0x7fffffff; /* ix = |x|'s high word*/
- if(ix<0x32000000) { /* if x < 2**27 */
- if(((int)x)==0) return one; /* generate inexact */
- }
- z = x*x;
- r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6)))));
- if(ix < 0x3e99999a) /* if |x| < 0.3 */
- return one - ((float)0.5*z - (z*r - x*y));
- else {
- if(ix > 0x3f480000) { /* x > 0.78125 */
- qx = (float)0.28125;
- } else {
- SET_FLOAT_WORD(qx,ix-0x01000000); /* x/4 */
- }
- hz = (float)0.5*z-qx;
- a = one-qx;
- return a - (hz - (z*r-x*y));
- }
-}
diff --git a/src/math/kf_rem_pio2.c b/src/math/kf_rem_pio2.c
deleted file mode 100644
index 1573ca9f..00000000
--- a/src/math/kf_rem_pio2.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/* kf_rem_pio2.c -- float version of k_rem_pio2.c
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "fdlibm.h"
-
-/* In the float version, the input parameter x contains 8 bit
- integers, not 24 bit integers. 113 bit precision is not supported. */
-
-#ifdef __STDC__
-static const int init_jk[] = {4,7,9}; /* initial value for jk */
-#else
-static int init_jk[] = {4,7,9};
-#endif
-
-#ifdef __STDC__
-static const float PIo2[] = {
-#else
-static float PIo2[] = {
-#endif
- 1.5703125000e+00, /* 0x3fc90000 */
- 4.5776367188e-04, /* 0x39f00000 */
- 2.5987625122e-05, /* 0x37da0000 */
- 7.5437128544e-08, /* 0x33a20000 */
- 6.0026650317e-11, /* 0x2e840000 */
- 7.3896444519e-13, /* 0x2b500000 */
- 5.3845816694e-15, /* 0x27c20000 */
- 5.6378512969e-18, /* 0x22d00000 */
- 8.3009228831e-20, /* 0x1fc40000 */
- 3.2756352257e-22, /* 0x1bc60000 */
- 6.3331015649e-25, /* 0x17440000 */
-};
-
-#ifdef __STDC__
-static const float
-#else
-static float
-#endif
-zero = 0.0,
-one = 1.0,
-two8 = 2.5600000000e+02, /* 0x43800000 */
-twon8 = 3.9062500000e-03; /* 0x3b800000 */
-
-#ifdef __STDC__
- int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const __int32_t *ipio2)
-#else
- int __kernel_rem_pio2f(x,y,e0,nx,prec,ipio2)
- float x[], y[]; int e0,nx,prec; __int32_t ipio2[];
-#endif
-{
- __int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
- float z,fw,f[20],fq[20],q[20];
-
- /* initialize jk*/
- jk = init_jk[prec];
- jp = jk;
-
- /* determine jx,jv,q0, note that 3>q0 */
- jx = nx-1;
- jv = (e0-3)/8; if(jv<0) jv=0;
- q0 = e0-8*(jv+1);
-
- /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */
- j = jv-jx; m = jx+jk;
- for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (float) ipio2[j];
-
- /* compute q[0],q[1],...q[jk] */
- for (i=0;i<=jk;i++) {
- for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
- q[i] = fw;
- }
-
- jz = jk;
-recompute:
- /* distill q[] into iq[] reversingly */
- for(i=0,j=jz,z=q[jz];j>0;i++,j--) {
- fw = (float)((__int32_t)(twon8* z));
- iq[i] = (__int32_t)(z-two8*fw);
- z = q[j-1]+fw;
- }
-
- /* compute n */
- z = scalbnf(z,(int)q0); /* actual value of z */
- z -= (float)8.0*floorf(z*(float)0.125); /* trim off integer >= 8 */
- n = (__int32_t) z;
- z -= (float)n;
- ih = 0;
- if(q0>0) { /* need iq[jz-1] to determine n */
- i = (iq[jz-1]>>(8-q0)); n += i;
- iq[jz-1] -= i<<(8-q0);
- ih = iq[jz-1]>>(7-q0);
- }
- else if(q0==0) ih = iq[jz-1]>>8;
- else if(z>=(float)0.5) ih=2;
-
- if(ih>0) { /* q > 0.5 */
- n += 1; carry = 0;
- for(i=0;i<jz ;i++) { /* compute 1-q */
- j = iq[i];
- if(carry==0) {
- if(j!=0) {
- carry = 1; iq[i] = 0x100- j;
- }
- } else iq[i] = 0xff - j;
- }
- if(q0>0) { /* rare case: chance is 1 in 12 */
- switch(q0) {
- case 1:
- iq[jz-1] &= 0x7f; break;
- case 2:
- iq[jz-1] &= 0x3f; break;
- }
- }
- if(ih==2) {
- z = one - z;
- if(carry!=0) z -= scalbnf(one,(int)q0);
- }
- }
-
- /* check if recomputation is needed */
- if(z==zero) {
- j = 0;
- for (i=jz-1;i>=jk;i--) j |= iq[i];
- if(j==0) { /* need recomputation */
- for(k=1;iq[jk-k]==0;k++); /* k = no. of terms needed */
-
- for(i=jz+1;i<=jz+k;i++) { /* add q[jz+1] to q[jz+k] */
- f[jx+i] = (float) ipio2[jv+i];
- for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
- q[i] = fw;
- }
- jz += k;
- goto recompute;
- }
- }
-
- /* chop off zero terms */
- if(z==(float)0.0) {
- jz -= 1; q0 -= 8;
- while(iq[jz]==0) { jz--; q0-=8;}
- } else { /* break z into 8-bit if necessary */
- z = scalbnf(z,-(int)q0);
- if(z>=two8) {
- fw = (float)((__int32_t)(twon8*z));
- iq[jz] = (__int32_t)(z-two8*fw);
- jz += 1; q0 += 8;
- iq[jz] = (__int32_t) fw;
- } else iq[jz] = (__int32_t) z ;
- }
-
- /* convert integer "bit" chunk to floating-point value */
- fw = scalbnf(one,(int)q0);
- for(i=jz;i>=0;i--) {
- q[i] = fw*(float)iq[i]; fw*=twon8;
- }
-
- /* compute PIo2[0,...,jp]*q[jz,...,0] */
- for(i=jz;i>=0;i--) {
- for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k];
- fq[jz-i] = fw;
- }
-
- /* compress fq[] into y[] */
- switch(prec) {
- case 0:
- fw = 0.0;
- for (i=jz;i>=0;i--) fw += fq[i];
- y[0] = (ih==0)? fw: -fw;
- break;
- case 1:
- case 2:
- fw = 0.0;
- for (i=jz;i>=0;i--) fw += fq[i];
- y[0] = (ih==0)? fw: -fw;
- fw = fq[0]-fw;
- for (i=1;i<=jz;i++) fw += fq[i];
- y[1] = (ih==0)? fw: -fw;
- break;
- case 3: /* painful */
- for (i=jz;i>0;i--) {
- fw = fq[i-1]+fq[i];
- fq[i] += fq[i-1]-fw;
- fq[i-1] = fw;
- }
- for (i=jz;i>1;i--) {
- fw = fq[i-1]+fq[i];
- fq[i] += fq[i-1]-fw;
- fq[i-1] = fw;
- }
- for (fw=0.0,i=jz;i>=2;i--) fw += fq[i];
- if(ih==0) {
- y[0] = fq[0]; y[1] = fq[1]; y[2] = fw;
- } else {
- y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw;
- }
- }
- return n&7;
-}
diff --git a/src/math/kf_sin.c b/src/math/kf_sin.c
deleted file mode 100644
index e81fa0bd..00000000
--- a/src/math/kf_sin.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* kf_sin.c -- float version of k_sin.c
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "fdlibm.h"
-
-#ifdef __STDC__
-static const float
-#else
-static float
-#endif
-half = 5.0000000000e-01,/* 0x3f000000 */
-S1 = -1.6666667163e-01, /* 0xbe2aaaab */
-S2 = 8.3333337680e-03, /* 0x3c088889 */
-S3 = -1.9841270114e-04, /* 0xb9500d01 */
-S4 = 2.7557314297e-06, /* 0x3638ef1b */
-S5 = -2.5050759689e-08, /* 0xb2d72f34 */
-S6 = 1.5896910177e-10; /* 0x2f2ec9d3 */
-
-#ifdef __STDC__
- float __kernel_sinf(float x, float y, int iy)
-#else
- float __kernel_sinf(x, y, iy)
- float x,y; int iy; /* iy=0 if y is zero */
-#endif
-{
- float z,r,v;
- __int32_t ix;
- GET_FLOAT_WORD(ix,x);
- ix &= 0x7fffffff; /* high word of x */
- if(ix<0x32000000) /* |x| < 2**-27 */
- {if((int)x==0) return x;} /* generate inexact */
- z = x*x;
- v = z*x;
- r = S2+z*(S3+z*(S4+z*(S5+z*S6)));
- if(iy==0) return x+v*(S1+z*r);
- else return x-((z*(half*y-v*r)-y)-v*S1);
-}
diff --git a/src/math/machine/ieeefp.h b/src/math/machine/ieeefp.h
deleted file mode 100644
index fffa3804..00000000
--- a/src/math/machine/ieeefp.h
+++ /dev/null
@@ -1,382 +0,0 @@
-#ifndef __IEEE_BIG_ENDIAN
-#ifndef __IEEE_LITTLE_ENDIAN
-
-/* This file can define macros to choose variations of the IEEE float
- format:
-
- _FLT_LARGEST_EXPONENT_IS_NORMAL
-
- Defined if the float format uses the largest exponent for finite
- numbers rather than NaN and infinity representations. Such a
- format cannot represent NaNs or infinities at all, but it's FLT_MAX
- is twice the IEEE value.
-
- _FLT_NO_DENORMALS
-
- Defined if the float format does not support IEEE denormals. Every
- float with a zero exponent is taken to be a zero representation.
-
- ??? At the moment, there are no equivalent macros above for doubles and
- the macros are not fully supported by --enable-newlib-hw-fp.
-
- __IEEE_BIG_ENDIAN
-
- Defined if the float format is big endian. This is mutually exclusive
- with __IEEE_LITTLE_ENDIAN.
-
- __IEEE_LITTLE_ENDIAN
-
- Defined if the float format is little endian. This is mutually exclusive
- with __IEEE_BIG_ENDIAN.
-
- Note that one of __IEEE_BIG_ENDIAN or __IEEE_LITTLE_ENDIAN must be specified for a
- platform or error will occur.
-
- __IEEE_BYTES_LITTLE_ENDIAN
-
- This flag is used in conjunction with __IEEE_BIG_ENDIAN to describe a situation
- whereby multiple words of an IEEE floating point are in big endian order, but the
- words themselves are little endian with respect to the bytes.
-
- _DOUBLE_IS_32BITS
-
- This is used on platforms that support double by using the 32-bit IEEE
- float type.
-
- _FLOAT_ARG
-
- This represents what type a float arg is passed as. It is used when the type is
- not promoted to double.
-
-*/
-
-#if (defined(__arm__) || defined(__thumb__)) && !defined(__MAVERICK__)
-/* ARM traditionally used big-endian words; and within those words the
- byte ordering was big or little endian depending upon the target.
- Modern floating-point formats are naturally ordered; in this case
- __VFP_FP__ will be defined, even if soft-float. */
-#ifdef __VFP_FP__
-# ifdef __ARMEL__
-# define __IEEE_LITTLE_ENDIAN
-# else
-# define __IEEE_BIG_ENDIAN
-# endif
-#else
-# define __IEEE_BIG_ENDIAN
-# ifdef __ARMEL__
-# define __IEEE_BYTES_LITTLE_ENDIAN
-# endif
-#endif
-#endif
-
-#ifdef __hppa__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __SPU__
-#define __IEEE_BIG_ENDIAN
-
-#define isfinite(__y) \
- (__extension__ ({int __cy; \
- (sizeof (__y) == sizeof (float)) ? (1) : \
- (__cy = fpclassify(__y)) != FP_INFINITE && __cy != FP_NAN;}))
-
-#define isinf(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isinfd(__x))
-#define isnan(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isnand(__x))
-
-/*
- * Macros for use in ieeefp.h. We can't just define the real ones here
- * (like those above) as we have name space issues when this is *not*
- * included via generic the ieeefp.h.
- */
-#define __ieeefp_isnanf(x) 0
-#define __ieeefp_isinff(x) 0
-#define __ieeefp_finitef(x) 1
-#endif
-
-#ifdef __sparc__
-#ifdef __LITTLE_ENDIAN_DATA__
-#define __IEEE_LITTLE_ENDIAN
-#else
-#define __IEEE_BIG_ENDIAN
-#endif
-#endif
-
-#if defined(__m68k__) || defined(__mc68000__)
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__)
-#define __IEEE_BIG_ENDIAN
-#ifdef __HAVE_SHORT_DOUBLE__
-# define _DOUBLE_IS_32BITS
-#endif
-#endif
-
-#if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__) || defined (__H8500__) || defined (__H8300SX__)
-#define __IEEE_BIG_ENDIAN
-#define _FLOAT_ARG float
-#define _DOUBLE_IS_32BITS
-#endif
-
-#if defined (__xc16x__) || defined (__xc16xL__) || defined (__xc16xS__)
-#define __IEEE_LITTLE_ENDIAN
-#define _FLOAT_ARG float
-#define _DOUBLE_IS_32BITS
-#endif
-
-
-#ifdef __sh__
-#ifdef __LITTLE_ENDIAN__
-#define __IEEE_LITTLE_ENDIAN
-#else
-#define __IEEE_BIG_ENDIAN
-#endif
-#if defined(__SH2E__) || defined(__SH3E__) || defined(__SH4_SINGLE_ONLY__) || defined(__SH2A_SINGLE_ONLY__)
-#define _DOUBLE_IS_32BITS
-#endif
-#endif
-
-#ifdef _AM29K
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef _WIN32
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __i386__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __i960__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __lm32__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __M32R__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#if defined(_C4x) || defined(_C3x)
-#define __IEEE_BIG_ENDIAN
-#define _DOUBLE_IS_32BITS
-#endif
-
-#ifdef __TMS320C6X__
-#ifdef _BIG_ENDIAN
-#define __IEEE_BIG_ENDIAN
-#else
-#define __IEEE_LITTLE_ENDIAN
-#endif
-#endif
-
-#ifdef __TIC80__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __MIPSEL__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-#ifdef __MIPSEB__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __MMIX__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __D30V__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-/* necv70 was __IEEE_LITTLE_ENDIAN. */
-
-#ifdef __W65__
-#define __IEEE_LITTLE_ENDIAN
-#define _DOUBLE_IS_32BITS
-#endif
-
-#if defined(__Z8001__) || defined(__Z8002__)
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __m88k__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __mn10300__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __mn10200__
-#define __IEEE_LITTLE_ENDIAN
-#define _DOUBLE_IS_32BITS
-#endif
-
-#ifdef __v800
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __v850
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __D10V__
-#define __IEEE_BIG_ENDIAN
-#if __DOUBLE__ == 32
-#define _DOUBLE_IS_32BITS
-#endif
-#endif
-
-#ifdef __PPC__
-#if (defined(_BIG_ENDIAN) && _BIG_ENDIAN) || (defined(_AIX) && _AIX)
-#define __IEEE_BIG_ENDIAN
-#else
-#if (defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN) || (defined(__sun__) && __sun__) || (defined(_WIN32) && _WIN32)
-#define __IEEE_LITTLE_ENDIAN
-#endif
-#endif
-#endif
-
-#ifdef __xstormy16__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __arc__
-#ifdef __big_endian__
-#define __IEEE_BIG_ENDIAN
-#else
-#define __IEEE_LITTLE_ENDIAN
-#endif
-#endif
-
-#ifdef __CRX__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __fr30__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __mcore__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __mt__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __frv__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __moxie__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __ia64__
-#ifdef __BIG_ENDIAN__
-#define __IEEE_BIG_ENDIAN
-#else
-#define __IEEE_LITTLE_ENDIAN
-#endif
-#endif
-
-#ifdef __AVR__
-#define __IEEE_LITTLE_ENDIAN
-#define _DOUBLE_IS_32BITS
-#endif
-
-#if defined(__or32__) || defined(__or1k__) || defined(__or16__)
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __IP2K__
-#define __IEEE_BIG_ENDIAN
-#define __SMALL_BITFIELDS
-#define _DOUBLE_IS_32BITS
-#endif
-
-#ifdef __iq2000__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __MAVERICK__
-#ifdef __ARMEL__
-# define __IEEE_LITTLE_ENDIAN
-#else /* must be __ARMEB__ */
-# define __IEEE_BIG_ENDIAN
-#endif /* __ARMEL__ */
-#endif /* __MAVERICK__ */
-
-#ifdef __m32c__
-#define __IEEE_LITTLE_ENDIAN
-#define __SMALL_BITFIELDS
-#endif
-
-#ifdef __CRIS__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __BFIN__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __x86_64__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __mep__
-#ifdef __LITTLE_ENDIAN__
-#define __IEEE_LITTLE_ENDIAN
-#else
-#define __IEEE_BIG_ENDIAN
-#endif
-#endif
-
-#ifdef __MICROBLAZE__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __RL78__
-#define __IEEE_LITTLE_ENDIAN
-#define __SMALL_BITFIELDS /* 16 Bit INT */
-#define _DOUBLE_IS_32BITS
-#endif
-
-#ifdef __RX__
-
-#ifdef __RX_BIG_ENDIAN__
-#define __IEEE_BIG_ENDIAN
-#else
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifndef __RX_64BIT_DOUBLES__
-#define _DOUBLE_IS_32BITS
-#endif
-
-#ifdef __RX_16BIT_INTS__
-#define __SMALL_BITFIELDS
-#endif
-
-#endif
-
-#if (defined(__CR16__) || defined(__CR16C__) ||defined(__CR16CP__))
-#define __IEEE_LITTLE_ENDIAN
-#define __SMALL_BITFIELDS /* 16 Bit INT */
-#endif
-
-#ifndef __IEEE_BIG_ENDIAN
-#ifndef __IEEE_LITTLE_ENDIAN
-#error Endianess not declared!!
-#endif /* not __IEEE_LITTLE_ENDIAN */
-#endif /* not __IEEE_BIG_ENDIAN */
-
-#endif /* not __IEEE_LITTLE_ENDIAN */
-#endif /* not __IEEE_BIG_ENDIAN */
-
diff --git a/src/math/math.h b/src/math/math.h
deleted file mode 100644
index 3a279663..00000000
--- a/src/math/math.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright © 2013 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.
- */
-
-#ifndef _MATH_H_
-#define _MATH_H_
-
-float acosf(float x);
-
-float cosf(float x);
-
-float sinf(float x);
-
-float sqrtf(float x);
-
-float fabsf(float x);
-
-float floorf(float x);
-
-float scalbnf(float x, int n);
-
-float copysignf(float x, float y);
-
-float logf(float x);
-
-#endif
diff --git a/src/math/sf_copysign.c b/src/math/sf_copysign.c
deleted file mode 100644
index f547c82e..00000000
--- a/src/math/sf_copysign.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* sf_copysign.c -- float version of s_copysign.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
- * copysignf(float x, float y)
- * copysignf(x,y) returns a value with the magnitude of x and
- * with the sign bit of y.
- */
-
-#include "fdlibm.h"
-
-#ifdef __STDC__
- float copysignf(float x, float y)
-#else
- float copysignf(x,y)
- float x,y;
-#endif
-{
- __uint32_t ix,iy;
- GET_FLOAT_WORD(ix,x);
- GET_FLOAT_WORD(iy,y);
- SET_FLOAT_WORD(x,(ix&0x7fffffff)|(iy&0x80000000));
- return x;
-}
-
-#ifdef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double copysign(double x, double y)
-#else
- double copysign(x,y)
- double x,y;
-#endif
-{
- return (double) copysignf((float) x, (float) y);
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/src/math/sf_cos.c b/src/math/sf_cos.c
deleted file mode 100644
index 2f46ec32..00000000
--- a/src/math/sf_cos.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* sf_cos.c -- float version of s_cos.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "fdlibm.h"
-
-#ifdef __STDC__
- float cosf(float x)
-#else
- float cosf(x)
- float x;
-#endif
-{
- float y[2],z=0.0;
- __int32_t n,ix;
-
- GET_FLOAT_WORD(ix,x);
-
- /* |x| ~< pi/4 */
- ix &= 0x7fffffff;
- if(ix <= 0x3f490fd8) return __kernel_cosf(x,z);
-
- /* cos(Inf or NaN) is NaN */
- else if (!FLT_UWORD_IS_FINITE(ix)) return x-x;
-
- /* argument reduction needed */
- else {
- n = __ieee754_rem_pio2f(x,y);
- switch(n&3) {
- case 0: return __kernel_cosf(y[0],y[1]);
- case 1: return -__kernel_sinf(y[0],y[1],1);
- case 2: return -__kernel_cosf(y[0],y[1]);
- default:
- return __kernel_sinf(y[0],y[1],1);
- }
- }
-}
-
-#ifdef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double cos(double x)
-#else
- double cos(x)
- double x;
-#endif
-{
- return (double) cosf((float) x);
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/src/math/sf_fabs.c b/src/math/sf_fabs.c
deleted file mode 100644
index 2aaed326..00000000
--- a/src/math/sf_fabs.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* sf_fabs.c -- float version of s_fabs.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
- * fabsf(x) returns the absolute value of x.
- */
-
-#include "fdlibm.h"
-
-#ifdef __STDC__
- float fabsf(float x)
-#else
- float fabsf(x)
- float x;
-#endif
-{
- __uint32_t ix;
- GET_FLOAT_WORD(ix,x);
- SET_FLOAT_WORD(x,ix&0x7fffffff);
- return x;
-}
-
-#ifdef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double fabs(double x)
-#else
- double fabs(x)
- double x;
-#endif
-{
- return (double) fabsf((float) x);
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/src/math/sf_floor.c b/src/math/sf_floor.c
deleted file mode 100644
index 9264d81e..00000000
--- a/src/math/sf_floor.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/* sf_floor.c -- float version of s_floor.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
- * floorf(x)
- * Return x rounded toward -inf to integral value
- * Method:
- * Bit twiddling.
- * Exception:
- * Inexact flag raised if x not equal to floorf(x).
- */
-
-#include "fdlibm.h"
-
-#ifdef __STDC__
-static const float huge = 1.0e30;
-#else
-static float huge = 1.0e30;
-#endif
-
-#ifdef __STDC__
- float floorf(float x)
-#else
- float floorf(x)
- float x;
-#endif
-{
- __int32_t i0,j0;
- __uint32_t i,ix;
- GET_FLOAT_WORD(i0,x);
- ix = (i0&0x7fffffff);
- j0 = (ix>>23)-0x7f;
- if(j0<23) {
- if(j0<0) { /* raise inexact if x != 0 */
- if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */
- if(i0>=0) {i0=0;}
- else if(!FLT_UWORD_IS_ZERO(ix))
- { i0=0xbf800000;}
- }
- } else {
- i = (0x007fffff)>>j0;
- if((i0&i)==0) return x; /* x is integral */
- if(huge+x>(float)0.0) { /* raise inexact flag */
- if(i0<0) i0 += (0x00800000)>>j0;
- i0 &= (~i);
- }
- }
- } else {
- if(!FLT_UWORD_IS_FINITE(ix)) return x+x; /* inf or NaN */
- else return x; /* x is integral */
- }
- SET_FLOAT_WORD(x,i0);
- return x;
-}
-
-#ifdef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double floor(double x)
-#else
- double floor(x)
- double x;
-#endif
-{
- return (double) floorf((float) x);
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/src/math/sf_scalbn.c b/src/math/sf_scalbn.c
deleted file mode 100644
index 70006001..00000000
--- a/src/math/sf_scalbn.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/* sf_scalbn.c -- float version of s_scalbn.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "fdlibm.h"
-#include <limits.h>
-#include <float.h>
-
-#if INT_MAX > 50000
-#define OVERFLOW_INT 50000
-#else
-#define OVERFLOW_INT 30000
-#endif
-
-#ifdef __STDC__
-static const float
-#else
-static float
-#endif
-two25 = 3.355443200e+07, /* 0x4c000000 */
-twom25 = 2.9802322388e-08, /* 0x33000000 */
-huge = 1.0e+30,
-tiny = 1.0e-30;
-
-#ifdef __STDC__
- float scalbnf (float x, int n)
-#else
- float scalbnf (x,n)
- float x; int n;
-#endif
-{
- __int32_t k,ix;
- __uint32_t hx;
-
- GET_FLOAT_WORD(ix,x);
- hx = ix&0x7fffffff;
- k = hx>>23; /* extract exponent */
- if (FLT_UWORD_IS_ZERO(hx))
- return x;
- if (!FLT_UWORD_IS_FINITE(hx))
- return x+x; /* NaN or Inf */
- if (FLT_UWORD_IS_SUBNORMAL(hx)) {
- x *= two25;
- GET_FLOAT_WORD(ix,x);
- k = ((ix&0x7f800000)>>23) - 25;
- if (n< -50000) return tiny*x; /*underflow*/
- }
- k = k+n;
- if (k > FLT_LARGEST_EXP) return huge*copysignf(huge,x); /* overflow */
- if (k > 0) /* normal result */
- {SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;}
- if (k < FLT_SMALLEST_EXP) {
- if (n > OVERFLOW_INT) /* in case integer overflow in n+k */
- return huge*copysignf(huge,x); /*overflow*/
- else return tiny*copysignf(tiny,x); /*underflow*/
- }
- k += 25; /* subnormal result */
- SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23));
- return x*twom25;
-}
-
-#ifdef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double scalbn(double x, int n)
-#else
- double scalbn(x,n)
- double x;
- int n;
-#endif
-{
- return (double) scalbnf((float) x, n);
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/src/math/sf_sin.c b/src/math/sf_sin.c
deleted file mode 100644
index da81845d..00000000
--- a/src/math/sf_sin.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* sf_sin.c -- float version of s_sin.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "fdlibm.h"
-
-#ifdef __STDC__
- float sinf(float x)
-#else
- float sinf(x)
- float x;
-#endif
-{
- float y[2],z=0.0;
- __int32_t n,ix;
-
- GET_FLOAT_WORD(ix,x);
-
- /* |x| ~< pi/4 */
- ix &= 0x7fffffff;
- if(ix <= 0x3f490fd8) return __kernel_sinf(x,z,0);
-
- /* sin(Inf or NaN) is NaN */
- else if (!FLT_UWORD_IS_FINITE(ix)) return x-x;
-
- /* argument reduction needed */
- else {
- n = __ieee754_rem_pio2f(x,y);
- switch(n&3) {
- case 0: return __kernel_sinf(y[0],y[1],1);
- case 1: return __kernel_cosf(y[0],y[1]);
- case 2: return -__kernel_sinf(y[0],y[1],1);
- default:
- return -__kernel_cosf(y[0],y[1]);
- }
- }
-}
-
-#ifdef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double sin(double x)
-#else
- double sin(x)
- double x;
-#endif
-{
- return (double) sinf((float) x);
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/src/megadongle-v0.1/.gitignore b/src/megadongle-v0.1/.gitignore
deleted file mode 100644
index f735e6ea..00000000
--- a/src/megadongle-v0.1/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-ao_product.h
-megadongle-*.elf
diff --git a/src/megadongle-v0.1/Makefile b/src/megadongle-v0.1/Makefile
deleted file mode 100644
index bbe2ea58..00000000
--- a/src/megadongle-v0.1/Makefile
+++ /dev/null
@@ -1,90 +0,0 @@
-#
-# AltOS build
-#
-#
-
-include ../stm/Makefile.defs
-
-INC = \
- ao.h \
- ao_arch.h \
- ao_arch_funcs.h \
- ao_boot.h \
- ao_pins.h \
- ao_product.h \
- ao_cc1120_CC1120.h \
- ao_task.h \
- ao_whiten.h \
- stm32l.h \
- Makefile
-
-#PROFILE=ao_profile.c
-#PROFILE_DEF=-DAO_PROFILE=1
-
-#SAMPLE_PROFILE=ao_sample_profile.c \
-# ao_sample_profile_timer.c
-#SAMPLE_PROFILE_DEF=-DHAS_SAMPLE_PROFILE=1
-
-#STACK_GUARD=ao_mpu_stm.c
-#STACK_GUARD_DEF=-DHAS_STACK_GUARD=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_cc1120.c \
- ao_fec_tx.c \
- ao_fec_rx.c \
- ao_usb_stm.c \
- ao_exti_stm.c \
- ao_monitor.c \
- ao_rssi.c \
- ao_send_packet.c \
- ao_packet_master.c \
- ao_eeprom_stm.c \
- ao_packet.c
-
-PRODUCT=MegaDongle-v0.1
-PRODUCT_DEF=-DMEGADONGLE
-IDPRODUCT=0x0024
-
-CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) $(PROFILE_DEF) $(SAMPLE_PROFILE_DEF) $(STACK_GUARD_DEF) -Os -g
-
-PROGNAME=megadongle-v0.1
-PROG=$(PROGNAME)-$(VERSION).elf
-HEX=$(PROGNAME)-$(VERSION).ihx
-
-SRC=$(ALTOS_SRC) ao_megadongle.c
-OBJ=$(SRC:.c=.o)
-
-all: $(PROG) $(HEX)
-
-$(PROG): Makefile $(OBJ) altos.ld
- $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS)
-
-$(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/megadongle-v0.1/ao_megadongle.c b/src/megadongle-v0.1/ao_megadongle.c
deleted file mode 100644
index e6821a3e..00000000
--- a/src/megadongle-v0.1/ao_megadongle.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright © 2012 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>
-#include <ao_exti.h>
-#include <ao_packet.h>
-#include <ao_send_packet.h>
-
-int
-main(void)
-{
- ao_clock_init();
-
-#if HAS_STACK_GUARD
- ao_mpu_init();
-#endif
-
- ao_task_init();
- ao_led_init(LEDS_AVAILABLE);
- ao_led_on(AO_LED_RED);
- ao_timer_init();
-
- ao_spi_init();
- ao_dma_init();
- ao_exti_init();
-
- ao_cmd_init();
-
- ao_usb_init();
- ao_radio_init();
- ao_monitor_init();
- ao_rssi_init(AO_LED_RED);
- ao_packet_master_init();
- ao_send_packet_init();
-
- ao_config_init();
-
- ao_start_scheduler();
- return 0;
-}
diff --git a/src/megadongle-v0.1/ao_pins.h b/src/megadongle-v0.1/ao_pins.h
deleted file mode 100644
index 4d3ad4dd..00000000
--- a/src/megadongle-v0.1/ao_pins.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright © 2012 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.
- */
-
-/* Using TeleMetrum v1.9 board */
-
-#ifndef _AO_PINS_H_
-#define _AO_PINS_H_
-
-#define HAS_TASK_QUEUE 1
-
-/* 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_SERIAL_1 0
-#define USE_SERIAL_1_STDIN 0
-#define SERIAL_1_PB6_PB7 0
-#define SERIAL_1_PA9_PA10 0
-
-#define HAS_SERIAL_2 0
-#define USE_SERIAL_2_STDIN 0
-#define SERIAL_2_PA2_PA3 0
-#define SERIAL_2_PD5_PD6 0
-
-#define HAS_SERIAL_3 0
-#define USE_SERIAL_3_STDIN 0
-#define SERIAL_3_PB10_PB11 0
-#define SERIAL_3_PC10_PC11 0
-#define SERIAL_3_PD8_PD9 0
-
-#define HAS_EEPROM 1
-#define USE_INTERNAL_FLASH 1
-#define USE_STORAGE_CONFIG 0
-#define USE_EEPROM_CONFIG 1
-#define HAS_USB 1
-#define HAS_BEEP 0
-#define HAS_RADIO 1
-#define HAS_TELEMETRY 0
-#define HAS_RSSI 1
-
-#define HAS_SPI_1 0
-#define SPI_1_PA5_PA6_PA7 0 /* Barometer */
-#define SPI_1_PB3_PB4_PB5 0
-#define SPI_1_PE13_PE14_PE15 0 /* Accelerometer */
-
-#define HAS_SPI_2 1
-#define SPI_2_PB13_PB14_PB15 1 /* Radio */
-#define SPI_2_PD1_PD3_PD4 0
-#define SPI_2_OSPEEDR STM_OSPEEDR_10MHz
-
-#define SPI_2_PORT (&stm_gpiob)
-#define SPI_2_SCK_PIN 13
-#define SPI_2_MISO_PIN 14
-#define SPI_2_MOSI_PIN 15
-
-#define PACKET_HAS_SLAVE 0
-#define PACKET_HAS_MASTER 1
-
-#define LOW_LEVEL_DEBUG 0
-
-#define LED_PORT_0_ENABLE STM_RCC_AHBENR_GPIOCEN
-#define LED_PORT_0 (&stm_gpioc)
-#define LED_PORT_0_MASK (0xffff)
-#define LED_PORT_0_SHIFT 0
-#define LED_PIN_RED 14
-#define LED_PIN_GREEN 15
-#define AO_LED_RED (1 << LED_PIN_RED)
-#define AO_LED_GREEN (1 << LED_PIN_GREEN)
-
-#define LEDS_AVAILABLE (AO_LED_RED | AO_LED_GREEN)
-
-#define HAS_GPS 0
-#define HAS_FLIGHT 0
-#define HAS_ADC 0
-#define HAS_LOG 0
-
-/*
- * Telemetry monitoring
- */
-#define HAS_MONITOR 1
-#define LEGACY_MONITOR 0
-#define HAS_MONITOR_PUT 1
-#define AO_MONITOR_LED AO_LED_GREEN
-
-/*
- * Radio (cc1120)
- */
-
-/* gets pretty close to 434.550 */
-
-#define AO_RADIO_CAL_DEFAULT 0x6ca333
-
-#define AO_FEC_DEBUG 0
-#define AO_CC1120_SPI_CS_PORT (&stm_gpioa)
-#define AO_CC1120_SPI_CS_PIN 2
-#define AO_CC1120_SPI_BUS AO_SPI_2_PB13_PB14_PB15
-#define AO_CC1120_SPI stm_spi2
-
-#define AO_CC1120_INT_PORT (&stm_gpioa)
-#define AO_CC1120_INT_PIN 3
-
-#define AO_CC1120_MCU_WAKEUP_PORT (&stm_gpioa)
-#define AO_CC1120_MCU_WAKEUP_PIN (4)
-
-#define AO_CC1120_INT_GPIO 2
-#define AO_CC1120_INT_GPIO_IOCFG CC1120_IOCFG2
-
-#define AO_CC1120_MARC_GPIO 3
-#define AO_CC1120_MARC_GPIO_IOCFG CC1120_IOCFG3
-
-/*
- * Profiling Viterbi decoding
- */
-
-#ifndef AO_PROFILE
-#define AO_PROFILE 0
-#endif
-
-#endif /* _AO_PINS_H_ */
diff --git a/src/megadongle-v0.1/flash-loader/ao_pins.h b/src/megadongle-v0.1/flash-loader/ao_pins.h
deleted file mode 100644
index 2b18f8e5..00000000
--- a/src/megadongle-v0.1/flash-loader/ao_pins.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright © 2013 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.
- */
-
-#ifndef _AO_PINS_H_
-#define _AO_PINS_H_
-
-/* External crystal at 8MHz */
-#define AO_HSE 8000000
-
-#include <ao_flash_stm_pins.h>
-
-/* Companion port cs_companion0 PD0 */
-
-#define AO_BOOT_PIN 1
-#define AO_BOOT_APPLICATION_GPIO stm_gpiod
-#define AO_BOOT_APPLICATION_PIN 0
-#define AO_BOOT_APPLICATION_VALUE 1
-#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP
-
-#endif /* _AO_PINS_H_ */
diff --git a/src/microkite/Makefile b/src/microkite/Makefile
index b7523758..5eb97206 100644
--- a/src/microkite/Makefile
+++ b/src/microkite/Makefile
@@ -29,7 +29,7 @@ LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w:
ALTOS_SRC = \
ao_micropeak.c \
ao_spi_attiny.c \
- ao_led.c \
+ ao_led_tiny.c \
ao_clock.c \
ao_ms5607.c \
ao_exti.c \
diff --git a/src/micropeak-v2.0/Makefile b/src/micropeak-v2.0/Makefile
index 32154fa6..c7d1b22d 100644
--- a/src/micropeak-v2.0/Makefile
+++ b/src/micropeak-v2.0/Makefile
@@ -18,7 +18,7 @@ ALTOS_SRC = \
ao_micropeak.c \
ao_spi_stm.c \
ao_dma_stm.c \
- ao_led.c \
+ ao_led_stmf0.c \
ao_timer.c \
ao_ms5607.c \
ao_exti_stm.c \
diff --git a/src/micropeak-v2.0/ao_micropeak.c b/src/micropeak-v2.0/ao_micropeak.c
index 1cfa1209..df557e60 100644
--- a/src/micropeak-v2.0/ao_micropeak.c
+++ b/src/micropeak-v2.0/ao_micropeak.c
@@ -252,7 +252,7 @@ main(void)
else
ao_hsi_init();
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
ao_task_init();
ao_timer_init();
ao_serial_init();
diff --git a/src/micropeak-v2.0/micropeak.ld b/src/micropeak-v2.0/micropeak.ld
index baeae5b8..a73d4c1d 100644
--- a/src/micropeak-v2.0/micropeak.ld
+++ b/src/micropeak-v2.0/micropeak.ld
@@ -90,7 +90,7 @@ SECTIONS {
*/
.textram BLOCK(8): {
- __data_start__ = .;
+ _start__ = .;
*(.ramtext)
} >ram AT>rom
@@ -99,7 +99,7 @@ SECTIONS {
*/
.data BLOCK(8): {
*(.data) /* initialized data */
- __data_end__ = .;
+ _end__ = .;
} >ram AT>rom
.bss : {
diff --git a/src/micropeak/Makefile b/src/micropeak/Makefile
index 6e8cae14..f80d61b0 100644
--- a/src/micropeak/Makefile
+++ b/src/micropeak/Makefile
@@ -29,7 +29,7 @@ LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w:
ALTOS_SRC = \
ao_micropeak.c \
ao_spi_attiny.c \
- ao_led.c \
+ ao_led_tiny.c \
ao_clock.c \
ao_ms5607.c \
ao_exti.c \
diff --git a/src/microsplash/Makefile b/src/microsplash/Makefile
index 9bb636f1..0342838e 100644
--- a/src/microsplash/Makefile
+++ b/src/microsplash/Makefile
@@ -29,7 +29,7 @@ LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w:
ALTOS_SRC = \
ao_micropeak.c \
ao_spi_attiny.c \
- ao_led.c \
+ ao_led_tiny.c \
ao_clock.c \
ao_ms5607.c \
ao_exti.c \
diff --git a/src/nanopeak-v0.1/Makefile b/src/nanopeak-v0.1/Makefile
index d3779594..774d4adc 100644
--- a/src/nanopeak-v0.1/Makefile
+++ b/src/nanopeak-v0.1/Makefile
@@ -19,7 +19,7 @@ LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w:
ALTOS_SRC = \
ao_micropeak.c \
ao_spi_attiny.c \
- ao_led.c \
+ ao_led_tiny.c \
ao_clock.c \
ao_ms5607.c \
ao_exti.c \
diff --git a/src/nucleao-32/Makefile b/src/nucleao-32/Makefile
index 2b9fe14f..1ab2eea1 100644
--- a/src/nucleao-32/Makefile
+++ b/src/nucleao-32/Makefile
@@ -26,7 +26,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stmf0.c \
ao_beep_stm.c \
ao_dma_stm.c \
ao_stdio.c \
diff --git a/src/nucleao-32/load.ld b/src/nucleao-32/load.ld
index 02a23a95..945f7c60 100644
--- a/src/nucleao-32/load.ld
+++ b/src/nucleao-32/load.ld
@@ -82,10 +82,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/pnpservo-v1/Makefile b/src/pnpservo-v1/Makefile
index 8606b1ae..443a6afb 100644
--- a/src/pnpservo-v1/Makefile
+++ b/src/pnpservo-v1/Makefile
@@ -24,7 +24,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stmf0.c \
ao_dma_stm.c \
ao_stdio.c \
ao_mutex.c \
diff --git a/src/pnpservo-v1/lambda.ld b/src/pnpservo-v1/lambda.ld
index 5de65eb5..d3edbe9f 100644
--- a/src/pnpservo-v1/lambda.ld
+++ b/src/pnpservo-v1/lambda.ld
@@ -85,7 +85,7 @@ SECTIONS {
*/
.textram BLOCK(8): {
- __data_start__ = .;
+ _start__ = .;
__text_ram_start__ = .;
*(.ramtext)
__text_ram_end = .;
@@ -96,7 +96,7 @@ SECTIONS {
.data : {
*(.data) /* initialized data */
. = ALIGN(4);
- __data_end__ = .;
+ _end__ = .;
} >ram AT>rom
.bss : {
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/product/ao_flash_task.c b/src/product/ao_flash_task.c
index 1f0edb05..a680ca18 100644
--- a/src/product/ao_flash_task.c
+++ b/src/product/ao_flash_task.c
@@ -29,7 +29,7 @@ ao_panic(uint8_t reason)
}
void
-ao_put_string(__code char *s)
+ao_put_string(const char *s)
{
char c;
while ((c = *s++)) {
diff --git a/src/product/ao_micropeak.c b/src/product/ao_micropeak.c
index 8aac79cd..8fed3069 100644
--- a/src/product/ao_micropeak.c
+++ b/src/product/ao_micropeak.c
@@ -57,7 +57,7 @@ ao_pips(void)
int
main(void)
{
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
ao_timer_init();
/* Init external hardware */
diff --git a/src/product/ao_telemetrum.c b/src/product/ao_telemetrum.c
index a10cb384..1266fee7 100644
--- a/src/product/ao_telemetrum.c
+++ b/src/product/ao_telemetrum.c
@@ -60,7 +60,7 @@ main(void)
ao_gps_report_init();
ao_telemetry_init();
ao_radio_init();
- ao_packet_slave_init(FALSE);
+ ao_packet_slave_init(false);
ao_igniter_init();
#if HAS_DBG
ao_dbg_init();
diff --git a/src/product/ao_telemini.c b/src/product/ao_telemini.c
index 14414a48..d9cb676b 100644
--- a/src/product/ao_telemini.c
+++ b/src/product/ao_telemini.c
@@ -56,7 +56,7 @@ main(void)
ao_report_init();
ao_telemetry_init();
ao_radio_init();
- ao_packet_slave_init(TRUE);
+ ao_packet_slave_init(true);
ao_igniter_init();
ao_config_init();
ao_start_scheduler();
diff --git a/src/product/ao_telenano.c b/src/product/ao_telenano.c
index ac08979f..1b04edc5 100644
--- a/src/product/ao_telenano.c
+++ b/src/product/ao_telenano.c
@@ -40,7 +40,7 @@ main(void)
ao_report_init();
ao_telemetry_init();
ao_radio_init();
- ao_packet_slave_init(TRUE);
+ ao_packet_slave_init(true);
ao_config_init();
ao_start_scheduler();
}
diff --git a/src/product/ao_teleterra.c b/src/product/ao_teleterra.c
index 0142f9e3..ae129233 100644
--- a/src/product/ao_teleterra.c
+++ b/src/product/ao_teleterra.c
@@ -34,7 +34,7 @@ main(void)
ao_cmd_init();
ao_usb_init();
ao_serial_init();
- ao_monitor_init(AO_LED_GREEN, TRUE);
+ ao_monitor_init(AO_LED_GREEN, true);
ao_radio_init();
ao_config_init();
ao_start_scheduler();
diff --git a/src/product/ao_terraui.c b/src/product/ao_terraui.c
index c2bbc30e..3a989f5a 100644
--- a/src/product/ao_terraui.c
+++ b/src/product/ao_terraui.c
@@ -20,15 +20,15 @@
#include <ao_flight.h>
#include <math.h>
-static __xdata struct ao_telemetry_sensor ao_tel_sensor;
-static __xdata struct ao_telemetry_location ao_tel_location;
-static __xdata struct ao_telemetry_configuration ao_tel_config;
-static __xdata int16_t ao_tel_max_speed;
-static __xdata int16_t ao_tel_max_height;
+static struct ao_telemetry_sensor ao_tel_sensor;
+static struct ao_telemetry_location ao_tel_location;
+static struct ao_telemetry_configuration ao_tel_config;
+static int16_t ao_tel_max_speed;
+static int16_t ao_tel_max_height;
static int8_t ao_tel_rssi;
-static __xdata char ao_lcd_line[17];
-static __xdata char ao_state_name[] = "SIPBFCDMLI";
+static char ao_lcd_line[17];
+static char ao_state_name[] = "SIPBFCDMLI";
static void
ao_terraui_line(uint8_t addr)
@@ -85,7 +85,7 @@ ao_terraui_logging(void)
return '-';
}
-static __code char ao_progress[4] = { '\011', '\012', '\014', '\013' };
+static const char ao_progress[4] = { '\011', '\012', '\014', '\013' };
static uint8_t ao_telem_progress;
static uint8_t ao_gps_progress;
@@ -165,7 +165,7 @@ static int16_t mag(int32_t d)
static int32_t
dist(int32_t d)
{
- __pdata uint32_t m;
+ uint32_t m;
uint8_t neg = 0;
if (d < 0) {
@@ -184,7 +184,7 @@ dist(int32_t d)
return d;
}
-static __code uint8_t cos_table[] = {
+static const uint8_t cos_table[] = {
0, /* 0 */
0, /* 1 */
0, /* 2 */
@@ -242,7 +242,7 @@ static __code uint8_t cos_table[] = {
1, /* 54 */
};
-static __code uint8_t tan_table[] = {
+static const uint8_t tan_table[] = {
0, /* 0 */
4, /* 1 */
9, /* 2 */
@@ -290,7 +290,7 @@ static __code uint8_t tan_table[] = {
247, /* 44 */
};
-int16_t ao_atan2(int32_t dy, int32_t dx) __reentrant
+int16_t ao_atan2(int32_t dy, int32_t dx)
{
int8_t m = 1;
int16_t a = 0;
@@ -334,10 +334,10 @@ int16_t ao_atan2(int32_t dy, int32_t dx) __reentrant
return t * m + a;
}
-static __pdata int32_t lon_dist, lat_dist;
-static __pdata uint32_t ground_dist, range;
-static __pdata uint8_t dist_in_km;
-static __pdata int16_t bearing, elevation;
+static int32_t lon_dist, lat_dist;
+static uint32_t ground_dist, range;
+static uint8_t dist_in_km;
+static int16_t bearing, elevation;
static void
ao_terraui_lat_dist(void)
@@ -346,7 +346,7 @@ ao_terraui_lat_dist(void)
}
static void
-ao_terraui_lon_dist(void) __reentrant
+ao_terraui_lon_dist(void)
{
uint8_t c = cos_table[ao_gps_data.latitude >> 24];
lon_dist = ao_tel_location.longitude;
@@ -418,7 +418,7 @@ ao_terraui_recover(void)
}
static void
-ao_terraui_coord(int32_t c, char plus, char minus, char extra) __reentrant
+ao_terraui_coord(int32_t c, char plus, char minus, char extra)
{
uint16_t d;
uint8_t m;
@@ -448,7 +448,7 @@ ao_terraui_remote(void)
}
static void
-ao_terraui_local(void) __reentrant
+ao_terraui_local(void)
{
ao_terraui_coord(ao_gps_data.latitude, 'n', 's',
ao_terraui_local_gps());
@@ -457,11 +457,11 @@ ao_terraui_local(void) __reentrant
ao_terraui_line(AO_LCD_ADDR(1,0));
}
-static __pdata uint8_t ao_set_freq;
-static __pdata uint32_t ao_set_freq_orig;
+static uint8_t ao_set_freq;
+static uint32_t ao_set_freq_orig;
static void
-ao_terraui_freq(void) __reentrant
+ao_terraui_freq(void)
{
uint16_t MHz;
uint16_t frac;
@@ -508,7 +508,7 @@ ao_terraui_freq_button(char b) {
ao_radio_recv_abort();
}
-static __code void (*__code ao_terraui_page[])(void) = {
+static const void (*const ao_terraui_page[])(void) = {
ao_terraui_startup,
ao_terraui_info,
ao_terraui_pad,
@@ -521,8 +521,8 @@ static __code void (*__code ao_terraui_page[])(void) = {
#define NUM_PAGE (sizeof (ao_terraui_page)/sizeof (ao_terraui_page[0]))
-static __pdata uint8_t ao_current_page = 0;
-static __pdata uint8_t ao_shown_about = 3;
+static uint8_t ao_current_page = 0;
+static uint8_t ao_shown_about = 3;
static void
ao_terraui(void)
@@ -575,7 +575,7 @@ ao_terraui(void)
}
}
-__xdata static struct ao_task ao_terraui_task;
+static struct ao_task ao_terraui_task;
static void
ao_terramonitor(void)
@@ -588,7 +588,7 @@ ao_terramonitor(void)
monitor = ao_monitor_ring_next(monitor))
{
while (monitor == ao_monitor_head)
- ao_sleep(DATA_TO_XDATA(&ao_monitor_head));
+ ao_sleep(&ao_monitor_head);
if (ao_monitoring != sizeof (union ao_telemetry_all))
continue;
if (!(ao_monitor_ring[monitor].all.status & PKT_APPEND_STATUS_1_CRC_OK))
@@ -619,7 +619,7 @@ ao_terramonitor(void)
}
}
-__xdata static struct ao_task ao_terramonitor_task;
+static struct ao_task ao_terramonitor_task;
static void
ao_terragps(void)
@@ -634,7 +634,7 @@ ao_terragps(void)
}
}
-__xdata static struct ao_task ao_terragps_task;
+static struct ao_task ao_terragps_task;
void
ao_terraui_init(void)
diff --git a/src/product/ao_test.c b/src/product/ao_test.c
index d1c60804..5db36293 100644
--- a/src/product/ao_test.c
+++ b/src/product/ao_test.c
@@ -18,13 +18,13 @@
#include "ao.h"
-struct ao_task __xdata blink_0_task;
-struct ao_task __xdata blink_1_task;
-struct ao_task __xdata wakeup_task;
-struct ao_task __xdata beep_task;
-struct ao_task __xdata echo_task;
+struct ao_task blink_0_task;
+struct ao_task blink_1_task;
+struct ao_task wakeup_task;
+struct ao_task beep_task;
+struct ao_task echo_task;
-void delay(int n) __reentrant
+void delay(int n)
{
uint8_t j = 0;
while (--n)
@@ -32,7 +32,7 @@ void delay(int n) __reentrant
ao_yield();
}
-static __xdata uint8_t blink_chan;
+static uint8_t blink_chan;
void
blink_0(void)
@@ -51,7 +51,7 @@ blink_0(void)
void
blink_1(void)
{
- static __xdata struct ao_adc adc;
+ static struct ao_adc adc;
for (;;) {
ao_sleep(&ao_adc_head);
@@ -75,7 +75,7 @@ wakeup(void)
void
beep(void)
{
- static __xdata struct ao_adc adc;
+ static struct ao_adc adc;
for (;;) {
ao_delay(AO_SEC_TO_TICKS(1));
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 <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.
- */
-
-#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 <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>
-#include <ao_radio_spi.h>
-
-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/stm-bringup/bringup.ld b/src/stm-bringup/bringup.ld
index dcdcf073..71039598 100644
--- a/src/stm-bringup/bringup.ld
+++ b/src/stm-bringup/bringup.ld
@@ -44,13 +44,13 @@ SECTIONS {
} > rom
. = ORIGIN(ram);
- __data_start__ = .;
+ _start__ = .;
/* Data -- relocated to RAM, but written to ROM
*/
.data : AT (ADDR(.ARM.exidx) + SIZEOF (.ARM.exidx)) {
*(.data) /* initialized data */
- __data_end__ = .;
+ _end__ = .;
__bss_start__ = .;
} >ram
diff --git a/src/stm-demo/Makefile b/src/stm-demo/Makefile
index d4569c1a..ccce37a5 100644
--- a/src/stm-demo/Makefile
+++ b/src/stm-demo/Makefile
@@ -23,7 +23,7 @@ ALTOS_SRC = \
ao_romconfig.c \
ao_cmd.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/stm-demo/ao_demo.c b/src/stm-demo/ao_demo.c
index f6c8e3df..4b963e42 100644
--- a/src/stm-demo/ao_demo.c
+++ b/src/stm-demo/ao_demo.c
@@ -125,7 +125,7 @@ ao_i2c_write(void) {
for (i = 0; i < 10; i++) {
ao_i2c_get(0);
if (ao_i2c_start(0, 0x55))
- ao_i2c_send(data, 4, 0, TRUE);
+ ao_i2c_send(data, 4, 0, true);
else {
printf ("i2c start failed\n");
ao_i2c_put(0);
@@ -197,7 +197,7 @@ ao_blink_toggle(void)
}
-__code struct ao_cmds ao_demo_cmds[] = {
+const struct ao_cmds ao_demo_cmds[] = {
{ ao_dma_test, "D\0DMA test" },
{ ao_spi_write, "W\0SPI write" },
{ ao_spi_read, "R\0SPI read" },
diff --git a/src/stm-scheme-newlib/Makefile b/src/stm-scheme-newlib/Makefile
index a4c249a3..1db58f10 100644
--- a/src/stm-scheme-newlib/Makefile
+++ b/src/stm-scheme-newlib/Makefile
@@ -30,7 +30,7 @@ ALTOS_SRC = \
ao_romconfig.c \
ao_cmd.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio_newlib.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/stm-scheme-newlib/ao_demo.c b/src/stm-scheme-newlib/ao_demo.c
index 13a31288..cb8e10e8 100644
--- a/src/stm-scheme-newlib/ao_demo.c
+++ b/src/stm-scheme-newlib/ao_demo.c
@@ -26,7 +26,7 @@ static void scheme_cmd() {
}
-__code struct ao_cmds ao_demo_cmds[] = {
+const struct ao_cmds ao_demo_cmds[] = {
{ scheme_cmd, "l\0Run scheme interpreter" },
{ 0, NULL }
};
diff --git a/src/stm-vga/Makefile b/src/stm-vga/Makefile
index 46a77272..fa0d008f 100644
--- a/src/stm-vga/Makefile
+++ b/src/stm-vga/Makefile
@@ -28,7 +28,7 @@ ALTOS_SRC = \
ao_romconfig.c \
ao_cmd.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/stm-vga/ao_demo.c b/src/stm-vga/ao_demo.c
index 1b443b1f..593a8743 100644
--- a/src/stm-vga/ao_demo.c
+++ b/src/stm-vga/ao_demo.c
@@ -159,17 +159,16 @@ ao_fb_init(void)
static void
ao_video_toggle(void)
{
- ao_cmd_decimal();
- if (ao_cmd_lex_i)
+ uint16_t r = ao_cmd_decimal();
+ if (r)
ao_fb_init();
- ao_vga_enable(ao_cmd_lex_i);
+ ao_vga_enable(r);
}
static void
ao_ball_toggle(void)
{
- ao_cmd_decimal();
- ball_enable = ao_cmd_lex_i;
+ ball_enable = ao_cmd_decimal();
ao_wakeup(&ball_enable);
}
@@ -198,7 +197,7 @@ ao_console_send(void)
}
}
-__code struct ao_cmds ao_demo_cmds[] = {
+const struct ao_cmds ao_demo_cmds[] = {
{ ao_video_toggle, "V\0Toggle video" },
{ ao_ball_toggle, "B\0Toggle ball" },
{ ao_ps2_read_keys, "K\0Read keys from keyboard" },
diff --git a/src/stm/Makefile-flash.defs b/src/stm/Makefile-flash.defs
index dde51a68..66ad1637 100644
--- a/src/stm/Makefile-flash.defs
+++ b/src/stm/Makefile-flash.defs
@@ -12,10 +12,14 @@ endif
include $(TOPDIR)/Makedefs
CC=$(ARM_CC)
-LIBS=$(PDCLIB_LIBS_M3) -lgcc
+LIBS=-L$(NEWLIB_NANO)/arm-none-eabi/lib/thumb/v7-m -lc -lm -lgcc
-AO_CFLAGS=-I. -I$(TOPDIR)/stm -I$(TOPDIR)/kernel -I$(TOPDIR)/drivers -I$(TOPDIR)/product -I$(TOPDIR) $(PDCLIB_INCLUDES)
-STM_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m3 -mthumb -ffreestanding -nostdlib $(AO_CFLAGS) $(SAT_CFLAGS)
+AO_CFLAGS=-I. -I$(TOPDIR)/stm -I$(TOPDIR)/kernel -I$(TOPDIR)/drivers \
+ -DNEWLIB_INTEGER_PRINTF_SCANF \
+ -I$(TOPDIR)/product -I$(TOPDIR) -isystem $(NEWLIB_NANO)/arm-none-eabi/include
+
+STM_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m3 -mthumb \
+ -ffreestanding -nostdlib $(AO_CFLAGS) $(SAT_CFLAGS)
LDFLAGS=-L$(TOPDIR)/stm -Wl,-Taltos-loader.ld
diff --git a/src/stm/Makefile.defs b/src/stm/Makefile.defs
index 4d0d27c7..8173b349 100644
--- a/src/stm/Makefile.defs
+++ b/src/stm/Makefile.defs
@@ -22,15 +22,18 @@ endif
include $(TOPDIR)/Makedefs
CC=$(ARM_CC)
-LIBS=$(PDCLIB_LIBS_M3) -lgcc
+LIBS=-L$(NEWLIB_NANO)/arm-none-eabi/lib/thumb/v7-m -lm -lc -lgcc
WARN_FLAGS=-Wall -Wextra -Werror
-AO_CFLAGS=-I. -I../stm -I../kernel -I../drivers -I../math -I../draw -I../lisp -I.. $(PDCLIB_INCLUDES)
+AO_CFLAGS=-I. -I../stm -I../kernel -I../drivers -I../math -I../draw \
+ -DNEWLIB_INTEGER_PRINTF_SCANF \
+ -I../lisp -I.. -isystem $(NEWLIB_NANO)/arm-none-eabi/include
+
STM_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m3 -mthumb -Wcast-align \
-ffreestanding -nostdlib $(AO_CFLAGS) $(WARN_FLAGS)
-LDFLAGS=-L../stm -Wl,-Taltos.ld
+LDFLAGS=-L../stm -Wl,-Taltos.ld -nostartfiles -Wl,-Map=$(PROGNAME).map
NICKLE=nickle
ELFTOHEX=$(TOPDIR)/../ao-tools/ao-elftohex/ao-elftohex
diff --git a/src/stm/altos-512.ld b/src/stm/altos-512.ld
index 78c41685..97a9c437 100644
--- a/src/stm/altos-512.ld
+++ b/src/stm/altos-512.ld
@@ -74,10 +74,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/stm/altos-loader.ld b/src/stm/altos-loader.ld
index 806b4842..1ebbc7a2 100644
--- a/src/stm/altos-loader.ld
+++ b/src/stm/altos-loader.ld
@@ -65,7 +65,7 @@ SECTIONS {
*/
.textram BLOCK(8): {
- __data_start__ = .;
+ _start__ = .;
__text_ram_start__ = .;
*(.ramtext)
__text_ram_end = .;
@@ -76,7 +76,7 @@ SECTIONS {
*/
.data BLOCK(8): {
*(.data) /* initialized data */
- __data_end__ = .;
+ _end__ = .;
} >ram AT>rom
diff --git a/src/stm/altos-ram.ld b/src/stm/altos-ram.ld
index 098454e1..d8f072a7 100644
--- a/src/stm/altos-ram.ld
+++ b/src/stm/altos-ram.ld
@@ -42,13 +42,13 @@ SECTIONS {
__text_end__ = .;
} > ram
- __data_start__ = .;
+ _start__ = .;
/* Data -- relocated to RAM, but written to ROM
*/
.data : AT (ADDR(.ARM.exidx) + SIZEOF (.ARM.exidx)) {
*(.data) /* initialized data */
- __data_end__ = .;
+ _end__ = .;
__bss_start__ = .;
} >ram
diff --git a/src/stm/altos.ld b/src/stm/altos.ld
index 6a8c7113..e352ed36 100644
--- a/src/stm/altos.ld
+++ b/src/stm/altos.ld
@@ -74,10 +74,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/stm/ao_adc_single_stm.c b/src/stm/ao_adc_single_stm.c
index 8a7fda4a..5737cd50 100644
--- a/src/stm/ao_adc_single_stm.c
+++ b/src/stm/ao_adc_single_stm.c
@@ -95,7 +95,7 @@ ao_adc_dump(void)
AO_ADC_DUMP(&packet);
}
-__code struct ao_cmds ao_adc_cmds[] = {
+const struct ao_cmds ao_adc_cmds[] = {
{ ao_adc_dump, "a\0Display current ADC values" },
{ 0, NULL },
};
diff --git a/src/stm/ao_adc_stm.c b/src/stm/ao_adc_stm.c
index 24912bb2..ffdcccc0 100644
--- a/src/stm/ao_adc_stm.c
+++ b/src/stm/ao_adc_stm.c
@@ -45,26 +45,7 @@ static void ao_adc_done(int index)
(void) index;
AO_DATA_PRESENT(AO_DATA_ADC);
ao_dma_done_transfer(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC1));
- 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
-#if HAS_MPU9250
- ao_data_ring[ao_data_head].mpu9250 = ao_mpu9250_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;
}
@@ -100,7 +81,7 @@ ao_adc_poll(void)
* Fetch a copy of the most recent ADC data
*/
void
-ao_adc_get(__xdata struct ao_adc *packet)
+ao_adc_get(struct ao_adc *packet)
{
#if HAS_FLIGHT
uint8_t i = ao_data_ring_prev(ao_sample_data);
@@ -177,7 +158,7 @@ static const char *ao_adc_name[AO_NUM_ADC] = {
#endif
static void
-ao_adc_dump(void) __reentrant
+ao_adc_dump(void)
{
struct ao_data packet;
#ifndef AO_ADC_DUMP
@@ -203,7 +184,7 @@ ao_adc_dump(void) __reentrant
#endif
}
-__code struct ao_cmds ao_adc_cmds[] = {
+const struct ao_cmds ao_adc_cmds[] = {
{ ao_adc_dump, "a\0Display current ADC values" },
{ 0, NULL },
};
diff --git a/src/stm/ao_arch.h b/src/stm/ao_arch.h
index 679dba44..e56375ca 100644
--- a/src/stm/ao_arch.h
+++ b/src/stm/ao_arch.h
@@ -41,11 +41,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)
@@ -57,28 +52,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
-
-extern const uint16_t ao_romconfig_version;
-extern const uint16_t ao_romconfig_check;
-extern const uint16_t ao_serial_number;
-extern const uint32_t ao_radio_cal;
+#define AO_ROMCONFIG_SYMBOL __attribute__((section(".romconfig"))) const
#define ao_arch_task_members\
uint32_t *sp; /* saved stack pointer */
diff --git a/src/stm/ao_arch_funcs.h b/src/stm/ao_arch_funcs.h
index 522059bc..7fe6a732 100644
--- a/src/stm/ao_arch_funcs.h
+++ b/src/stm/ao_arch_funcs.h
@@ -39,6 +39,9 @@
#define AO_SPI_SPEED_200kHz AO_SPI_SPEED_125kHz
+#define AO_SPI_CPOL_BIT 4
+#define AO_SPI_CPHA_BIT 5
+
#define AO_SPI_CONFIG_1 0x00
#define AO_SPI_1_CONFIG_PA5_PA6_PA7 AO_SPI_CONFIG_1
#define AO_SPI_2_CONFIG_PB13_PB14_PB15 AO_SPI_CONFIG_1
@@ -64,6 +67,15 @@
#define AO_SPI_INDEX(id) ((id) & AO_SPI_INDEX_MASK)
#define AO_SPI_CONFIG(id) ((id) & AO_SPI_CONFIG_MASK)
+#define AO_SPI_PIN_CONFIG(id) ((id) & (AO_SPI_INDEX_MASK | AO_SPI_CONFIG_MASK))
+#define AO_SPI_CPOL(id) ((uint32_t) (((id) >> AO_SPI_CPOL_BIT) & 1))
+#define AO_SPI_CPHA(id) ((uint32_t) (((id) >> AO_SPI_CPHA_BIT) & 1))
+
+#define AO_SPI_MAKE_MODE(pol,pha) (((pol) << AO_SPI_CPOL_BIT) | ((pha) << AO_SPI_CPHA_BIT))
+#define AO_SPI_MODE_0 AO_SPI_MAKE_MODE(0,0)
+#define AO_SPI_MODE_1 AO_SPI_MAKE_MODE(0,1)
+#define AO_SPI_MODE_2 AO_SPI_MAKE_MODE(1,0)
+#define AO_SPI_MODE_3 AO_SPI_MAKE_MODE(1,1)
uint8_t
ao_spi_try_get(uint8_t spi_index, uint32_t speed, uint8_t task_id);
@@ -166,8 +178,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)
#define ao_enable_port(port) do { \
if ((port) == &stm_gpioa) \
@@ -196,9 +208,9 @@ ao_spi_try_get_mask(struct stm_gpio *reg, uint16_t mask, uint8_t bus, uint32_t s
} while (0)
-#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_gpio_set_bits(port, bits) stm_gpio_set_bits(port, bits)
@@ -208,9 +220,9 @@ ao_spi_try_get_mask(struct stm_gpio *reg, uint16_t mask, uint8_t bus, uint32_t s
#define ao_gpio_get_all(port) stm_gpio_get_all(port)
-#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)
@@ -223,7 +235,7 @@ ao_spi_try_get_mask(struct stm_gpio *reg, uint16_t mask, uint8_t bus, uint32_t s
#define AO_OUTPUT_PUSH_PULL STM_OTYPER_PUSH_PULL
#define AO_OUTPUT_OPEN_DRAIN STM_OTYPER_OPEN_DRAIN
-#define ao_gpio_set_output_mode(port,bit,pin,mode) \
+#define ao_gpio_set_output_mode(port,bit,mode) \
stm_otyper_set(port, pin, mode)
#define ao_gpio_set_mode(port,bit,mode) do { \
@@ -248,8 +260,8 @@ ao_spi_try_get_mask(struct stm_gpio *reg, uint16_t mask, uint8_t bus, uint32_t s
stm_moder_set(port, bit, STM_MODER_INPUT); \
} while (0)
-#define ao_set_output(port, bit, pin, v) do { \
- ao_gpio_set(port, bit, pin, v); \
+#define ao_set_output(port, bit, v) do { \
+ ao_gpio_set(port, bit, v); \
stm_moder_set(port, bit, STM_MODER_OUTPUT); \
} while (0)
diff --git a/src/stm/ao_beep_stm.c b/src/stm/ao_beep_stm.c
index 0b4e6012..2746d7f8 100644
--- a/src/stm/ao_beep_stm.c
+++ b/src/stm/ao_beep_stm.c
@@ -18,37 +18,59 @@
#include "ao.h"
-#ifndef BEEPER_CHANNEL
-#define BEEPER_CHANNEL 1
+#if BEEPER_TIMER == 2
+#define stm_beeper stm_tim2
+#define RCC_BEEPER STM_RCC_APB1ENR_TIM2EN
+#define BEEPER_AFR STM_AFR_AF1
+#elif BEEPER_TIMER == 3
+#define stm_beeper stm_tim3
+#define RCC_BEEPER STM_RCC_APB1ENR_TIM3EN
+#define BEEPER_AFR STM_AFR_AF2
+#elif BEEPER_TIMER == 4
+#define stm_beeper stm_tim4
+#define RCC_BEEPER STM_RCC_APB1ENR_TIM4EN
+#define BEEPER_AFR STM_AFR_AF2
+#else
+#error BEEPER_TIMER must be 2, 3 or 4
#endif
void
ao_beep(uint8_t beep)
{
if (beep == 0) {
- stm_tim3.cr1 = 0;
- stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_TIM3EN);
+ stm_beeper.cr1 = 0;
+ stm_rcc.apb1enr &= ~(1 << RCC_BEEPER);
} else {
- stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_TIM3EN);
+ stm_rcc.apb1enr |= (1 << RCC_BEEPER);
- stm_tim3.cr2 = ((0 << STM_TIM234_CR2_TI1S) |
+ stm_beeper.cr2 = ((0 << STM_TIM234_CR2_TI1S) |
(STM_TIM234_CR2_MMS_RESET << STM_TIM234_CR2_MMS) |
(0 << STM_TIM234_CR2_CCDS));
/* Set prescaler to match cc1111 clocks
*/
- stm_tim3.psc = AO_TIM23467_CLK / 750000;
+ stm_beeper.psc = AO_TIM23467_CLK / 750000;
/* 1. Select the counter clock (internal, external, prescaler).
*
* Setting SMCR to zero means use the internal clock
*/
- stm_tim3.smcr = 0;
+ stm_beeper.smcr = 0;
/* 2. Write the desired data in the TIMx_ARR and TIMx_CCRx registers. */
- stm_tim3.arr = beep;
- stm_tim3.ccr1 = beep;
+ stm_beeper.arr = beep;
+#if BEEPER_CHANNEL == 1
+ stm_beeper.ccr1 = beep;
+#elif BEEPER_CHANNEL == 2
+ stm_beeper.ccr2 = beep;
+#elif BEEPER_CHANNEL == 3
+ stm_beeper.ccr3 = beep;
+#elif BEEPER_CHANNEL == 4
+ stm_beeper.ccr4 = beep;
+#else
+#error invalid BEEPER_CHANNEL
+#endif
/* 3. Set the CCxIE and/or CCxDE bits if an interrupt and/or a
* DMA request is to be generated.
@@ -61,63 +83,56 @@ ao_beep(uint8_t beep)
* is enabled and active high.
*/
-#if BEEPER_CHANNEL == 1
- stm_tim3.ccmr1 = ((0 << STM_TIM234_CCMR1_OC2CE) |
- (STM_TIM234_CCMR1_OC2M_FROZEN << STM_TIM234_CCMR1_OC2M) |
- (0 << STM_TIM234_CCMR1_OC2PE) |
- (0 << STM_TIM234_CCMR1_OC2FE) |
- (STM_TIM234_CCMR1_CC2S_OUTPUT << STM_TIM234_CCMR1_CC2S) |
-
- (0 << STM_TIM234_CCMR1_OC1CE) |
- (STM_TIM234_CCMR1_OC1M_TOGGLE << STM_TIM234_CCMR1_OC1M) |
- (0 << STM_TIM234_CCMR1_OC1PE) |
- (0 << STM_TIM234_CCMR1_OC1FE) |
- (STM_TIM234_CCMR1_CC1S_OUTPUT << STM_TIM234_CCMR1_CC1S));
-
- stm_tim3.ccer = ((0 << STM_TIM234_CCER_CC4NP) |
- (0 << STM_TIM234_CCER_CC4P) |
- (0 << STM_TIM234_CCER_CC4E) |
- (0 << STM_TIM234_CCER_CC3NP) |
- (0 << STM_TIM234_CCER_CC3P) |
- (0 << STM_TIM234_CCER_CC3E) |
- (0 << STM_TIM234_CCER_CC2NP) |
- (0 << STM_TIM234_CCER_CC2P) |
- (0 << STM_TIM234_CCER_CC2E) |
- (0 << STM_TIM234_CCER_CC1NP) |
- (0 << STM_TIM234_CCER_CC1P) |
- (1 << STM_TIM234_CCER_CC1E));
+#define OC1M (BEEPER_CHANNEL == 1 ? STM_TIM234_CCMR1_OC1M_TOGGLE : STM_TIM234_CCMR1_OC1M_FROZEN)
+#define OC2M (BEEPER_CHANNEL == 2 ? STM_TIM234_CCMR1_OC2M_TOGGLE : STM_TIM234_CCMR1_OC2M_FROZEN)
+#define OC3M (BEEPER_CHANNEL == 3 ? STM_TIM234_CCMR2_OC3M_TOGGLE : STM_TIM234_CCMR2_OC3M_FROZEN)
+#define OC4M (BEEPER_CHANNEL == 4 ? STM_TIM234_CCMR2_OC4M_TOGGLE : STM_TIM234_CCMR2_OC4M_FROZEN)
+
+#define CCER(n) (BEEPER_CHANNEL == (n) ? 1 : 0)
+
+#if BEEPER_CHANNEL == 1 || BEEPER_CHANNEL == 2
+ stm_beeper.ccmr1 = ((0 << STM_TIM234_CCMR1_OC2CE) |
+ (OC2M << STM_TIM234_CCMR1_OC2M) |
+ (0 << STM_TIM234_CCMR1_OC2PE) |
+ (0 << STM_TIM234_CCMR1_OC2FE) |
+ (STM_TIM234_CCMR1_CC2S_OUTPUT << STM_TIM234_CCMR1_CC2S) |
+
+ (0 << STM_TIM234_CCMR1_OC1CE) |
+ (OC1M << STM_TIM234_CCMR1_OC1M) |
+ (0 << STM_TIM234_CCMR1_OC1PE) |
+ (0 << STM_TIM234_CCMR1_OC1FE) |
+ (STM_TIM234_CCMR1_CC1S_OUTPUT << STM_TIM234_CCMR1_CC1S));
+#elif BEEPER_CHANNEL == 3 || BEEPER_CHANNEL == 4
+ stm_beeper.ccmr2 = ((0 << STM_TIM234_CCMR2_OC4CE) |
+ (OC4M << STM_TIM234_CCMR2_OC4M) |
+ (0 << STM_TIM234_CCMR2_OC4PE) |
+ (0 << STM_TIM234_CCMR2_OC4FE) |
+ (STM_TIM234_CCMR2_CC4S_OUTPUT << STM_TIM234_CCMR2_CC4S) |
+
+ (0 << STM_TIM234_CCMR2_OC3CE) |
+ (OC3M << STM_TIM234_CCMR2_OC3M) |
+ (0 << STM_TIM234_CCMR2_OC3PE) |
+ (0 << STM_TIM234_CCMR2_OC3FE) |
+ (STM_TIM234_CCMR2_CC3S_OUTPUT << STM_TIM234_CCMR2_CC3S));
+#else
+#error invalid BEEPER_CHANNEL
#endif
-#if BEEPER_CHANNEL == 4
- stm_tim3.ccmr2 = ((0 << STM_TIM234_CCMR2_OC4CE) |
- (STM_TIM234_CCMR2_OC4M_TOGGLE << STM_TIM234_CCMR2_OC4M) |
- (0 << STM_TIM234_CCMR2_OC4PE) |
- (0 << STM_TIM234_CCMR2_OC4FE) |
- (STM_TIM234_CCMR2_CC4S_OUTPUT << STM_TIM234_CCMR2_CC4S) |
-
- (0 << STM_TIM234_CCMR2_OC3CE) |
- (STM_TIM234_CCMR2_OC3M_FROZEN << STM_TIM234_CCMR2_OC3M) |
- (0 << STM_TIM234_CCMR2_OC3PE) |
- (0 << STM_TIM234_CCMR2_OC3FE) |
- (STM_TIM234_CCMR2_CC3S_OUTPUT << STM_TIM234_CCMR2_CC3S));
-
- stm_tim3.ccer = ((0 << STM_TIM234_CCER_CC4NP) |
- (0 << STM_TIM234_CCER_CC4P) |
- (1 << STM_TIM234_CCER_CC4E) |
- (0 << STM_TIM234_CCER_CC3NP) |
- (0 << STM_TIM234_CCER_CC3P) |
- (0 << STM_TIM234_CCER_CC3E) |
- (0 << STM_TIM234_CCER_CC2NP) |
- (0 << STM_TIM234_CCER_CC2P) |
- (0 << STM_TIM234_CCER_CC2E) |
- (0 << STM_TIM234_CCER_CC1NP) |
- (0 << STM_TIM234_CCER_CC1P) |
- (0 << STM_TIM234_CCER_CC1E));
-#endif
-
+ stm_beeper.ccer = ((0 << STM_TIM234_CCER_CC4NP) |
+ (0 << STM_TIM234_CCER_CC4P) |
+ (CCER(4) << STM_TIM234_CCER_CC4E) |
+ (0 << STM_TIM234_CCER_CC3NP) |
+ (0 << STM_TIM234_CCER_CC3P) |
+ (CCER(3) << STM_TIM234_CCER_CC3E) |
+ (0 << STM_TIM234_CCER_CC2NP) |
+ (0 << STM_TIM234_CCER_CC2P) |
+ (CCER(2) << STM_TIM234_CCER_CC2E) |
+ (0 << STM_TIM234_CCER_CC1NP) |
+ (0 << STM_TIM234_CCER_CC1P) |
+ (CCER(1) << STM_TIM234_CCER_CC1E));
/* 5. Enable the counter by setting the CEN bit in the TIMx_CR1 register. */
- stm_tim3.cr1 = ((STM_TIM234_CR1_CKD_1 << STM_TIM234_CR1_CKD) |
+ stm_beeper.cr1 = ((STM_TIM234_CR1_CKD_1 << STM_TIM234_CR1_CKD) |
(0 << STM_TIM234_CR1_ARPE) |
(STM_TIM234_CR1_CMS_EDGE << STM_TIM234_CR1_CMS) |
(0 << STM_TIM234_CR1_DIR) |
@@ -127,12 +142,12 @@ ao_beep(uint8_t beep)
(1 << STM_TIM234_CR1_CEN));
/* Update the values */
- stm_tim3.egr = (1 << STM_TIM234_EGR_UG);
+ stm_beeper.egr = (1 << STM_TIM234_EGR_UG);
}
}
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);
@@ -142,24 +157,9 @@ ao_beep_for(uint8_t beep, uint16_t ticks) __reentrant
void
ao_beep_init(void)
{
-#if BEEPER_CHANNEL == 1
-
- /* Our beeper is on PC6, which is hooked to TIM3_CH1.
- */
- stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOCEN);
-
- stm_afr_set(&stm_gpioc, 6, STM_AFR_AF2);
-#endif
-#if BEEPER_CHANNEL == 4
-
- /* Our beeper is on PB1, which is hooked to TIM3_CH4.
- */
- stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOBEN);
-
- stm_afr_set(&stm_gpiob, 1, STM_AFR_AF2);
-#endif
+ ao_enable_port(BEEPER_PORT);
+ stm_afr_set(BEEPER_PORT, BEEPER_PIN, BEEPER_AFR);
/* Leave the timer off until requested */
-
- stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_TIM3EN);
+ stm_rcc.apb1enr &= ~(1 << RCC_BEEPER);
}
diff --git a/src/stm/ao_eeprom_stm.c b/src/stm/ao_eeprom_stm.c
index 4f477122..d3e3338d 100644
--- a/src/stm/ao_eeprom_stm.c
+++ b/src/stm/ao_eeprom_stm.c
@@ -117,10 +117,10 @@ ao_intflash_read(uint16_t pos)
*/
uint8_t
-ao_eeprom_write(ao_pos_t pos32, __xdata void *v, uint16_t len)
+ao_eeprom_write(ao_pos_t pos32, void *v, uint16_t len)
{
uint16_t pos = pos32;
- __xdata uint8_t *d = v;
+ uint8_t *d = v;
if (pos >= ao_eeprom_total || pos + len > ao_eeprom_total)
return 0;
@@ -151,7 +151,7 @@ ao_eeprom_write(ao_pos_t pos32, __xdata void *v, uint16_t len)
* Read from eeprom
*/
uint8_t
-ao_eeprom_read(ao_pos_t pos, __xdata void *v, uint16_t len)
+ao_eeprom_read(ao_pos_t pos, void *v, uint16_t len)
{
uint8_t *d = v;
diff --git a/src/stm/ao_flash_stm_pins.h b/src/stm/ao_flash_stm_pins.h
index d5893c80..b82046d7 100644
--- a/src/stm/ao_flash_stm_pins.h
+++ b/src/stm/ao_flash_stm_pins.h
@@ -21,6 +21,10 @@
#include <ao_flash_pins.h>
+#ifndef AO_PLLMUL
+
+#if AO_HSE == 8000000
+
/* PLLVCO = 96MHz (so that USB will work) */
#define AO_PLLMUL 12
#define AO_RCC_CFGR_PLLMUL (STM_RCC_CFGR_PLLMUL_12)
@@ -29,6 +33,22 @@
#define AO_PLLDIV 3
#define AO_RCC_CFGR_PLLDIV (STM_RCC_CFGR_PLLDIV_3)
+#endif
+
+#if AO_HSE == 16000000
+
+/* PLLVCO = 96MHz (so that USB will work) */
+#define AO_PLLMUL 6
+#define AO_RCC_CFGR_PLLMUL (STM_RCC_CFGR_PLLMUL_6)
+
+/* SYSCLK = 32MHz */
+#define AO_PLLDIV 3
+#define AO_RCC_CFGR_PLLDIV (STM_RCC_CFGR_PLLDIV_3)
+
+#endif
+
+#endif
+
/* HCLK = 32MHZ (CPU clock) */
#define AO_AHB_PRESCALER 1
#define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1
diff --git a/src/stm/ao_i2c_stm.c b/src/stm/ao_i2c_stm.c
index 59cad495..23805aa8 100644
--- a/src/stm/ao_i2c_stm.c
+++ b/src/stm/ao_i2c_stm.c
@@ -275,7 +275,7 @@ ao_i2c_send(void *block, uint16_t len, uint8_t index, uint8_t stop)
stm_i2c->cr1 = AO_STM_I2C_CR1 | (1 << STM_I2C_CR1_STOP);
ao_i2c_wait_stop(index);
}
- return TRUE;
+ return true;
}
void
@@ -300,10 +300,10 @@ uint8_t
ao_i2c_recv(void *block, uint16_t len, uint8_t index, uint8_t stop)
{
struct stm_i2c *stm_i2c = ao_i2c_stm_info[index].stm_i2c;
- uint8_t ret = TRUE;
+ uint8_t ret = true;
if (len == 0)
- return TRUE;
+ return true;
if (len == 1) {
ao_i2c_recv_data[index] = block;
ao_i2c_recv_len[index] = 1;
diff --git a/src/stm/ao_interrupt.c b/src/stm/ao_interrupt.c
index eb1ed0b5..d8be3667 100644
--- a/src/stm/ao_interrupt.c
+++ b/src/stm/ao_interrupt.c
@@ -24,7 +24,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__;
/* Interrupt functions */
@@ -83,7 +83,7 @@ void start(void)
#endif
/* Set interrupt vector table offset */
stm_nvic.vto = (uint32_t) &stm_interrupt_vector;
- 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/stm/ao_lcd_stm.c b/src/stm/ao_lcd_stm.c
index 10d5d620..1947012b 100644
--- a/src/stm/ao_lcd_stm.c
+++ b/src/stm/ao_lcd_stm.c
@@ -326,12 +326,9 @@ ao_lcd_stm_seg_set(void)
{
int com, seg, val;
int n, bit;
- ao_cmd_decimal();
- com = ao_cmd_lex_i;
- ao_cmd_decimal();
- seg = ao_cmd_lex_u32;
- ao_cmd_decimal();
- val = ao_cmd_lex_i;
+ com = ao_cmd_decimal();
+ seg = ao_cmd_decimal();
+ val = ao_cmd_decimal();
printf ("com: %d seg: %d val: %d\n", com, seg, val);
ao_lcd_set(com, seg, val);
ao_lcd_flush();
diff --git a/src/stm/ao_led.c b/src/stm/ao_led.c
deleted file mode 100644
index a7033dbb..00000000
--- a/src/stm/ao_led.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright © 2012 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"
-
-#if LED_PER_LED
-static const struct {
- struct stm_gpio *port;
- uint16_t pin;
-} ao_leds[] = {
-#ifdef LED_0_PORT
- [0] { LED_0_PORT, LED_0_PIN },
-#endif
-#ifdef LED_1_PORT
- [1] { LED_1_PORT, LED_1_PIN },
-#endif
-#ifdef LED_2_PORT
- [2] { LED_2_PORT, LED_2_PIN },
-#endif
-#ifdef LED_3_PORT
- [3] { LED_3_PORT, LED_3_PIN },
-#endif
-#ifdef LED_4_PORT
- [4] { LED_4_PORT, LED_4_PIN },
-#endif
-#ifdef LED_5_PORT
- [5] { LED_5_PORT, LED_5_PIN },
-#endif
-#ifdef LED_6_PORT
- [6] { LED_6_PORT, LED_6_PIN },
-#endif
-#ifdef LED_7_PORT
- [7] { LED_7_PORT, LED_7_PIN },
-#endif
-#ifdef LED_8_PORT
- [8] { LED_8_PORT, LED_8_PIN },
-#endif
-#ifdef LED_9_PORT
- [9] { LED_9_PORT, LED_9_PIN },
-#endif
-#ifdef LED_10_PORT
- [10] { LED_10_PORT, LED_10_PIN },
-#endif
-#ifdef LED_11_PORT
- [11] { LED_11_PORT, LED_11_PIN },
-#endif
-#ifdef LED_12_PORT
- [12] { LED_12_PORT, LED_12_PIN },
-#endif
-#ifdef LED_13_PORT
- [13] { LED_13_PORT, LED_13_PIN },
-#endif
-#ifdef LED_14_PORT
- [14] { LED_14_PORT, LED_14_PIN },
-#endif
-#ifdef LED_15_PORT
- [15] { LED_15_PORT, LED_15_PIN },
-#endif
-};
-#define N_LED (sizeof (ao_leds)/sizeof(ao_leds[0]))
-#endif
-static AO_LED_TYPE ao_led_enable;
-
-void
-ao_led_on(AO_LED_TYPE colors)
-{
-#ifdef LED_PER_LED
- AO_LED_TYPE i;
- for (i = 0; i < N_LED; i++)
- if (colors & (1 << i))
- ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, foo, 1);
-#else
-#ifdef LED_PORT
- LED_PORT->bsrr = (colors & ao_led_enable);
-#else
-#ifdef LED_PORT_0
- LED_PORT_0->bsrr = ((colors & ao_led_enable) & 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;
-#endif
-#endif
-#endif
-}
-
-void
-ao_led_off(AO_LED_TYPE colors)
-{
-#ifdef LED_PER_LED
- AO_LED_TYPE i;
- for (i = 0; i < N_LED; i++)
- if (colors & (1 << i))
- ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, foo, 0);
-#else
-#ifdef LED_PORT
- LED_PORT->bsrr = (uint32_t) (colors & ao_led_enable) << 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);
-#endif
-#ifdef LED_PORT_1
- LED_PORT_1->bsrr = ((uint32_t) (colors & ao_led_enable) & LED_PORT_1_MASK) << (LED_PORT_1_SHIFT + 16);
-#endif
-#endif
-#endif
-}
-
-void
-ao_led_set(AO_LED_TYPE colors)
-{
- AO_LED_TYPE on = colors & ao_led_enable;
- AO_LED_TYPE off = ~colors & ao_led_enable;
-
- ao_led_off(off);
- ao_led_on(on);
-}
-
-void
-ao_led_toggle(AO_LED_TYPE colors)
-{
-#ifdef LED_PER_LED
- AO_LED_TYPE i;
- for (i = 0; i < N_LED; i++)
- if (colors & (1 << i))
- ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, foo, ~ao_gpio_get(ao_leds[i].port, ao_leds[i].pin, foo));
-#else
-#ifdef LED_PORT
- LED_PORT->odr ^= (colors & ao_led_enable);
-#else
-#ifdef LED_PORT_0
- LED_PORT_0->odr ^= ((colors & ao_led_enable) & 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;
-#endif
-#endif
-#endif
-}
-
-void
-ao_led_for(AO_LED_TYPE colors, AO_LED_TYPE ticks) __reentrant
-{
- ao_led_on(colors);
- ao_delay(ticks);
- ao_led_off(colors);
-}
-
-#define init_led_pin(port, bit) do { \
- stm_moder_set(port, bit, STM_MODER_OUTPUT); \
- stm_otyper_set(port, bit, STM_OTYPER_PUSH_PULL); \
- } while (0)
-
-void
-ao_led_init(AO_LED_TYPE enable)
-{
- AO_LED_TYPE bit;
-
- ao_led_enable = enable;
-#if LED_PER_LED
- for (bit = 0; bit < N_LED; bit++)
- ao_enable_output(ao_leds[bit].port, ao_leds[bit].pin, foo, 0);
-#else
-#ifdef LED_PORT
- stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE);
- LED_PORT->odr &= ~enable;
-#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;
-#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;
-#endif
-#ifdef LED_PORT_2
- stm_rcc.ahbenr |= (1 << LED_PORT_1_ENABLE);
- LED_PORT_1->odr &= ~((enable & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
-#endif
-#endif
- for (bit = 0; bit < 16; bit++) {
- if (enable & (1 << bit)) {
-#ifdef LED_PORT
- init_led_pin(LED_PORT, bit);
-#else
-#ifdef LED_PORT_0
- if (LED_PORT_0_MASK & (1 << bit))
- init_led_pin(LED_PORT_0, bit + LED_PORT_0_SHIFT);
-#endif
-#ifdef LED_PORT_1
- if (LED_PORT_1_MASK & (1 << bit))
- init_led_pin(LED_PORT_1, bit + LED_PORT_1_SHIFT);
-#endif
-#ifdef LED_PORT_2
- if (LED_PORT_2_MASK & (1 << bit))
- init_led_pin(LED_PORT_2, bit + LED_PORT_2_SHIFT);
-#endif
-#endif
- }
- }
-#endif
-}
diff --git a/src/stm/ao_led_stm.c b/src/stm/ao_led_stm.c
new file mode 100644
index 00000000..7dcbb661
--- /dev/null
+++ b/src/stm/ao_led_stm.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright © 2012 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"
+
+#if LED_PER_LED
+#error LED_PER_LED support is in ao_led.c now
+#endif
+
+void
+ao_led_on(AO_LED_TYPE colors)
+{
+#ifdef LED_PORT
+ LED_PORT->bsrr = (colors & LEDS_AVAILABLE);
+#else
+#ifdef LED_PORT_0
+ 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 & LEDS_AVAILABLE) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+#endif
+#ifdef LED_PORT_2
+ LED_PORT_2->bsrr = ((colors & LEDS_AVAILABLE) & LED_PORT_2_MASK) << LED_PORT_2_SHIFT;
+#endif
+#endif
+}
+
+void
+ao_led_off(AO_LED_TYPE colors)
+{
+#ifdef LED_PORT
+ LED_PORT->bsrr = (uint32_t) (colors & LEDS_AVAILABLE) << 16;
+#else
+#ifdef LED_PORT_0
+ 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 & LEDS_AVAILABLE) & LED_PORT_1_MASK) << (LED_PORT_1_SHIFT + 16);
+#endif
+#ifdef LED_PORT_2
+ LED_PORT_2->bsrr = ((uint32_t) (colors & LEDS_AVAILABLE) & LED_PORT_2_MASK) << (LED_PORT_2_SHIFT + 16);
+#endif
+#endif
+}
+
+void
+ao_led_set(AO_LED_TYPE colors)
+{
+ 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(AO_LED_TYPE colors)
+{
+#ifdef LED_PORT
+ LED_PORT->odr ^= (colors & LEDS_AVAILABLE);
+#else
+#ifdef LED_PORT_0
+ 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 & LEDS_AVAILABLE) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+#endif
+#ifdef LED_PORT_2
+ LED_PORT_2->odr ^= ((colors & LEDS_AVAILABLE) & LED_PORT_2_MASK) << LED_PORT_2_SHIFT;
+#endif
+#endif
+}
+
+void
+ao_led_for(AO_LED_TYPE colors, AO_LED_TYPE ticks)
+{
+ ao_led_on(colors);
+ ao_delay(ticks);
+ ao_led_off(colors);
+}
+
+#define init_led_pin(port, bit) do { \
+ stm_moder_set(port, bit, STM_MODER_OUTPUT); \
+ stm_otyper_set(port, bit, STM_OTYPER_PUSH_PULL); \
+ } while (0)
+
+void
+ao_led_init(void)
+{
+ AO_LED_TYPE bit;
+
+#ifdef LED_PORT
+ stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE);
+ LED_PORT->odr &= ~LEDS_AVAILABLE;
+#else
+#ifdef LED_PORT_0
+ stm_rcc.ahbenr |= (1 << LED_PORT_0_ENABLE);
+ 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 &= (uint32_t) ~(LEDS_AVAILABLE & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+#endif
+#ifdef LED_PORT_2
+ stm_rcc.ahbenr |= (1 << LED_PORT_2_ENABLE);
+ LED_PORT_2->odr &= (uint32_t) ~(LEDS_AVAILABLE & LED_PORT_2_MASK) << LED_PORT_2_SHIFT;
+#endif
+#endif
+ for (bit = 0; bit < sizeof (AO_LED_TYPE) * 8; bit++) {
+ if (LEDS_AVAILABLE & (1 << bit)) {
+#ifdef LED_PORT
+ init_led_pin(LED_PORT, bit);
+#else
+#ifdef LED_PORT_0
+ if (LED_PORT_0_MASK & (1 << bit))
+ init_led_pin(LED_PORT_0, bit + LED_PORT_0_SHIFT);
+#endif
+#ifdef LED_PORT_1
+ if (LED_PORT_1_MASK & (1 << bit))
+ init_led_pin(LED_PORT_1, bit + LED_PORT_1_SHIFT);
+#endif
+#ifdef LED_PORT_2
+ if (LED_PORT_2_MASK & (1 << bit))
+ init_led_pin(LED_PORT_2, bit + LED_PORT_2_SHIFT);
+#endif
+#endif
+ }
+ }
+}
diff --git a/src/stm/ao_pwm_stm.c b/src/stm/ao_pwm_stm.c
index 53000a17..341f8887 100644
--- a/src/stm/ao_pwm_stm.c
+++ b/src/stm/ao_pwm_stm.c
@@ -107,10 +107,8 @@ ao_pwm_cmd(void)
uint8_t ch;
uint16_t val;
- ao_cmd_decimal();
- ch = ao_cmd_lex_u32;
- ao_cmd_decimal();
- val = ao_cmd_lex_u32;
+ ch = ao_cmd_decimal();
+ val = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
diff --git a/src/stm/ao_romconfig.c b/src/stm/ao_romconfig.c
deleted file mode 100644
index 63a48bec..00000000
--- a/src/stm/ao_romconfig.c
+++ /dev/null
@@ -1,29 +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
-#if HAS_RADIO
-AO_ROMCONFIG_SYMBOL (0) uint32_t ao_radio_cal = AO_RADIO_CAL_DEFAULT;
-#endif
diff --git a/src/stm/ao_serial_stm.c b/src/stm/ao_serial_stm.c
index 2afee5b5..c1a2f1bd 100644
--- a/src/stm/ao_serial_stm.c
+++ b/src/stm/ao_serial_stm.c
@@ -33,7 +33,7 @@ _ao_usart_tx_start(struct ao_stm_usart *usart)
{
if (!ao_fifo_empty(usart->tx_fifo)) {
#if HAS_SERIAL_SW_FLOW
- if (usart->gpio_cts && ao_gpio_get(usart->gpio_cts, usart->pin_cts, foo) == 1) {
+ if (usart->gpio_cts && ao_gpio_get(usart->gpio_cts, usart->pin_cts) == 1) {
ao_exti_enable(usart->gpio_cts, usart->pin_cts);
return 0;
}
@@ -73,7 +73,7 @@ _ao_usart_rx(struct ao_stm_usart *usart, int is_stdin)
* for it to drain a bunch
*/
if (usart->gpio_rts && ao_fifo_mostly(usart->rx_fifo)) {
- ao_gpio_set(usart->gpio_rts, usart->pin_rts, usart->pin_rts, 1);
+ ao_gpio_set(usart->gpio_rts, usart->pin_rts, 1);
usart->rts = 0;
}
#endif
@@ -118,7 +118,7 @@ _ao_usart_pollchar(struct ao_stm_usart *usart)
#if HAS_SERIAL_SW_FLOW
/* If we've cleared RTS, check if there's space now and turn it back on */
if (usart->gpio_rts && usart->rts == 0 && ao_fifo_barely(usart->rx_fifo)) {
- ao_gpio_set(usart->gpio_rts, usart->pin_rts, foo, 0);
+ ao_gpio_set(usart->gpio_rts, usart->pin_rts, 0);
usart->rts = 1;
}
#endif
@@ -403,7 +403,7 @@ ao_serial_set_sw_rts_cts(struct ao_stm_usart *usart,
{
/* Pull RTS low to note that there's space in the FIFO
*/
- ao_enable_output(port_rts, pin_rts, foo, 0);
+ ao_enable_output(port_rts, pin_rts, 0);
usart->gpio_rts = port_rts;
usart->pin_rts = pin_rts;
usart->rts = 1;
diff --git a/src/stm/ao_spi_stm.c b/src/stm/ao_spi_stm.c
index 05078f3b..1a04a289 100644
--- a/src/stm/ao_spi_stm.c
+++ b/src/stm/ao_spi_stm.c
@@ -25,7 +25,7 @@ struct ao_spi_stm_info {
};
static uint8_t ao_spi_mutex[STM_NUM_SPI];
-static uint8_t ao_spi_index[STM_NUM_SPI];
+static uint8_t ao_spi_pin_config[STM_NUM_SPI];
static const struct ao_spi_stm_info ao_spi_stm_info[STM_NUM_SPI] = {
{
@@ -285,11 +285,11 @@ ao_spi_duplex(const void *out, void *in, uint16_t len, uint8_t spi_index)
}
static void
-ao_spi_disable_index(uint8_t spi_index)
+ao_spi_disable_pin_config(uint8_t spi_pin_config)
{
/* Disable current config
*/
- switch (spi_index) {
+ switch (spi_pin_config) {
case AO_SPI_1_PA5_PA6_PA7:
stm_gpio_set(&stm_gpioa, 5, 1);
stm_moder_set(&stm_gpioa, 5, STM_MODER_OUTPUT);
@@ -324,11 +324,11 @@ ao_spi_disable_index(uint8_t spi_index)
}
static void
-ao_spi_enable_index(uint8_t spi_index)
+ao_spi_enable_pin_config(uint8_t spi_pin_config)
{
/* Enable new config
*/
- switch (spi_index) {
+ switch (spi_pin_config) {
case AO_SPI_1_PA5_PA6_PA7:
stm_afr_set(&stm_gpioa, 5, STM_AFR_AF5);
stm_afr_set(&stm_gpioa, 6, STM_AFR_AF5);
@@ -360,23 +360,26 @@ ao_spi_enable_index(uint8_t spi_index)
static void
ao_spi_config(uint8_t spi_index, uint32_t speed)
{
+ uint8_t spi_pin_config = AO_SPI_PIN_CONFIG(spi_index);
uint8_t id = AO_SPI_INDEX(spi_index);
struct stm_spi *stm_spi = ao_spi_stm_info[id].stm_spi;
- if (spi_index != ao_spi_index[id]) {
+ if (spi_pin_config != ao_spi_pin_config[id]) {
/* Disable old config
*/
- ao_spi_disable_index(ao_spi_index[id]);
+ ao_spi_disable_pin_config(ao_spi_pin_config[id]);
/* Enable new config
*/
- ao_spi_enable_index(spi_index);
+ ao_spi_enable_pin_config(spi_pin_config);
/* Remember current config
*/
- ao_spi_index[id] = spi_index;
+ ao_spi_pin_config[id] = spi_pin_config;
}
+
+ /* Turn the SPI transceiver on and set the mode */
stm_spi->cr1 = ((0 << STM_SPI_CR1_BIDIMODE) | /* Three wire mode */
(0 << STM_SPI_CR1_BIDIOE) |
(0 << STM_SPI_CR1_CRCEN) | /* CRC disabled */
@@ -389,8 +392,8 @@ ao_spi_config(uint8_t spi_index, uint32_t speed)
(1 << STM_SPI_CR1_SPE) | /* Enable SPI unit */
(speed << STM_SPI_CR1_BR) | /* baud rate to pclk/4 */
(1 << STM_SPI_CR1_MSTR) |
- (0 << STM_SPI_CR1_CPOL) | /* Format 0 */
- (0 << STM_SPI_CR1_CPHA));
+ (AO_SPI_CPOL(spi_index) << STM_SPI_CR1_CPOL) | /* Format */
+ (AO_SPI_CPHA(spi_index) << STM_SPI_CR1_CPHA));
validate_spi(stm_spi, 13, 0);
}
@@ -430,7 +433,7 @@ ao_spi_channel_init(uint8_t spi_index)
uint8_t id = AO_SPI_INDEX(spi_index);
struct stm_spi *stm_spi = ao_spi_stm_info[id].stm_spi;
- ao_spi_disable_index(spi_index);
+ ao_spi_disable_pin_config(AO_SPI_PIN_CONFIG(spi_index));
stm_spi->cr1 = 0;
stm_spi->cr2 = ((0 << STM_SPI_CR2_TXEIE) |
@@ -512,7 +515,7 @@ ao_spi_init(void)
stm_ospeedr_set(&stm_gpioe, 15, SPI_1_OSPEEDR);
# endif
stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_SPI1EN);
- ao_spi_index[0] = AO_SPI_CONFIG_NONE;
+ ao_spi_pin_config[0] = AO_SPI_CONFIG_NONE;
ao_spi_channel_init(0);
#endif
@@ -530,7 +533,7 @@ ao_spi_init(void)
stm_ospeedr_set(&stm_gpiod, 4, SPI_2_OSPEEDR);
# endif
stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_SPI2EN);
- ao_spi_index[1] = AO_SPI_CONFIG_NONE;
+ ao_spi_pin_config[1] = AO_SPI_CONFIG_NONE;
ao_spi_channel_init(1);
#endif
#if DEBUG
diff --git a/src/stm/ao_timer.c b/src/stm/ao_timer.c
index 9d118b72..9e9436cf 100644
--- a/src/stm/ao_timer.c
+++ b/src/stm/ao_timer.c
@@ -39,8 +39,8 @@ ao_time(void)
#endif
#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/stm/ao_usb_stm.c b/src/stm/ao_usb_stm.c
index b06814d2..d7cbd5b7 100644
--- a/src/stm/ao_usb_stm.c
+++ b/src/stm/ao_usb_stm.c
@@ -1079,7 +1079,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 }
};
diff --git a/src/stm/stm32l.h b/src/stm/stm32l.h
index 1da817e7..0109ec81 100644
--- a/src/stm/stm32l.h
+++ b/src/stm/stm32l.h
@@ -241,15 +241,14 @@ stm_gpio_get_all(struct stm_gpio *gpio) {
* ao_enable_gpio macro will expand into a huge pile of code
* as the compiler won't do correct constant folding and
* dead-code elimination
+ */
- extern struct stm_gpio stm_gpioa;
- extern struct stm_gpio stm_gpiob;
- extern struct stm_gpio stm_gpioc;
- extern struct stm_gpio stm_gpiod;
- extern struct stm_gpio stm_gpioe;
- extern struct stm_gpio stm_gpioh;
-
-*/
+extern struct stm_gpio stm_gpioa;
+extern struct stm_gpio stm_gpiob;
+extern struct stm_gpio stm_gpioc;
+extern struct stm_gpio stm_gpiod;
+extern struct stm_gpio stm_gpioe;
+extern struct stm_gpio stm_gpioh;
#define stm_gpioh (*((struct stm_gpio *) 0x40021400))
#define stm_gpioe (*((struct stm_gpio *) 0x40021000))
diff --git a/src/stm32f4-disco/.gitignore b/src/stm32f4-disco/.gitignore
new file mode 100644
index 00000000..deb5083f
--- /dev/null
+++ b/src/stm32f4-disco/.gitignore
@@ -0,0 +1,3 @@
+stm32f4-disco-*.elf
+stm32f4-disco-*.ihx
+stm32f4-disco-*.map
diff --git a/src/stm32f4-disco/Makefile b/src/stm32f4-disco/Makefile
new file mode 100644
index 00000000..de30316c
--- /dev/null
+++ b/src/stm32f4-disco/Makefile
@@ -0,0 +1,81 @@
+include ../stm32f4/Makefile-raw.defs
+
+aoschemelib=$(shell pkg-config --variable=aoschemelib ao-scheme)
+
+include $(aoschemelib)/Makefile-scheme
+
+IDVENDOR=0xfffe
+IDPRODUCT=0xfffa
+PRODUCT=stm32f4-disco
+SERIAL=1
+
+INC = \
+ ao.h \
+ ao_arch.h \
+ ao_arch_funcs.h \
+ ao_boot.h \
+ ao_pins.h \
+ ao_task.h \
+ ao_product.h \
+ $(SCHEME_HDRS) \
+ ao_scheme_const.h \
+ stm32f4.h \
+ Makefile
+
+ALTOS_SRC = \
+ ao_interrupt.c \
+ ao_romconfig.c \
+ ao_panic.c \
+ ao_timer.c \
+ ao_task.c \
+ ao_stdio.c \
+ ao_product.c \
+ ao_cmd.c \
+ ao_exti_stm32f4.c \
+ ao_usart_stm32f4.c \
+ ao_usb_gen.c \
+ ao_usb_stm32f4.c \
+ ao_led.c \
+ ao_impure.c \
+ $(SCHEME_SRCS)
+
+CFLAGS = $(STM32F4_CFLAGS) -I$(aoschemelib)
+
+PROG=stm32f4-disco-$(VERSION)
+ELF=$(PROG).elf
+IHX=$(PROG).ihx
+
+SRC=$(ALTOS_SRC) ao_disco.c
+OBJ=$(SRC:.c=.o)
+MAP=$(PROG).map
+
+all: $(ELF) $(IHX)
+
+$(ELF): Makefile $(OBJ)
+ $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJ) -Wl,-M=$(MAP) $(LIBS)
+
+$(OBJ): $(INC)
+
+ao_product.h: ao-make-product.5c ../Version Makefile
+ $(call quiet,NICKLE,$<) $< -m altusmetrum.org -V $(IDVENDOR) -s $(SERIAL) -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
+
+SCHEME_SCHEME=\
+ ao_scheme_basic_syntax.scheme \
+ ao_scheme_list.scheme \
+ ao_scheme_advanced_syntax.scheme \
+ ao_scheme_vector.scheme \
+ ao_scheme_string.scheme \
+ ao_scheme_char.scheme \
+ ao_scheme_number.scheme
+
+ao_scheme_const.h: ao-scheme-make-const-big $(SCHEME_SCHEME)
+ $^ -o $@ -d POSIX,PORT,SAVE
+
+distclean: clean
+
+clean:
+ rm -f *.o *.elf *.ihx *.map
+
+install:
+
+uninstall:
diff --git a/src/stm32f4-disco/ao_disco.c b/src/stm32f4-disco/ao_disco.c
new file mode 100644
index 00000000..ab3c0340
--- /dev/null
+++ b/src/stm32f4-disco/ao_disco.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2018 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.
+ */
+
+#include <ao.h>
+#include <ao_scheme.h>
+#include <ao_usb.h>
+
+static void scheme_cmd() {
+ ao_scheme_read_eval_print(stdin, stdout, false);
+}
+
+static const struct ao_cmds scheme_cmds[] = {
+ { scheme_cmd, "l\0Run scheme interpreter" },
+ { 0, 0 }
+};
+
+int
+_ao_scheme_getc(void)
+{
+ static uint8_t at_eol;
+ int c;
+
+ if (at_eol) {
+ ao_cmd_readline(ao_scheme_read_list ? "- " : "> ");
+ at_eol = 0;
+ }
+ c = (unsigned char) ao_cmd_lex();
+ if (c == '\n')
+ at_eol = 1;
+ return c;
+}
+
+void main(void)
+{
+ ao_clock_init();
+ ao_timer_init();
+ ao_task_init();
+
+ ao_led_init();
+ ao_usart_init();
+ ao_usb_init();
+ ao_cmd_init();
+ ao_cmd_register(scheme_cmds);
+ ao_start_scheduler();
+}
diff --git a/src/stm32f4-disco/ao_pins.h b/src/stm32f4-disco/ao_pins.h
new file mode 100644
index 00000000..6a18d59d
--- /dev/null
+++ b/src/stm32f4-disco/ao_pins.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2018 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.
+ */
+#ifndef _AO_PINS_H_
+#define _AO_PINS_H_
+
+/* Clock tree configuration */
+#define AO_HSE 8000000 /* fed from st/link processor */
+#define AO_HSE_BYPASS 1 /* no xtal, directly fed */
+
+#define AO_PLL_M 8 /* down to 1MHz */
+
+#define AO_PLL1_R 2 /* down to 96MHz */
+#define AO_PLL1_N 192 /* up to 192MHz */
+#define AO_PLL1_P 2 /* down to 96MHz */
+#define AO_PLL1_Q 4 /* down to 48MHz for USB and SDIO */
+
+#define AO_AHB_PRESCALER 1
+#define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1
+
+#define AO_APB1_PRESCALER 2
+#define AO_RCC_CFGR_PPRE1_DIV STM_RCC_CFGR_PPRE1_DIV_2
+
+#define AO_APB2_PRESCALER 1
+#define AO_RCC_CFGR_PPRE2_DIV STM_RCC_CFGR_PPRE2_DIV_1
+
+#define DEBUG_THE_CLOCK 1
+
+#define HAS_BEEP 0
+
+#define B_USER_PORT (&stm_gpioa)
+#define B_USER_PIN 0
+
+/* LEDs */
+
+#define HAS_LED 1
+
+#define LED_0_PORT (&stm_gpioc)
+#define LED_0_PIN 5
+#define LED_GREEN AO_LED_0
+
+#define LED_1_PORT (&stm_gpioe)
+#define LED_1_PIN 3
+#define LED_RED AO_LED_0
+
+#define AO_LED_PANIC LED_RED
+
+#define AO_CMD_LEN 128
+
+/* USART */
+
+#define HAS_SERIAL_6 1
+#define SERIAL_6_RX_PORT (&stm_gpiog)
+#define SERIAL_6_RX_PIN 9
+
+#define SERIAL_6_TX_PORT (&stm_gpiog)
+#define SERIAL_6_TX_PIN 14
+
+#define USE_SERIAL_6_STDIN 1
+#define DELAY_SERIAL_6_STDIN 0
+#define USE_SERIAL_6_FLOW 0
+#define USE_SERIAL_6_SW_FLOW 0
+
+/* USB */
+
+#define HAS_USB 1
+#define USE_USB_STDIO 0
+
+#endif /* _AO_PINS_H_ */
diff --git a/src/stm32f4-disco/ao_scheme_os.h b/src/stm32f4-disco/ao_scheme_os.h
new file mode 100644
index 00000000..b1eac30b
--- /dev/null
+++ b/src/stm32f4-disco/ao_scheme_os.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2016 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; version 2 of the License.
+ *
+ * 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_SCHEME_OS_H_
+#define _AO_SCHEME_OS_H_
+
+#include "ao.h"
+#include "ao_scheme.h"
+
+#define AO_SCHEME_POOL 131072
+#define AO_SCHEME_TOKEN_MAX 64
+
+#define AO_SCHEME_BIG
+
+#ifndef __BYTE_ORDER
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN 4321
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
+extern int _ao_scheme_getc(void);
+
+#define ao_scheme_getc(f) ({ (void) (f); _ao_scheme_getc(); })
+#undef putc
+#define putc(c, f) ({ (void) (f); ao_putchar(c); })
+#define fputs(s, f) ({ (void) (f); ao_put_string(s); })
+#define fiprintf(f, ...) ({ (void) (f); iprintf(__VA_ARGS__); })
+
+static inline void
+ao_scheme_abort(void)
+{
+ ao_panic(1);
+}
+
+#ifdef LEDS_AVAILABLE
+static inline void
+ao_scheme_os_led(int led)
+{
+ ao_led_set(led);
+}
+#endif
+
+#define AO_SCHEME_JIFFIES_PER_SECOND AO_HERTZ
+
+static inline void
+ao_scheme_os_delay(int delay)
+{
+ ao_delay(delay);
+}
+
+static inline int
+ao_scheme_os_jiffy(void)
+{
+ return ao_tick_count;
+}
+#endif
diff --git a/src/stm32f4/Makefile-flash.defs b/src/stm32f4/Makefile-flash.defs
new file mode 100644
index 00000000..1a2aa75c
--- /dev/null
+++ b/src/stm32f4/Makefile-flash.defs
@@ -0,0 +1,68 @@
+include $(TOPDIR)/stm32f4/Makefile-stm32f4.defs
+
+INC = \
+ ao.h \
+ ao_arch.h \
+ ao_arch_funcs.h \
+ ao_flash_pins.h \
+ ao_flash_stm_pins.h \
+ ao_flash_task.h \
+ ao_pins.h \
+ ao_product.h \
+ Makefile
+
+#
+# Common AltOS sources
+#
+SRC = \
+ ao_interrupt.c \
+ ao_romconfig.c \
+ ao_boot_chain.c \
+ ao_boot_pin.c \
+ ao_product.c \
+ ao_notask.c \
+ ao_timer.c \
+ ao_usb_stm.c \
+ ao_flash_stm.c \
+ ao_flash_task.c \
+ ao_flash_loader_stm.c
+
+OBJ=$(SRC:.c=.o)
+
+PRODUCT=AltosFlash
+PRODUCT_DEF=-DALTOS_FLASH
+IDPRODUCT=0x000a
+
+CFLAGS = $(PRODUCT_DEF) $(STM32F4_CFLAGS) -g -Os
+
+LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stm32f4 -Wl,-Taltos-loader.ld
+
+PROGNAME=altos-flash
+PROG=$(HARDWARE)-$(PROGNAME)-$(VERSION).elf
+BIN=$(HARDWARE)-$(PROGNAME)-$(VERSION).bin
+
+MAKEBIN=$(TOPDIR)/../ao-tools/ao-makebin/ao-makebin
+FLASH_ADDR=0x08000000
+
+all: $(PROG) $(BIN)
+
+$(PROG): Makefile $(OBJ) altos-loader.ld
+ $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS)
+
+$(BIN): $(PROG)
+ $(MAKEBIN) --output=$@ --base=$(FLASH_ADDR) $(PROG)
+
+ao_product.h: ao-make-product.5c $(TOPDIR)/Version
+ $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
+
+$(OBJ): $(INC)
+
+distclean: clean
+
+clean:
+ rm -f *.o $(HARDWARE)-$(PROGNAME)-*.elf $(HARDWARE)-$(PROGNAME)-*.bin
+ rm -f ao_product.h
+
+install:
+
+uninstall:
diff --git a/src/stm32f4/Makefile-raw.defs b/src/stm32f4/Makefile-raw.defs
new file mode 100644
index 00000000..03d92e42
--- /dev/null
+++ b/src/stm32f4/Makefile-raw.defs
@@ -0,0 +1,13 @@
+ifndef TOPDIR
+TOPDIR=..
+endif
+
+include $(TOPDIR)/stm32f4/Makefile-stm32f4.defs
+
+LOADER=flash-loader/$(PROGNAME)-altos-flash-$(VERSION).elf
+MAKEBIN=$(TOPDIR)/../ao-tools/ao-makebin/ao-makebin
+FLASH_ADDR=0x08000000
+
+LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stm32f4 -Wl,-Taltos-raw.ld -n
+
+.DEFAULT_GOAL=all
diff --git a/src/stm32f4/Makefile-stm32f4.defs b/src/stm32f4/Makefile-stm32f4.defs
new file mode 100644
index 00000000..c39633c7
--- /dev/null
+++ b/src/stm32f4/Makefile-stm32f4.defs
@@ -0,0 +1,52 @@
+ifndef TOPDIR
+TOPDIR=..
+endif
+
+include $(TOPDIR)/Makedefs
+
+vpath % $(TOPDIR)/stm32f4:$(TOPDIR)/product:$(TOPDIR)/drivers:$(TOPDIR)/kernel:$(TOPDIR)/util:$(TOPDIR)/kalman:$(TOPDIR)/aes:$(TOPDIR):$(TOPDIR)/math
+vpath make-altitude $(TOPDIR)/util
+vpath make-kalman $(TOPDIR)/util
+vpath kalman.5c $(TOPDIR)/kalman
+vpath kalman_filter.5c $(TOPDIR)/kalman
+vpath load_csv.5c $(TOPDIR)/kalman
+vpath matrix.5c $(TOPDIR)/kalman
+vpath ao-make-product.5c $(TOPDIR)/util
+
+.SUFFIXES: .elf .ihx
+
+.elf.ihx:
+ $(ELFTOHEX) --output=$@ $*.elf
+
+ifndef VERSION
+include $(TOPDIR)/Version
+endif
+
+ELFTOHEX=$(TOPDIR)/../ao-tools/ao-elftohex/ao-elftohex
+CC=$(ARM_CC)
+
+WARN_FLAGS=-Wall -Wextra -Werror -Wcast-align
+
+AO_CFLAGS=-I. -I$(TOPDIR)/stm32f4 -I$(TOPDIR)/kernel -I$(TOPDIR)/drivers \
+ -Os -g \
+ -I$(TOPDIR)/product -I$(TOPDIR) -I$(TOPDIR)/math \
+ -isystem $(NEWLIB_NANO)/arm-none-eabi/include
+
+STM32F4_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m4 -mthumb \
+ -mfloat-abi=hard -mfpu=fpv4-sp-d16 \
+ -ffreestanding -nostdlib $(AO_CFLAGS) $(WARN_FLAGS)
+
+NICKLE=nickle
+
+LIBS=-L$(NEWLIB_NANO)/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard -lc -lm -lgcc
+
+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)
+
+.c.o:
+ $(call quiet,CC) -c $(CFLAGS) -o $@ $<
diff --git a/src/stm32f4/Makefile.defs b/src/stm32f4/Makefile.defs
new file mode 100644
index 00000000..be185a59
--- /dev/null
+++ b/src/stm32f4/Makefile.defs
@@ -0,0 +1,13 @@
+ifndef TOPDIR
+TOPDIR=..
+endif
+
+include $(TOPDIR)/stm32f4/Makefile-stm32f4.defs
+
+LOADER=flash-loader/$(PROGNAME)-altos-flash-$(VERSION).elf
+MAKEBIN=$(TOPDIR)/../ao-tools/ao-makebin/ao-makebin
+FLASH_ADDR=0x08000000
+
+LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stm32f4 -Wl,-Taltos.ld -n
+
+.DEFAULT_GOAL=all
diff --git a/src/stm32f4/altos-loader.ld b/src/stm32f4/altos-loader.ld
new file mode 100644
index 00000000..5d6e1f4b
--- /dev/null
+++ b/src/stm32f4/altos-loader.ld
@@ -0,0 +1,97 @@
+/*
+ * Copyright © 2012 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.
+ */
+
+MEMORY {
+ rom : ORIGIN = 0x08000000, LENGTH = 4K
+ ram : ORIGIN = 0x20000000, LENGTH = 256K
+}
+
+INCLUDE registers.ld
+
+EXTERN (stm_interrupt_vector)
+
+SECTIONS {
+ /*
+ * Rom contents
+ */
+
+ .interrupt : {
+ __text_start__ = .;
+ *(.interrupt) /* Interrupt vectors */
+ } > rom
+
+ .text ORIGIN(rom) + 0x100 : {
+ ao_romconfig.o(.romconfig*)
+ ao_product.o(.romconfig*)
+
+ *(.text*) /* Executable code */
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ *(.rodata*) /* Constants */
+ } > rom
+ __text_end__ = .;
+
+ /* Boot data which must live at the start of ram so that
+ * the application and bootloader share the same addresses.
+ * This must be all uninitialized data
+ */
+ .boot ORIGIN(ram) + SIZEOF(.interrupt) (NOLOAD) : {
+ __boot_start__ = .;
+ *(.boot)
+ __boot_end__ = .;
+ } >ram
+
+ /* Functions placed in RAM (required for flashing)
+ *
+ * Align to 8 bytes as that's what the ARM likes text
+ * segment alignments to be, and if we don't, then
+ * we end up with a mismatch between the location in
+ * ROM and the desired location in RAM. I don't
+ * entirely understand this, but at least this appears
+ * to work...
+ */
+
+ .textram BLOCK(8): {
+ _start__ = .;
+ __text_ram_start__ = .;
+ *(.ramtext)
+ __text_ram_end = .;
+ } >ram AT>rom
+
+ /* Data -- relocated to RAM, but written to ROM.
+ * also aligned to 8 bytes in case textram is empty
+ */
+ .data BLOCK(8): {
+ *(.data) /* initialized data */
+ _end__ = .;
+ } >ram AT>rom
+
+
+ .bss : {
+ __bss_start__ = .;
+ *(.bss)
+ *(COMMON)
+ __bss_end__ = .;
+ } >ram
+
+ PROVIDE(__stack__ = ORIGIN(ram) + LENGTH(ram));
+ PROVIDE(end = .);
+}
+
+ENTRY(start);
+
+
diff --git a/src/stm32f4/altos-raw.ld b/src/stm32f4/altos-raw.ld
new file mode 100644
index 00000000..82d33c09
--- /dev/null
+++ b/src/stm32f4/altos-raw.ld
@@ -0,0 +1,74 @@
+/*
+ * Copyright © 2018 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.
+ */
+
+MEMORY {
+ rom (rx) : ORIGIN = 0x08000000, LENGTH = 1M
+ ram (!w) : ORIGIN = 0x20000000, LENGTH = 256k - 256
+ stack (!w) : ORIGIN = 0x20000000 + 256k - 256, LENGTH = 256
+}
+
+INCLUDE registers.ld
+
+EXTERN (stm_interrupt_vector)
+
+SECTIONS {
+ /*
+ * Rom contents
+ */
+
+ .interrupt : {
+ __text_start__ = .;
+ *(.interrupt) /* Interrupt vectors */
+ } > rom
+
+ .text : {
+ *(.text*) /* Executable code */
+ *(.rodata*) /* Constants */
+ } > rom
+
+ .exidx : {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+
+ __text_end__ = .;
+
+ /* Data -- relocated to RAM, but written to ROM
+ */
+ .data : {
+ _start__ = .;
+ *(.data) /* initialized data */
+ . = ALIGN(4);
+ _end__ = .;
+ } >ram AT>rom
+
+ .bss : {
+ __bss_start__ = .;
+ *(.bss)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ } >ram
+
+ PROVIDE(end = .);
+
+ PROVIDE(__stack__ = ORIGIN(stack) + LENGTH(stack));
+}
+
+ENTRY(start);
+
+
diff --git a/src/lambdakey-v1.0/lambda.ld b/src/stm32f4/altos.ld
index b09fdb4a..2db0e387 100644
--- a/src/lambdakey-v1.0/lambda.ld
+++ b/src/stm32f4/altos.ld
@@ -1,5 +1,5 @@
/*
- * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ * Copyright © 2018 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
@@ -17,9 +17,9 @@
*/
MEMORY {
- rom (rx) : ORIGIN = 0x08001000, LENGTH = 28K
- ram (!w) : ORIGIN = 0x20000000, LENGTH = 6k - 1k
- stack (!w) : ORIGIN = 0x20000000 + 6k - 1k, LENGTH = 1k
+ rom (rx) : ORIGIN = 0x08001000, LENGTH = 1M - 4k
+ ram (!w) : ORIGIN = 0x20000000, LENGTH = 256k - 256
+ stack (!w) : ORIGIN = 0x20000000 + 256k - 256, LENGTH = 256
}
INCLUDE registers.ld
@@ -55,12 +55,17 @@ SECTIONS {
ao_product.o(.romconfig*)
*(.text*) /* Executable code */
+ } > rom
+
+ .ARM.exidx : {
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
- *(.rodata*) /* Constants */
+ } > rom
+ .rodata : {
+ *(.rodata*) /* Constants */
} > rom
+
__text_end__ = .;
-
/* Boot data which must live at the start of ram so that
* the application and bootloader share the same addresses.
@@ -73,29 +78,13 @@ SECTIONS {
__boot_end__ = .;
} >ram
- /* Functions placed in RAM (required for flashing)
- *
- * Align to 8 bytes as that's what the ARM likes text
- * segment alignments to be, and if we don't, then
- * we end up with a mismatch between the location in
- * ROM and the desired location in RAM. I don't
- * entirely understand this, but at least this appears
- * to work...
- */
-
- .textram BLOCK(8): {
- __data_start__ = .;
- __text_ram_start__ = .;
- *(.ramtext)
- __text_ram_end = .;
- } >ram AT>rom
-
/* Data -- relocated to RAM, but written to ROM
*/
- .data BLOCK(8): {
+ .data : {
+ _start__ = .;
*(.data) /* initialized data */
- . = ALIGN(8);
- __data_end__ = .;
+ . = ALIGN(4);
+ _end__ = .;
} >ram AT>rom
.bss : {
@@ -112,3 +101,5 @@ SECTIONS {
}
ENTRY(start);
+
+
diff --git a/src/stm32f4/ao_arch.h b/src/stm32f4/ao_arch.h
new file mode 100644
index 00000000..73dc3e93
--- /dev/null
+++ b/src/stm32f4/ao_arch.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright © 2018 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.
+ */
+
+#ifndef _AO_ARCH_H_
+#define _AO_ARCH_H_
+
+#include <stdio.h>
+#include <stm32f4.h>
+
+#ifndef AO_STACK_SIZE
+#define AO_STACK_SIZE 2048
+#endif
+
+#ifndef HAS_TASK_QUEUE
+#define HAS_TASK_QUEUE 1
+#endif
+
+#define AO_STACK_ALIGNMENT __attribute__ ((aligned(8)))
+
+#define AO_PORT_TYPE uint16_t
+
+#define ao_arch_reboot() \
+ (stm_scb.aircr = ((STM_SCB_AIRCR_VECTKEY_KEY << STM_SCB_AIRCR_VECTKEY) | \
+ (1 << STM_SCB_AIRCR_SYSRESETREQ)))
+
+#define ao_arch_nop() asm("nop")
+
+#define AO_ROMCONFIG_SYMBOL __attribute__((section(".romconfig"))) const
+
+#define ao_arch_task_members\
+ uint32_t *sp; /* saved stack pointer */
+
+#define ao_arch_naked_declare __attribute__((naked))
+#define ao_arch_naked_define
+
+/*
+ * ao_timer.c
+ *
+ * We'll generally use the HSE clock through the PLL
+ */
+
+#define AO_STM_NVIC_CLOCK_PRIORITY 0xf0 /* low priority for clock */
+
+#if AO_HSE
+#define AO_PLLSRC AO_HSE
+#endif
+
+#if AO_HSI
+#define AO_PLLSRC STM_HSI_FREQ
+#endif
+
+#if AO_PLL_M
+#define AO_PLLIN (AO_PLLSRC / AO_PLL_M)
+#endif
+
+#if AO_PLL1_N
+
+#define AO_PLL1_VCO (AO_PLLIN * AO_PLL1_N)
+#define AO_PLL1_CLK_P (AO_PLL1_VCO / AO_PLL1_P)
+#define AO_SYSCLK (AO_PLL1_CLK_P)
+
+# if AO_PLL1_Q
+#define AO_PLL1_CLK_Q (AO_PLL1_VCO / AO_PLL1_Q)
+# endif
+
+#else
+
+#define AO_SYSCLK AO_PLLSRC
+
+#endif
+
+#if AO_PLL2_N
+
+#define AO_PLL2_VCO (AO_PLLIN * AO_PLL2_N)
+
+# if AO_PLL2_Q
+#define AO_PLL2_CLK_Q (AL_PLL2_VCO / AO_PLL2_Q)
+# endif
+
+# if AO_PLL2_R
+#define AO_PLL2_CLK_R (AL_PLL2_VCO / AO_PLL2_R)
+# endif
+
+#endif
+
+#define AO_HCLK (AO_SYSCLK / AO_AHB_PRESCALER)
+#define AO_P1CLK (AO_HCLK / AO_APB1_PRESCALER)
+#if AO_ABP1_PRESCALER == 1
+#define AO_P1_TIMER_CLK AO_P1CLK
+#else
+#define AO_P1_TIMER_CLK (AO_P1CLK * 2)
+#endif
+#define AO_P2CLK (AO_HCLK / AO_APB2_PRESCALER)
+#if AO_ABP2_PRESCALER == 1
+#define AO_P2_TIMER_CLK AO_P2CLK
+#else
+#define AO_P2_TIMER_CLK (AO_P2CLK * 2)
+#endif
+#define AO_SYSTICK (AO_HCLK)
+#define AO_PANIC_DELAY_SCALE (AO_SYSCLK / 12000000)
+
+/* The stm32f413 implements only 4 bits of the priority fields? */
+
+#if AO_NONMASK_INTERRUPT
+#define AO_STM_NVIC_NONMASK_PRIORITY 0x00
+
+/* Set the basepri register to this value to mask all
+ * non-maskable priorities
+ */
+#define AO_STM_NVIC_BASEPRI_MASK 0x10
+#endif
+
+#define AO_STM_NVIC_HIGH_PRIORITY 0x40
+#define AO_STM_NVIC_MED_PRIORITY 0x80
+#define AO_STM_NVIC_LOW_PRIORITY 0xC0
+#define AO_STM_NVIC_CLOCK_PRIORITY 0xf0
+
+#define AO_GPIO_MODE_PULL_NONE 0
+#define AO_GPIO_MODE_PULL_UP 4
+#define AO_GPIO_MODE_PULL_DOWN 8
+
+/* usart stuff */
+
+#define AO_SERIAL_SPEED_4800 4800
+#define AO_SERIAL_SPEED_9600 9600
+#define AO_SERIAL_SPEED_19200 19200
+#define AO_SERIAL_SPEED_57600 57600
+#define AO_SERIAL_SPEED_115200 115200
+
+#endif /* _AO_ARCH_H_ */
diff --git a/src/stm32f4/ao_arch_funcs.h b/src/stm32f4/ao_arch_funcs.h
new file mode 100644
index 00000000..b1ffb5b6
--- /dev/null
+++ b/src/stm32f4/ao_arch_funcs.h
@@ -0,0 +1,340 @@
+/*
+ * Copyright © 2018 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.
+ */
+
+#ifndef _AO_ARCH_FUNCS_H_
+#define _AO_ARCH_FUNCS_H_
+
+/* task functions */
+
+#define ARM_PUSH32(stack, val) (*(--(stack)) = (val))
+
+typedef uint32_t ao_arch_irq_t;
+
+static inline void
+ao_arch_block_interrupts(void) {
+#ifdef AO_NONMASK_INTERRUPTS
+ asm("msr basepri,%0" : : "r" (AO_STM_NVIC_BASEPRI_MASK));
+#else
+ asm("cpsid i");
+#endif
+}
+
+static inline void
+ao_arch_release_interrupts(void) {
+#ifdef AO_NONMASK_INTERRUPTS
+ asm("msr basepri,%0" : : "r" (0x0));
+#else
+ asm("cpsie i");
+#endif
+}
+
+static inline uint32_t
+ao_arch_irqsave(void) {
+ uint32_t val;
+#ifdef AO_NONMASK_INTERRUPTS
+ asm("mrs %0,basepri" : "=r" (val));
+#else
+ asm("mrs %0,primask" : "=r" (val));
+#endif
+ ao_arch_block_interrupts();
+ return val;
+}
+
+static inline void
+ao_arch_irqrestore(uint32_t basepri) {
+#ifdef AO_NONMASK_INTERRUPTS
+ asm("msr basepri,%0" : : "r" (basepri));
+#else
+ asm("msr primask,%0" : : "r" (basepri));
+#endif
+}
+
+static inline void
+ao_arch_memory_barrier() {
+ asm volatile("" ::: "memory");
+}
+
+static inline void
+ao_arch_irq_check(void) {
+#ifdef AO_NONMASK_INTERRUPTS
+ uint32_t basepri;
+ asm("mrs %0,basepri" : "=r" (basepri));
+ if (basepri == 0)
+ ao_panic(AO_PANIC_IRQ);
+#else
+ uint32_t primask;
+ asm("mrs %0,primask" : "=r" (primask));
+ if ((primask & 1) == 0)
+ ao_panic(AO_PANIC_IRQ);
+#endif
+}
+
+#if HAS_TASK
+static inline void
+ao_arch_init_stack(struct ao_task *task, void *start)
+{
+ uint32_t *sp = (uint32_t *) ((void*) task->stack + AO_STACK_SIZE);
+ uint32_t a = (uint32_t) start;
+ int i;
+
+ /* Return address (goes into LR) */
+ ARM_PUSH32(sp, a);
+
+ /* Clear register values r0-r12 */
+ i = 13;
+ while (i--)
+ ARM_PUSH32(sp, 0);
+
+ /* APSR */
+ ARM_PUSH32(sp, 0);
+
+ /* Clear register values s0-s31 */
+ i = 32;
+ while (i--)
+ ARM_PUSH32(sp, 0);
+
+ /* FPSCR */
+ ARM_PUSH32(sp, 0);
+
+ /* BASEPRI with interrupts enabled */
+ ARM_PUSH32(sp, 0);
+
+ task->sp = sp;
+}
+
+static inline void ao_arch_save_regs(void) {
+ /* Save general registers */
+ asm("push {r0-r12,lr}");
+
+ /* Save APSR */
+ asm("mrs r0,apsr");
+ asm("push {r0}");
+
+ /* Save FPU registers */
+ asm("vpush {s0-s15}");
+ asm("vpush {s16-s31}");
+
+ /* Save FPSCR */
+ asm("vmrs r0,fpscr");
+ asm("push {r0}");
+
+#ifdef AO_NONMASK_INTERRUPTS
+ /* Save BASEPRI */
+ asm("mrs r0,basepri");
+#else
+ /* Save PRIMASK */
+ asm("mrs r0,primask");
+#endif
+ asm("push {r0}");
+}
+
+static inline void ao_arch_save_stack(void) {
+ uint32_t *sp;
+ asm("mov %0,sp" : "=&r" (sp) );
+ ao_cur_task->sp = (sp);
+}
+
+static inline void ao_arch_restore_stack(void) {
+ /* Switch stacks */
+ asm("mov sp, %0" : : "r" (ao_cur_task->sp) );
+
+#ifdef AO_NONMASK_INTERRUPTS
+ /* Restore BASEPRI */
+ asm("pop {r0}");
+ asm("msr basepri,r0");
+#else
+ /* Restore PRIMASK */
+ asm("pop {r0}");
+ asm("msr primask,r0");
+#endif
+
+ /* Restore FPSCR */
+ asm("pop {r0}");
+ asm("vmsr fpscr,r0");
+
+ /* Restore FPU registers */
+ asm("vpop {s16-s31}");
+ asm("vpop {s0-s15}");
+
+ /* Restore APSR */
+ asm("pop {r0}");
+ asm("msr apsr_nczvq,r0");
+
+ /* Restore general registers */
+ asm("pop {r0-r12,lr}\n");
+
+ /* Return to calling function */
+ asm("bx lr");
+}
+
+#ifndef HAS_SAMPLE_PROFILE
+#define HAS_SAMPLE_PROFILE 0
+#endif
+
+#if DEBUG
+#define HAS_ARCH_VALIDATE_CUR_STACK 1
+
+static inline void
+ao_validate_cur_stack(void)
+{
+ uint8_t *psp;
+
+ asm("mrs %0,psp" : "=&r" (psp));
+ if (ao_cur_task &&
+ psp <= ao_cur_task->stack &&
+ psp >= ao_cur_task->stack - 256)
+ ao_panic(AO_PANIC_STACK);
+}
+#endif
+
+#if !HAS_SAMPLE_PROFILE
+#define HAS_ARCH_START_SCHEDULER 1
+
+static inline void ao_arch_start_scheduler(void) {
+ uint32_t sp;
+ uint32_t control;
+
+ asm("mrs %0,msp" : "=&r" (sp));
+ asm("msr psp,%0" : : "r" (sp));
+ asm("mrs %0,control" : "=r" (control));
+ control |= (1 << 1);
+ asm("msr control,%0" : : "r" (control));
+ asm("isb");
+}
+#endif
+
+#define ao_arch_isr_stack()
+
+#endif
+
+static inline void
+ao_arch_wait_interrupt(void) {
+#ifdef AO_NONMASK_INTERRUPTS
+ asm(
+ "dsb\n" /* Serialize data */
+ "isb\n" /* Serialize instructions */
+ "cpsid i\n" /* Block all interrupts */
+ "msr basepri,%0\n" /* Allow all interrupts through basepri */
+ "wfi\n" /* Wait for an interrupt */
+ "cpsie i\n" /* Allow all interrupts */
+ "msr basepri,%1\n" /* Block interrupts through basepri */
+ : : "r" (0), "r" (AO_STM_NVIC_BASEPRI_MASK));
+#else
+ asm("\twfi\n");
+ ao_arch_release_interrupts();
+ ao_arch_block_interrupts();
+#endif
+}
+
+#define ao_arch_critical(b) do { \
+ uint32_t __mask = ao_arch_irqsave(); \
+ do { b } while (0); \
+ ao_arch_irqrestore(__mask); \
+ } while (0)
+
+/* GPIO functions */
+
+#define ao_power_register(gpio)
+#define ao_power_unregister(gpio)
+
+static inline void ao_enable_port(struct stm_gpio *port)
+{
+ if ((port) == &stm_gpioa) {
+ stm_rcc.ahb1enr |= (1 << STM_RCC_AHB1ENR_IOPAEN);
+ ao_power_register(&ao_power_gpioa);
+ } else if ((port) == &stm_gpiob) {
+ stm_rcc.ahb1enr |= (1 << STM_RCC_AHB1ENR_IOPBEN);
+ ao_power_register(&ao_power_gpiob);
+ } else if ((port) == &stm_gpioc) {
+ stm_rcc.ahb1enr |= (1 << STM_RCC_AHB1ENR_IOPCEN);
+ ao_power_register(&ao_power_gpioc);
+ } else if ((port) == &stm_gpiod) {
+ stm_rcc.ahb1enr |= (1 << STM_RCC_AHB1ENR_IOPDEN);
+ ao_power_register(&ao_power_gpiod);
+ } else if ((port) == &stm_gpioe) {
+ stm_rcc.ahb1enr |= (1 << STM_RCC_AHB1ENR_IOPEEN);
+ ao_power_register(&ao_power_gpioe);
+ } else if ((port) == &stm_gpiof) {
+ stm_rcc.ahb1enr |= (1 << STM_RCC_AHB1ENR_IOPFEN);
+ ao_power_register(&ao_power_gpiof);
+ } else if ((port) == &stm_gpiog) {
+ stm_rcc.ahb1enr |= (1 << STM_RCC_AHB1ENR_IOPGEN);
+ ao_power_register(&ao_power_gpiog);
+ } else if ((port) == &stm_gpioh) {
+ stm_rcc.ahb1enr |= (1 << STM_RCC_AHB1ENR_IOPHEN);
+ ao_power_register(&ao_power_gpioh);
+ }
+}
+
+static inline void ao_disable_port(struct stm_gpio *port)
+{
+ if ((port) == &stm_gpioa) {
+ stm_rcc.ahb1enr &= ~(1 << STM_RCC_AHB1ENR_IOPAEN);
+ ao_power_unregister(&ao_power_gpioa);
+ } else if ((port) == &stm_gpiob) {
+ stm_rcc.ahb1enr &= ~(1 << STM_RCC_AHB1ENR_IOPBEN);
+ ao_power_unregister(&ao_power_gpiob);
+ } else if ((port) == &stm_gpioc) {
+ stm_rcc.ahb1enr &= ~(1 << STM_RCC_AHB1ENR_IOPCEN);
+ ao_power_unregister(&ao_power_gpioc);
+ } else if ((port) == &stm_gpiod) {
+ stm_rcc.ahb1enr &= ~(1 << STM_RCC_AHB1ENR_IOPDEN);
+ ao_power_unregister(&ao_power_gpiod);
+ } else if ((port) == &stm_gpioe) {
+ stm_rcc.ahb1enr &= ~(1 << STM_RCC_AHB1ENR_IOPEEN);
+ ao_power_unregister(&ao_power_gpioe);
+ } else if ((port) == &stm_gpiof) {
+ stm_rcc.ahb1enr &= ~(1 << STM_RCC_AHB1ENR_IOPFEN);
+ ao_power_unregister(&ao_power_gpiof);
+ } else if ((port) == &stm_gpiog) {
+ stm_rcc.ahb1enr &= ~(1 << STM_RCC_AHB1ENR_IOPGEN);
+ ao_power_unregister(&ao_power_gpiog);
+ } else if ((port) == &stm_gpioh) {
+ stm_rcc.ahb1enr &= ~(1 << STM_RCC_AHB1ENR_IOPHEN);
+ ao_power_unregister(&ao_power_gpioh);
+ }
+}
+
+#define ao_gpio_set(port, bit, v) stm_gpio_set(port, bit, v)
+
+#define ao_gpio_get(port, bit) stm_gpio_get(port, bit)
+
+#define ao_enable_output(port,bit,v) do { \
+ ao_enable_port(port); \
+ ao_gpio_set(port, bit, v); \
+ stm_moder_set(port, bit, STM_MODER_OUTPUT);\
+ } while (0)
+
+#define ao_gpio_set_mode(port,bit,mode) do { \
+ if (mode == AO_EXTI_MODE_PULL_UP) \
+ stm_pupdr_set(port, bit, STM_PUPDR_PULL_UP); \
+ else if (mode == AO_EXTI_MODE_PULL_DOWN) \
+ stm_pupdr_set(port, bit, STM_PUPDR_PULL_DOWN); \
+ else \
+ stm_pupdr_set(port, bit, STM_PUPDR_NONE); \
+ } while (0)
+
+#define ao_enable_input(port,bit,mode) do { \
+ ao_enable_port(port); \
+ stm_moder_set(port, bit, STM_MODER_INPUT); \
+ ao_gpio_set_mode(port, bit, mode); \
+ } while (0)
+
+/* usart */
+
+void
+ao_usart_init(void);
+
+
+#endif /* _AO_ARCH_FUNCS_H_ */
diff --git a/src/cc1111/ao_exti.h b/src/stm32f4/ao_exti.h
index 927a4f09..0216f352 100644
--- a/src/cc1111/ao_exti.h
+++ b/src/stm32f4/ao_exti.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ * Copyright © 2018 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
@@ -21,37 +21,30 @@
#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_MODE_PULL_NONE AO_GPIO_MODE_PULL_NONE
+#define AO_EXTI_MODE_PULL_UP AO_GPIO_MODE_PULL_UP
+#define AO_EXTI_MODE_PULL_DOWN AO_GPIO_MODE_PULL_DOWN
#define AO_EXTI_PRIORITY_LOW 16
#define AO_EXTI_PRIORITY_MED 0
#define AO_EXTI_PRIORITY_HIGH 32
+#define AO_EXTI_PIN_NOCONFIGURE 64
-extern void (*ao_int_callback)(void);
+void
+ao_exti_setup(struct stm_gpio *gpio, uint8_t pin, uint8_t mode, void (*callback)());
-#define ao_exti_setup(gpio, pin, mode, callback) do { \
- ao_int_callback = callback; \
- } while (0)
+void
+ao_exti_set_mode(struct stm_gpio *gpio, uint8_t pin, uint8_t mode);
-#define ao_exti_set_mode(gpio, pin, mode) do { \
- } while (0)
+void
+ao_exti_set_callback(struct stm_gpio *gpio, uint8_t pin, void (*callback)());
-#define ao_exti_set_callback(port, pin, callback) do { \
- ao_int_callback = callback; \
- } while (0)
+void
+ao_exti_enable(struct stm_gpio *gpio, uint8_t pin);
-#define ao_exti_init()
+void
+ao_exti_disable(struct stm_gpio *gpio, uint8_t pin);
-#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)
+void
+ao_exti_init(void);
#endif /* _AO_EXTI_H_ */
diff --git a/src/stm32f4/ao_exti_stm32f4.c b/src/stm32f4/ao_exti_stm32f4.c
new file mode 100644
index 00000000..1e288f9c
--- /dev/null
+++ b/src/stm32f4/ao_exti_stm32f4.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright © 2018 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>
+#include <ao_exti.h>
+
+static void (*ao_exti_callback[16])(void);
+
+uint32_t ao_last_exti;
+
+static void ao_exti_one_isr(uint8_t pin) {
+ uint32_t pending = (ao_last_exti = stm_exti.pr) & (1 << pin);
+
+ stm_exti.pr = pending;
+ if (pending && ao_exti_callback[pin])
+ (*ao_exti_callback[pin])();
+}
+
+static void ao_exti_range_isr(uint8_t first, uint8_t last, uint16_t mask) {
+ uint16_t pending = (ao_last_exti = stm_exti.pr) & mask;
+ uint8_t pin;
+ static uint16_t last_mask;
+ static uint8_t last_pin;
+
+ if (pending == last_mask) {
+ stm_exti.pr = last_mask;
+ (*ao_exti_callback[last_pin])();
+ return;
+ }
+ stm_exti.pr = pending;
+ for (pin = first; pin <= last; pin++)
+ if ((pending & ((uint32_t) 1 << pin)) && ao_exti_callback[pin]) {
+ last_mask = (1 << pin);
+ last_pin = pin;
+ (*ao_exti_callback[pin])();
+ }
+}
+
+void stm_exti0_isr(void) { ao_exti_one_isr(0); }
+void stm_exti1_isr(void) { ao_exti_one_isr(1); }
+void stm_exti2_isr(void) { ao_exti_one_isr(2); }
+void stm_exti3_isr(void) { ao_exti_one_isr(3); }
+void stm_exti4_isr(void) { ao_exti_one_isr(4); }
+void stm_exti9_5_isr(void) { ao_exti_range_isr(5, 9, 0x3e0); }
+void stm_exti15_10_isr(void) { ao_exti_range_isr(10, 15, 0xfc00); }
+
+void
+ao_exti_setup (struct stm_gpio *gpio, uint8_t pin, uint8_t mode, void (*callback)(void)) {
+ uint32_t mask = 1 << pin;
+ uint32_t pupdr;
+ uint8_t irq;
+ uint8_t prio;
+
+ ao_exti_callback[pin] = callback;
+
+ /* configure gpio to interrupt routing */
+ stm_exticr_set(gpio, pin);
+
+ if (!(mode & AO_EXTI_PIN_NOCONFIGURE)) {
+ /* configure pin as input, setting selected pull-up/down mode */
+ stm_moder_set(gpio, pin, STM_MODER_INPUT);
+ switch (mode & (AO_EXTI_MODE_PULL_UP|AO_EXTI_MODE_PULL_DOWN)) {
+ case 0:
+ default:
+ pupdr = STM_PUPDR_NONE;
+ break;
+ case AO_EXTI_MODE_PULL_UP:
+ pupdr = STM_PUPDR_PULL_UP;
+ break;
+ case AO_EXTI_MODE_PULL_DOWN:
+ pupdr = STM_PUPDR_PULL_DOWN;
+ break;
+ }
+ stm_pupdr_set(gpio, pin, pupdr);
+ }
+
+ /* Set interrupt mask and rising/falling mode */
+ stm_exti.imr &= ~mask;
+ if (mode & AO_EXTI_MODE_RISING)
+ stm_exti.rtsr |= mask;
+ else
+ stm_exti.rtsr &= ~mask;
+ if (mode & AO_EXTI_MODE_FALLING)
+ stm_exti.ftsr |= mask;
+ else
+ stm_exti.ftsr &= ~mask;
+
+ if (pin <= 4)
+ irq = STM_ISR_EXTI0_POS + pin;
+ else if (pin <= 9)
+ irq = STM_ISR_EXTI9_5_POS;
+ else
+ irq = STM_ISR_EXTI15_10_POS;
+
+ /* Set priority */
+ prio = AO_STM_NVIC_MED_PRIORITY;
+ if (mode & AO_EXTI_PRIORITY_LOW)
+ prio = AO_STM_NVIC_LOW_PRIORITY;
+ else if (mode & AO_EXTI_PRIORITY_HIGH)
+ prio = AO_STM_NVIC_HIGH_PRIORITY;
+
+ stm_nvic_set_priority(irq, prio);
+ stm_nvic_set_enable(irq);
+}
+
+void
+ao_exti_set_mode(struct stm_gpio *gpio, uint8_t pin, uint8_t mode) {
+ (void) gpio;
+
+ uint32_t mask = 1 << pin;
+
+ if (mode & AO_EXTI_MODE_RISING)
+ stm_exti.rtsr |= mask;
+ else
+ stm_exti.rtsr &= ~mask;
+ if (mode & AO_EXTI_MODE_FALLING)
+ stm_exti.ftsr |= mask;
+ else
+ stm_exti.ftsr &= ~mask;
+}
+
+void
+ao_exti_set_callback(struct stm_gpio *gpio, uint8_t pin, void (*callback)()) {
+ (void) gpio;
+ ao_exti_callback[pin] = callback;
+}
+
+void
+ao_exti_enable(struct stm_gpio *gpio, uint8_t pin) {
+ uint32_t mask = (1 << pin);
+ (void) gpio;
+ stm_exti.pr = mask;
+ stm_exti.imr |= mask;
+}
+
+void
+ao_exti_disable(struct stm_gpio *gpio, uint8_t pin) {
+ uint32_t mask = (1 << pin);
+ (void) gpio;
+ stm_exti.imr &= ~mask;
+ stm_exti.pr = mask;
+}
+
+void
+ao_exti_init(void)
+{
+}
diff --git a/src/stm32f4/ao_interrupt.c b/src/stm32f4/ao_interrupt.c
new file mode 100644
index 00000000..24f56abc
--- /dev/null
+++ b/src/stm32f4/ao_interrupt.c
@@ -0,0 +1,290 @@
+/*
+ * Copyright © 2018 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>
+#include "stm32f4.h"
+#include <string.h>
+#include <ao_boot.h>
+
+extern void main(void);
+extern char __stack__;
+extern char __text_start__, __text_end__;
+extern char _start__, _end__;
+extern char __bss_start__, __bss_end__;
+
+/* Interrupt functions */
+
+void stm_halt_isr(void)
+{
+ ao_panic(AO_PANIC_CRASH);
+}
+
+void stm_ignore_isr(void)
+{
+}
+
+const void *stm_interrupt_vector[];
+
+void start(void)
+{
+#ifdef AO_BOOT_CHAIN
+ if (ao_boot_check_chain()) {
+#ifdef AO_BOOT_PIN
+ ao_boot_check_pin();
+#endif
+ }
+#endif
+ /* Enable FPU */
+ stm_scb.cpacr |= ((STM_SCB_CPACR_FULL << STM_SCB_CPACR_FP0) |
+ (STM_SCB_CPACR_FULL << STM_SCB_CPACR_FP1));
+ ao_arch_nop();
+ /* Set interrupt vector table offset */
+ stm_scb.vtor = (uint32_t) &stm_interrupt_vector;
+ memcpy(&_start__, &__text_end__, &_end__ - &_start__);
+ memset(&__bss_start__, '\0', &__bss_end__ - &__bss_start__);
+ main();
+}
+
+#define STRINGIFY(x) #x
+
+#define isr(name) \
+ void __attribute__ ((weak)) stm_ ## name ## _isr(void); \
+ _Pragma(STRINGIFY(weak stm_ ## name ## _isr = stm_ignore_isr))
+
+#define isr_halt(name) \
+ void __attribute__ ((weak)) stm_ ## name ## _isr(void); \
+ _Pragma(STRINGIFY(weak stm_ ## name ## _isr = stm_halt_isr))
+
+isr(nmi)
+isr_halt(hardfault)
+isr_halt(memmanage)
+isr_halt(busfault)
+isr_halt(usagefault)
+isr(svc)
+isr(debugmon)
+isr(pendsv)
+isr(systick)
+isr(wwdg)
+isr(pvd)
+isr(tamper_stamp)
+isr(rtc_wkup)
+isr(flash)
+isr(rcc)
+isr(exti0)
+isr(exti1)
+isr(exti2)
+isr(exti3)
+isr(exti4)
+isr(dma1_stream0)
+isr(dma1_stream1)
+isr(dma1_stream2)
+isr(dma1_stream3)
+isr(dma1_stream4)
+isr(dma1_stream5)
+isr(dma1_stream6)
+isr(adc)
+isr(can1_tx)
+isr(can1_rx0)
+isr(can1_rx1)
+isr(can1_sce)
+isr(exti9_5)
+isr(tim1_brk_tim9)
+isr(tim1_up_tim10)
+isr(tim_trg_com_tim11)
+isr(tim1_cc)
+isr(tim2)
+isr(tim3)
+isr(tim4)
+isr(i2c1_evt)
+isr(i2c1_err)
+isr(i2c2_evt)
+isr(i2c2_err)
+isr(spi1)
+isr(spi2)
+isr(usart1)
+isr(usart2)
+isr(usart3)
+isr(exti15_10)
+isr(rtc_alarm)
+isr(otg_fs_wkup)
+isr(tim8_brk_tim12)
+isr(tim8_up_tim13)
+isr(tim8_trg_com_tim14)
+isr(tim8_cc)
+isr(dma1_stream7)
+isr(fsmc)
+isr(sdio)
+isr(tim5)
+isr(spi3)
+isr(uart4)
+isr(uart5)
+isr(tim6_glb_it)
+isr(tim7)
+isr(dma2_stream0)
+isr(dma2_stream1)
+isr(dma2_stream2)
+isr(dma2_stream3)
+isr(dma2_stream4)
+isr(dfsdm1_flt0)
+isr(dfsdm1_flt1)
+isr(can2_tx)
+isr(can2_rx0)
+isr(can2_rx1)
+isr(can2_sce)
+isr(otg_fs)
+isr(dma2_stream5)
+isr(dma2_stream6)
+isr(dma2_stream7)
+isr(usart6)
+isr(i2c3_ev)
+isr(i2c3_er)
+isr(can3_tx)
+isr(can3_rx0)
+isr(can3_rx1)
+isr(can3_sce)
+isr(crypto)
+isr(rng)
+isr(fpu)
+isr(uart7)
+isr(uart8)
+isr(spi4)
+isr(spi5)
+isr(sai1)
+isr(uart9)
+isr(uart10)
+isr(quad_spi)
+isr(i2cfmp1_ev)
+isr(i2cfmp1_er)
+isr(exti23)
+isr(dfsdm2_flt0)
+isr(dfsdm2_flt1)
+isr(dfsdm2_flt2)
+isr(dfsdm2_flt3)
+
+#define i(addr,name) [(addr)/4] = stm_ ## name ## _isr
+
+__attribute__ ((section(".interrupt")))
+const void *stm_interrupt_vector[] = {
+ [0] = &__stack__,
+ [1] = start,
+ i(0x08, nmi),
+ i(0x0c, hardfault),
+ i(0x10, memmanage),
+ i(0x14, busfault),
+ i(0x18, usagefault),
+ i(0x2c, svc),
+ i(0x30, debugmon),
+ i(0x38, pendsv),
+ i(0x3c, systick),
+ i(0x40, wwdg),
+ i(0x44, pvd),
+ i(0x48, tamper_stamp),
+ i(0x4c, rtc_wkup),
+ i(0x50, flash),
+ i(0x54, rcc),
+ i(0x58, exti0),
+ i(0x5c, exti1),
+ i(0x60, exti2),
+ i(0x64, exti3),
+ i(0x68, exti4),
+ i(0x6c, dma1_stream0),
+ i(0x70, dma1_stream1),
+ i(0x74, dma1_stream2),
+ i(0x78, dma1_stream3),
+ i(0x7c, dma1_stream4),
+ i(0x80, dma1_stream5),
+ i(0x84, dma1_stream6),
+ i(0x88, adc),
+ i(0x8c, can1_tx),
+ i(0x90, can1_rx0),
+ i(0x94, can1_rx1),
+ i(0x98, can1_sce),
+ i(0x9c, exti9_5),
+ i(0xa0, tim1_brk_tim9),
+ i(0xa4, tim1_up_tim10),
+ i(0xa8, tim_trg_com_tim11),
+ i(0xac, tim1_cc),
+ i(0xb0, tim2),
+ i(0xb4, tim3),
+ i(0xb8, tim4),
+ i(0xbc, i2c1_evt),
+ i(0xc0, i2c1_err),
+ i(0xc4, i2c2_evt),
+ i(0xc8, i2c2_err),
+ i(0xcc, spi1),
+ i(0xd0, spi2),
+ i(0xd4, usart1),
+ i(0xd8, usart2),
+ i(0xdc, usart3),
+ i(0xe0, exti15_10),
+ i(0xe4, rtc_alarm),
+ i(0xe8, otg_fs_wkup),
+ i(0xec, tim8_brk_tim12),
+ i(0xf0, tim8_up_tim13),
+ i(0xf4, tim8_trg_com_tim14),
+ i(0xf8, tim8_cc),
+ i(0xfc, dma1_stream7),
+ i(0x100, fsmc),
+ i(0x104, sdio),
+ i(0x108, tim5),
+ i(0x10c, spi3),
+ i(0x110, uart4),
+ i(0x114, uart5),
+ i(0x118,tim6_glb_it),
+ i(0x11c, tim7),
+ i(0x120, dma2_stream0),
+ i(0x124, dma2_stream1),
+ i(0x128, dma2_stream2),
+ i(0x12c, dma2_stream3),
+ i(0x130, dma2_stream4),
+ i(0x134, dfsdm1_flt0),
+ i(0x138, dfsdm1_flt1),
+ i(0x13c, can2_tx),
+ i(0x140, can2_rx0),
+ i(0x144, can2_rx1),
+ i(0x148, can2_sce),
+ i(0x14c, otg_fs),
+ i(0x150, dma2_stream5),
+ i(0x154, dma2_stream6),
+ i(0x158, dma2_stream7),
+ i(0x15c, usart6),
+ i(0x160, i2c3_ev),
+ i(0x164, i2c3_er),
+ i(0x168, can3_tx),
+ i(0x16c, can3_rx0),
+ i(0x170, can3_rx1),
+ i(0x174, can3_sce),
+ i(0x17c, crypto),
+ i(0x180, rng),
+ i(0x184, fpu),
+ i(0x188, uart7),
+ i(0x18c, uart8),
+ i(0x190, spi4),
+ i(0x194, spi5),
+ i(0x19c, sai1),
+ i(0x1a0, uart9),
+ i(0x1a4, uart10),
+ i(0x1b0, quad_spi),
+ i(0x1bc, i2cfmp1_ev),
+ i(0x1c0, i2cfmp1_er),
+ i(0x1c4, exti23),
+ i(0x1c8, dfsdm2_flt0),
+ i(0x1cc, dfsdm2_flt1),
+ i(0x1d0, dfsdm2_flt2),
+ i(0x1d4, dfsdm2_flt3),
+};
diff --git a/src/stm32f4/ao_serial_stm32f4.c b/src/stm32f4/ao_serial_stm32f4.c
new file mode 100644
index 00000000..bcecc791
--- /dev/null
+++ b/src/stm32f4/ao_serial_stm32f4.c
@@ -0,0 +1,544 @@
+/*
+ * Copyright © 2018 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>
+#include <ao_exti.h>
+
+static int
+_ao_usart_tx_start(struct ao_stm_usart *usart)
+{
+ if (!ao_fifo_empty(usart->tx_fifo)) {
+#if HAS_SERIAL_SW_FLOW
+ if (usart->gpio_cts && ao_gpio_get(usart->gpio_cts, usart->pin_cts) == 1) {
+ ao_exti_enable(usart->gpio_cts, usart->pin_cts);
+ return 0;
+ }
+#endif
+ if (usart->reg->sr & (1 << STM_USART_SR_TXE))
+ {
+ usart->tx_running = 1;
+ usart->reg->cr1 |= (1 << STM_USART_CR1_TXEIE) | (1 << STM_USART_CR1_TCIE);
+ ao_fifo_remove(usart->tx_fifo, usart->reg->dr);
+ ao_wakeup(&usart->tx_fifo);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+#if HAS_SERIAL_SW_FLOW
+static void
+_ao_usart_cts(struct ao_stm_usart *usart)
+{
+ if (_ao_usart_tx_start(usart))
+ ao_exti_disable(usart->gpio_cts, usart->pin_cts);
+}
+#endif
+
+static void
+_ao_usart_rx(struct ao_stm_usart *usart, int is_stdin)
+{
+ if (usart->reg->sr & (1 << STM_USART_SR_RXNE)) {
+ if (!ao_fifo_full(usart->rx_fifo)) {
+ ao_fifo_insert(usart->rx_fifo, usart->reg->dr);
+ ao_wakeup(&usart->rx_fifo);
+ if (is_stdin)
+ ao_wakeup(&ao_stdin_ready);
+#if HAS_SERIAL_SW_FLOW
+ /* If the fifo is nearly full, turn off RTS and wait
+ * for it to drain a bunch
+ */
+ if (usart->gpio_rts && ao_fifo_mostly(usart->rx_fifo)) {
+ ao_gpio_set(usart->gpio_rts, usart->pin_rts, 1);
+ usart->rts = 0;
+ }
+#endif
+ } else {
+ usart->reg->cr1 &= ~(1 << STM_USART_CR1_RXNEIE);
+ }
+ }
+}
+
+static void
+ao_usart_isr(struct ao_stm_usart *usart, int is_stdin)
+{
+ _ao_usart_rx(usart, is_stdin);
+
+ if (!_ao_usart_tx_start(usart))
+ usart->reg->cr1 &= ~(1<< STM_USART_CR1_TXEIE);
+
+ if (usart->reg->sr & (1 << STM_USART_SR_TC)) {
+ usart->tx_running = 0;
+ usart->reg->cr1 &= ~(1 << STM_USART_CR1_TCIE);
+ if (usart->draining) {
+ usart->draining = 0;
+ ao_wakeup(&usart->tx_fifo);
+ }
+ }
+}
+
+static int
+_ao_usart_pollchar(struct ao_stm_usart *usart)
+{
+ int c;
+
+ if (ao_fifo_empty(usart->rx_fifo))
+ c = AO_READ_AGAIN;
+ else {
+ uint8_t u;
+ ao_fifo_remove(usart->rx_fifo,u);
+ if ((usart->reg->cr1 & (1 << STM_USART_CR1_RXNEIE)) == 0) {
+ if (ao_fifo_barely(usart->rx_fifo))
+ usart->reg->cr1 |= (1 << STM_USART_CR1_RXNEIE);
+ }
+#if HAS_SERIAL_SW_FLOW
+ /* If we've cleared RTS, check if there's space now and turn it back on */
+ if (usart->gpio_rts && usart->rts == 0 && ao_fifo_barely(usart->rx_fifo)) {
+ ao_gpio_set(usart->gpio_rts, usart->pin_rts, 0);
+ usart->rts = 1;
+ }
+#endif
+ c = u;
+ }
+ return c;
+}
+
+static char
+ao_usart_getchar(struct ao_stm_usart *usart)
+{
+ int c;
+ ao_arch_block_interrupts();
+ while ((c = _ao_usart_pollchar(usart)) == AO_READ_AGAIN)
+ ao_sleep(&usart->rx_fifo);
+ ao_arch_release_interrupts();
+ return (char) c;
+}
+
+static inline uint8_t
+_ao_usart_sleep_for(struct ao_stm_usart *usart, uint16_t timeout)
+{
+ return ao_sleep_for(&usart->rx_fifo, timeout);
+}
+
+static void
+ao_usart_putchar(struct ao_stm_usart *usart, char c)
+{
+ ao_arch_block_interrupts();
+ while (ao_fifo_full(usart->tx_fifo))
+ ao_sleep(&usart->tx_fifo);
+ ao_fifo_insert(usart->tx_fifo, c);
+ _ao_usart_tx_start(usart);
+ ao_arch_release_interrupts();
+}
+
+static void
+ao_usart_drain(struct ao_stm_usart *usart)
+{
+ ao_arch_block_interrupts();
+ while (!ao_fifo_empty(usart->tx_fifo) || usart->tx_running) {
+ usart->draining = 1;
+ ao_sleep(&usart->tx_fifo);
+ }
+ ao_arch_release_interrupts();
+}
+
+static const struct {
+ uint32_t brr;
+} ao_usart_speeds[] = {
+ [AO_SERIAL_SPEED_4800] = {
+ AO_PCLK1 / 4800
+ },
+ [AO_SERIAL_SPEED_9600] = {
+ AO_PCLK1 / 9600
+ },
+ [AO_SERIAL_SPEED_19200] = {
+ AO_PCLK1 / 19200
+ },
+ [AO_SERIAL_SPEED_57600] = {
+ AO_PCLK1 / 57600
+ },
+ [AO_SERIAL_SPEED_115200] = {
+ AO_PCLK1 / 115200
+ },
+};
+
+static void
+ao_usart_set_speed(struct ao_stm_usart *usart, uint8_t speed)
+{
+ if (speed > AO_SERIAL_SPEED_115200)
+ return;
+ usart->reg->brr = ao_usart_speeds[speed].brr;
+}
+
+static void
+ao_usart_init(struct ao_stm_usart *usart, int hw_flow)
+{
+ usart->reg->cr1 = ((0 << STM_USART_CR1_OVER8) |
+ (1 << STM_USART_CR1_UE) |
+ (0 << STM_USART_CR1_M) |
+ (0 << STM_USART_CR1_WAKE) |
+ (0 << STM_USART_CR1_PCE) |
+ (0 << STM_USART_CR1_PS) |
+ (0 << STM_USART_CR1_PEIE) |
+ (0 << STM_USART_CR1_TXEIE) |
+ (0 << STM_USART_CR1_TCIE) |
+ (1 << STM_USART_CR1_RXNEIE) |
+ (0 << STM_USART_CR1_IDLEIE) |
+ (1 << STM_USART_CR1_TE) |
+ (1 << STM_USART_CR1_RE) |
+ (0 << STM_USART_CR1_RWU) |
+ (0 << STM_USART_CR1_SBK));
+
+ usart->reg->cr2 = ((0 << STM_USART_CR2_LINEN) |
+ (STM_USART_CR2_STOP_1 << STM_USART_CR2_STOP) |
+ (0 << STM_USART_CR2_CLKEN) |
+ (0 << STM_USART_CR2_CPOL) |
+ (0 << STM_USART_CR2_CPHA) |
+ (0 << STM_USART_CR2_LBCL) |
+ (0 << STM_USART_CR2_LBDIE) |
+ (0 << STM_USART_CR2_LBDL) |
+ (0 << STM_USART_CR2_ADD));
+
+ usart->reg->cr3 = ((0 << STM_USART_CR3_ONEBITE) |
+ (0 << STM_USART_CR3_CTSIE) |
+ (0 << STM_USART_CR3_CTSE) |
+ (0 << STM_USART_CR3_RTSE) |
+ (0 << STM_USART_CR3_DMAT) |
+ (0 << STM_USART_CR3_DMAR) |
+ (0 << STM_USART_CR3_SCEN) |
+ (0 << STM_USART_CR3_NACK) |
+ (0 << STM_USART_CR3_HDSEL) |
+ (0 << STM_USART_CR3_IRLP) |
+ (0 << STM_USART_CR3_IREN) |
+ (0 << STM_USART_CR3_EIE));
+
+ if (hw_flow)
+ usart->reg->cr3 |= ((1 << STM_USART_CR3_CTSE) |
+ (1 << STM_USART_CR3_RTSE));
+
+ /* Pick a 9600 baud rate */
+ ao_usart_set_speed(usart, AO_SERIAL_SPEED_9600);
+}
+
+#if HAS_SERIAL_HW_FLOW
+static void
+ao_usart_set_flow(struct ao_stm_usart *usart)
+{
+}
+#endif
+
+#if HAS_SERIAL_1
+
+struct ao_stm_usart ao_stm_usart1;
+
+void stm_usart1_isr(void) { ao_usart_isr(&ao_stm_usart1, USE_SERIAL_1_STDIN); }
+
+char
+ao_serial1_getchar(void)
+{
+ return ao_usart_getchar(&ao_stm_usart1);
+}
+
+void
+ao_serial1_putchar(char c)
+{
+ ao_usart_putchar(&ao_stm_usart1, c);
+}
+
+int
+_ao_serial1_pollchar(void)
+{
+ return _ao_usart_pollchar(&ao_stm_usart1);
+}
+
+uint8_t
+_ao_serial1_sleep_for(uint16_t timeout)
+{
+ return _ao_usart_sleep_for(&ao_stm_usart1, timeout);
+}
+
+void
+ao_serial1_drain(void)
+{
+ ao_usart_drain(&ao_stm_usart1);
+}
+
+void
+ao_serial1_set_speed(uint8_t speed)
+{
+ ao_usart_drain(&ao_stm_usart1);
+ ao_usart_set_speed(&ao_stm_usart1, speed);
+}
+#endif /* HAS_SERIAL_1 */
+
+#if HAS_SERIAL_2
+
+struct ao_stm_usart ao_stm_usart2;
+
+void stm_usart2_isr(void) { ao_usart_isr(&ao_stm_usart2, USE_SERIAL_2_STDIN); }
+
+char
+ao_serial2_getchar(void)
+{
+ return ao_usart_getchar(&ao_stm_usart2);
+}
+
+void
+ao_serial2_putchar(char c)
+{
+ ao_usart_putchar(&ao_stm_usart2, c);
+}
+
+int
+_ao_serial2_pollchar(void)
+{
+ return _ao_usart_pollchar(&ao_stm_usart2);
+}
+
+uint8_t
+_ao_serial2_sleep_for(uint16_t timeout)
+{
+ return _ao_usart_sleep_for(&ao_stm_usart2, timeout);
+}
+
+void
+ao_serial2_drain(void)
+{
+ ao_usart_drain(&ao_stm_usart2);
+}
+
+void
+ao_serial2_set_speed(uint8_t speed)
+{
+ ao_usart_drain(&ao_stm_usart2);
+ ao_usart_set_speed(&ao_stm_usart2, speed);
+}
+
+#if HAS_SERIAL_SW_FLOW
+void
+ao_serial2_cts(void)
+{
+ _ao_usart_cts(&ao_stm_usart2);
+}
+#endif
+
+#endif /* HAS_SERIAL_2 */
+
+#if HAS_SERIAL_3
+
+struct ao_stm_usart ao_stm_usart3;
+
+void stm_usart3_isr(void) { ao_usart_isr(&ao_stm_usart3, USE_SERIAL_3_STDIN); }
+
+char
+ao_serial3_getchar(void)
+{
+ return ao_usart_getchar(&ao_stm_usart3);
+}
+
+void
+ao_serial3_putchar(char c)
+{
+ ao_usart_putchar(&ao_stm_usart3, c);
+}
+
+int
+_ao_serial3_pollchar(void)
+{
+ return _ao_usart_pollchar(&ao_stm_usart3);
+}
+
+uint8_t
+_ao_serial3_sleep_for(uint16_t timeout)
+{
+ return _ao_usart_sleep_for(&ao_stm_usart3, timeout);
+}
+
+void
+ao_serial3_set_speed(uint8_t speed)
+{
+ ao_usart_drain(&ao_stm_usart3);
+ ao_usart_set_speed(&ao_stm_usart3, speed);
+}
+
+void
+ao_serial3_drain(void)
+{
+ ao_usart_drain(&ao_stm_usart3);
+}
+#endif /* HAS_SERIAL_3 */
+
+#if HAS_SERIAL_SW_FLOW
+static void
+ao_serial_set_sw_rts_cts(struct ao_stm_usart *usart,
+ void (*isr)(void),
+ struct stm_gpio *port_rts,
+ int pin_rts,
+ struct stm_gpio *port_cts,
+ int pin_cts)
+{
+ /* Pull RTS low to note that there's space in the FIFO
+ */
+ ao_enable_output(port_rts, pin_rts, 0);
+ usart->gpio_rts = port_rts;
+ usart->pin_rts = pin_rts;
+ usart->rts = 1;
+
+ ao_exti_setup(port_cts, pin_cts, AO_EXTI_MODE_FALLING|AO_EXTI_PRIORITY_MED, isr);
+ usart->gpio_cts = port_cts;
+ usart->pin_cts = pin_cts;
+}
+#endif
+
+void
+ao_serial_init(void)
+{
+#if HAS_SERIAL_1
+ /*
+ * TX RX
+ * PA9 PA10
+ * PB6 PB7 *
+ */
+
+#if SERIAL_1_PA9_PA10
+ stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOAEN);
+
+ stm_afr_set(&stm_gpioa, 9, STM_AFR_AF7);
+ stm_afr_set(&stm_gpioa, 10, STM_AFR_AF7);
+#else
+#if SERIAL_1_PB6_PB7
+ stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOBEN);
+
+ stm_afr_set(&stm_gpiob, 6, STM_AFR_AF7);
+ stm_afr_set(&stm_gpiob, 7, STM_AFR_AF7);
+#else
+#error "No SERIAL_1 port configuration specified"
+#endif
+#endif
+ /* Enable USART */
+ stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_USART1EN);
+
+ ao_stm_usart1.reg = &stm_usart1;
+ ao_usart_init(&ao_stm_usart1, 0);
+
+ stm_nvic_set_enable(STM_ISR_USART1_POS);
+ stm_nvic_set_priority(STM_ISR_USART1_POS, AO_STM_NVIC_MED_PRIORITY);
+#if USE_SERIAL_1_STDIN && !DELAY_SERIAL_1_STDIN
+ ao_add_stdio(_ao_serial1_pollchar,
+ ao_serial1_putchar,
+ NULL);
+#endif
+#endif
+
+#if HAS_SERIAL_2
+ /*
+ * TX RX
+ * PA2 PA3
+ * PD5 PD6
+ */
+
+#if SERIAL_2_PA2_PA3
+ stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOAEN);
+
+ stm_afr_set(&stm_gpioa, 2, STM_AFR_AF7);
+ stm_afr_set(&stm_gpioa, 3, STM_AFR_AF7);
+# if USE_SERIAL_2_FLOW
+# if USE_SERIAL_2_SW_FLOW
+ ao_serial_set_sw_rts_cts(&ao_stm_usart2,
+ ao_serial2_cts,
+ SERIAL_2_PORT_RTS,
+ SERIAL_2_PIN_RTS,
+ SERIAL_2_PORT_CTS,
+ SERIAL_2_PIN_CTS);
+# else
+ stm_afr_set(&stm_gpioa, 0, STM_AFR_AF7);
+ stm_afr_set(&stm_gpioa, 1, STM_AFR_AF7);
+# endif
+# endif
+#else
+#if SERIAL_2_PD5_PD6
+ stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIODEN);
+
+ stm_afr_set(&stm_gpiod, 5, STM_AFR_AF7);
+ stm_afr_set(&stm_gpiod, 6, STM_AFR_AF7);
+#if USE_SERIAL_2_FLOW
+#error "Don't know how to set flowcontrol for serial 2 on PD"
+#endif
+#else
+#error "No SERIAL_2 port configuration specified"
+#endif
+#endif
+ /* Enable USART */
+ stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_USART2EN);
+
+ ao_stm_usart2.reg = &stm_usart2;
+ ao_usart_init(&ao_stm_usart2, USE_SERIAL_2_FLOW && !USE_SERIAL_2_SW_FLOW);
+
+ stm_nvic_set_enable(STM_ISR_USART2_POS);
+ stm_nvic_set_priority(STM_ISR_USART2_POS, AO_STM_NVIC_MED_PRIORITY);
+#if USE_SERIAL_2_STDIN && !DELAY_SERIAL_2_STDIN
+ ao_add_stdio(_ao_serial2_pollchar,
+ ao_serial2_putchar,
+ NULL);
+#endif
+#endif
+
+#if HAS_SERIAL_3
+ /*
+ * TX RX
+ * PB10 PB11
+ * PC10 PC11
+ * PD8 PD9
+ */
+#if SERIAL_3_PB10_PB11
+ stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOBEN);
+
+ stm_afr_set(&stm_gpiob, 10, STM_AFR_AF7);
+ stm_afr_set(&stm_gpiob, 11, STM_AFR_AF7);
+#else
+#if SERIAL_3_PC10_PC11
+ stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOCEN);
+
+ stm_afr_set(&stm_gpioc, 10, STM_AFR_AF7);
+ stm_afr_set(&stm_gpioc, 11, STM_AFR_AF7);
+#else
+#if SERIAL_3_PD8_PD9
+ stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIODEN);
+
+ stm_afr_set(&stm_gpiod, 8, STM_AFR_AF7);
+ stm_afr_set(&stm_gpiod, 9, STM_AFR_AF7);
+#else
+#error "No SERIAL_3 port configuration specified"
+#endif
+#endif
+#endif
+ /* Enable USART */
+ stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_USART3EN);
+
+ ao_stm_usart3.reg = &stm_usart3;
+ ao_usart_init(&ao_stm_usart3, 0);
+
+ stm_nvic_set_enable(STM_ISR_USART3_POS);
+ stm_nvic_set_priority(STM_ISR_USART3_POS, AO_STM_NVIC_MED_PRIORITY);
+#if USE_SERIAL_3_STDIN && !DELAY_SERIAL_3_STDIN
+ ao_add_stdio(_ao_serial3_pollchar,
+ ao_serial3_putchar,
+ NULL);
+#endif
+#endif
+}
diff --git a/src/stm32f4/ao_timer.c b/src/stm32f4/ao_timer.c
new file mode 100644
index 00000000..d6ef9bc3
--- /dev/null
+++ b/src/stm32f4/ao_timer.c
@@ -0,0 +1,284 @@
+/*
+ * Copyright © 2018 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"
+#include <ao_task.h>
+
+#ifndef HAS_TICK
+#define HAS_TICK 1
+#endif
+
+#if HAS_TICK || defined(AO_TIMER_HOOK)
+
+#if HAS_TICK
+volatile AO_TICK_TYPE ao_tick_count;
+
+AO_TICK_TYPE
+ao_time(void)
+{
+ return ao_tick_count;
+}
+#endif
+
+#if AO_DATA_ALL
+volatile uint8_t ao_data_interval = 1;
+volatile uint8_t ao_data_count;
+#endif
+
+void stm_systick_isr(void)
+{
+ ao_validate_cur_stack();
+ if (stm_systick.csr & (1 << STM_SYSTICK_CSR_COUNTFLAG)) {
+#if HAS_TICK
+ ++ao_tick_count;
+#endif
+#if HAS_TASK_QUEUE
+ if (ao_task_alarm_tick && (int16_t) (ao_tick_count - ao_task_alarm_tick) >= 0)
+ ao_task_check_alarm((uint16_t) ao_tick_count);
+#endif
+#if AO_DATA_ALL
+ if (++ao_data_count == ao_data_interval) {
+ ao_data_count = 0;
+#if HAS_FAKE_FLIGHT
+ if (ao_fake_flight_active)
+ ao_fake_flight_poll();
+ else
+#endif
+ ao_adc_poll();
+#if (AO_DATA_ALL & ~(AO_DATA_ADC))
+ ao_wakeup((void *) &ao_data_count);
+#endif
+ }
+#endif
+#ifdef AO_TIMER_HOOK
+ AO_TIMER_HOOK;
+#endif
+ }
+}
+
+#if HAS_ADC
+void
+ao_timer_set_adc_interval(uint8_t interval)
+{
+ ao_arch_critical(
+ ao_data_interval = interval;
+ ao_data_count = 0;
+ );
+}
+#endif
+
+#define SYSTICK_RELOAD ((AO_SYSTICK / 8) / 100 - 1)
+
+void
+ao_timer_init(void)
+{
+ stm_systick.rvr = SYSTICK_RELOAD;
+ stm_systick.cvr = 0;
+ stm_systick.csr = ((1 << STM_SYSTICK_CSR_ENABLE) |
+ (1 << STM_SYSTICK_CSR_TICKINT) |
+ (STM_SYSTICK_CSR_CLKSOURCE_AHB_8 << STM_SYSTICK_CSR_CLKSOURCE));
+ stm_scb.shpr3 |= AO_STM_NVIC_CLOCK_PRIORITY << 24;
+}
+
+#endif
+
+void
+ao_clock_init(void)
+{
+ uint32_t cfgr;
+ uint32_t pllcfgr;
+
+ /* Switch to HSI while messing about */
+ stm_rcc.cr |= (1 << STM_RCC_CR_HSION);
+ while (!(stm_rcc.cr & (1 << STM_RCC_CR_HSIRDY)))
+ ao_arch_nop();
+
+ stm_rcc.cfgr = (stm_rcc.cfgr & ~(STM_RCC_CFGR_SW_MASK << STM_RCC_CFGR_SW)) |
+ (STM_RCC_CFGR_SW_HSI << STM_RCC_CFGR_SW);
+
+ /* wait for system to switch to HSI */
+ while ((stm_rcc.cfgr & (STM_RCC_CFGR_SWS_MASK << STM_RCC_CFGR_SWS)) !=
+ (STM_RCC_CFGR_SWS_HSI << STM_RCC_CFGR_SWS))
+ ao_arch_nop();
+
+ /* reset everything but the HSI selection and status */
+ stm_rcc.cfgr &= (uint32_t)0x0000000f;
+
+ /* reset everything but HSI */
+ stm_rcc.cr &= 0x0000ffff;
+
+ /* Disable and clear all interrupts */
+ stm_rcc.cir = 0xffff0000;
+
+#if AO_HSE
+#if AO_HSE_BYPASS
+ stm_rcc.cr |= (1 << STM_RCC_CR_HSEBYP);
+#else
+ stm_rcc.cr &= ~(1 << STM_RCC_CR_HSEBYP);
+#endif
+ /* Enable HSE clock */
+ stm_rcc.cr |= (1 << STM_RCC_CR_HSEON);
+ while (!(stm_rcc.cr & (1 << STM_RCC_CR_HSERDY)))
+ asm("nop");
+
+#endif
+
+ /* Set flash latency to tolerate SYSCLK */
+
+#define FLASH_LATENCY ((AO_SYSCLK - 1) / 25000000)
+
+ /* Enable icache, dcache and prefetch. Set latency */
+ stm_flash.acr = ((1 << STM_FLASH_ACR_DCEN) |
+ (1 << STM_FLASH_ACR_ICEN) |
+ (1 << STM_FLASH_ACR_PRFTEN) |
+ (FLASH_LATENCY << STM_FLASH_ACR_LATENCY));
+
+ /* Enable power interface clock */
+ stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_PWREN);
+
+#if AO_SYSCLK <= 64000000
+#define VOS_SCALE_MODE STM_PWR_CR_VOS_SCALE_MODE_1
+#elif AO_SYSCLK <= 84000000
+#define VOS_SCALE_MODE STM_PWR_CR_VOS_SCALE_MODE_2
+#else
+#define VOS_SCALE_MODE STM_PWR_CR_VOS_SCALE_MODE_1
+#endif
+
+ /* Set voltage scale mode */
+ stm_pwr.cr = ((stm_pwr.cr & ~(STM_PWR_CR_VOS_SCALE_MODE_MASK)) |
+ (VOS_SCALE_MODE << STM_PWR_CR_VOS));
+
+ /* HCLK */
+ cfgr = stm_rcc.cfgr;
+ cfgr &= ~(STM_RCC_CFGR_HPRE_MASK << STM_RCC_CFGR_HPRE);
+ cfgr |= (AO_RCC_CFGR_HPRE_DIV << STM_RCC_CFGR_HPRE);
+ stm_rcc.cfgr = cfgr;
+
+ /* APB1 Prescaler = AO_APB1_PRESCALER */
+ cfgr = stm_rcc.cfgr;
+ cfgr &= ~(STM_RCC_CFGR_PPRE1_MASK << STM_RCC_CFGR_PPRE1);
+ cfgr |= (AO_RCC_CFGR_PPRE1_DIV << STM_RCC_CFGR_PPRE1);
+ stm_rcc.cfgr = cfgr;
+
+ /* APB2 Prescaler = AO_APB2_PRESCALER */
+ cfgr = stm_rcc.cfgr;
+ cfgr &= ~(STM_RCC_CFGR_PPRE2_MASK << STM_RCC_CFGR_PPRE2);
+ cfgr |= (AO_RCC_CFGR_PPRE2_DIV << STM_RCC_CFGR_PPRE2);
+ stm_rcc.cfgr = cfgr;
+
+ /* Clock configuration register DCKCFGR2; mostly make sure USB
+ * gets clocked from PLL_Q
+ */
+ stm_rcc.dckcfgr2 = ((STM_RCC_DCKCFGR2_LPTIMER1SEL_APB << STM_RCC_DCKCFGR2_LPTIMER1SEL) |
+ (STM_RCC_DCKCFGR2_SDIOSEL_CK_48MHZ << STM_RCC_DCKCFGR2_SDIOSEL) |
+ (STM_RCC_DCKCFGR2_CK48MSEL_PLL_Q << STM_RCC_DCKCFGR2_CK48MSEL) |
+ (STM_RCC_DCKCFGR2_I2CFMP1SEL_APB << STM_RCC_DCKCFGR2_I2CFMP1SEL));
+
+ /* Disable the PLL */
+ stm_rcc.cr &= ~(1 << STM_RCC_CR_PLLON);
+ while (stm_rcc.cr & (1 << STM_RCC_CR_PLLRDY))
+ asm("nop");
+
+ /* PLL1VCO */
+ pllcfgr = stm_rcc.pllcfgr;
+ pllcfgr &= ~(STM_RCC_PLLCFGR_PLLM_MASK << STM_RCC_PLLCFGR_PLLM);
+ pllcfgr &= ~(STM_RCC_PLLCFGR_PLLN_MASK << STM_RCC_PLLCFGR_PLLN);
+ pllcfgr &= ~(STM_RCC_PLLCFGR_PLLP_MASK << STM_RCC_PLLCFGR_PLLP);
+ pllcfgr &= ~(STM_RCC_PLLCFGR_PLLQ_MASK << STM_RCC_PLLCFGR_PLLQ);
+ pllcfgr &= ~(STM_RCC_PLLCFGR_PLLR_MASK << STM_RCC_PLLCFGR_PLLR);
+
+ pllcfgr |= (AO_PLL_M << STM_RCC_PLLCFGR_PLLM);
+ pllcfgr |= (AO_PLL1_N << STM_RCC_PLLCFGR_PLLN);
+#if AO_PLL1_P == 2
+#define AO_RCC_PLLCFGR_PLLP STM_RCC_PLLCFGR_PLLP_DIV_2
+#endif
+#if AO_PLL1_P == 4
+#define AO_RCC_PLLCFGR_PLLP STM_RCC_PLLCFGR_PLLP_DIV_4
+#endif
+#if AO_PLL1_P == 6
+#define AO_RCC_PLLCFGR_PLLP STM_RCC_PLLCFGR_PLLP_DIV_6
+#endif
+#if AO_PLL1_P == 8
+#define AO_RCC_PLLCFGR_PLLP STM_RCC_PLLCFGR_PLLP_DIV_8
+#endif
+ pllcfgr |= (AO_RCC_PLLCFGR_PLLP << STM_RCC_PLLCFGR_PLLP);
+ pllcfgr |= (AO_PLL1_Q << STM_RCC_PLLCFGR_PLLQ);
+ pllcfgr |= (AO_PLL1_R << STM_RCC_PLLCFGR_PLLR);
+ /* PLL source */
+ pllcfgr &= ~(1 << STM_RCC_PLLCFGR_PLLSRC);
+#if AO_HSI
+ pllcfgr |= (STM_RCC_PLLCFGR_PLLSRC_HSI << STM_RCC_PLLCFGR_PLLSRC);
+#endif
+#if AO_HSE
+ pllcfgr |= (STM_RCC_PLLCFGR_PLLSRC_HSE << STM_RCC_PLLCFGR_PLLSRC);
+#endif
+ stm_rcc.pllcfgr = pllcfgr;
+
+ /* Enable the PLL and wait for it */
+ stm_rcc.cr |= (1 << STM_RCC_CR_PLLON);
+ while (!(stm_rcc.cr & (1 << STM_RCC_CR_PLLRDY)))
+ asm("nop");
+
+ /* Switch to the PLL for the system clock */
+
+ cfgr = stm_rcc.cfgr;
+ cfgr &= ~(STM_RCC_CFGR_SW_MASK << STM_RCC_CFGR_SW);
+ cfgr |= (STM_RCC_CFGR_SW_PLL << STM_RCC_CFGR_SW);
+ stm_rcc.cfgr = cfgr;
+ for (;;) {
+ uint32_t c, part, mask, val;
+
+ c = stm_rcc.cfgr;
+ mask = (STM_RCC_CFGR_SWS_MASK << STM_RCC_CFGR_SWS);
+ val = (STM_RCC_CFGR_SWS_PLL << STM_RCC_CFGR_SWS);
+ part = c & mask;
+ if (part == val)
+ break;
+ }
+
+#if AO_HSE
+ /* Disable HSI clock */
+ stm_rcc.cr &= ~(1 << STM_RCC_CR_HSION);
+#endif
+
+ /* Clear reset flags */
+ stm_rcc.csr |= (1 << STM_RCC_CSR_RMVF);
+
+#if DEBUG_THE_CLOCK
+ /* Output PLL clock on PA8 and SYCLK on PC9 for measurments */
+
+ stm_rcc.ahb1enr |= ((1 << STM_RCC_AHB1ENR_IOPAEN) |
+ (1 << STM_RCC_AHB1ENR_IOPCEN));
+
+ stm_afr_set(&stm_gpioa, 8, STM_AFR_AF0);
+ stm_moder_set(&stm_gpioa, 8, STM_MODER_ALTERNATE);
+ stm_ospeedr_set(&stm_gpioa, 8, STM_OSPEEDR_HIGH);
+
+ stm_afr_set(&stm_gpioc, 9, STM_AFR_AF0);
+ stm_moder_set(&stm_gpioc, 9, STM_MODER_ALTERNATE);
+ stm_ospeedr_set(&stm_gpioc, 9, STM_OSPEEDR_HIGH);
+
+ cfgr = stm_rcc.cfgr;
+ cfgr &= 0x001fffff;
+ cfgr |= ((0 << STM_RCC_CFGR_MCO2) |
+ (6 << STM_RCC_CFGR_MCO2PRE) |
+ (6 << STM_RCC_CFGR_MCO1PRE) |
+ (2 << STM_RCC_CFGR_MCO1));
+ stm_rcc.cfgr = cfgr;
+#endif
+}
diff --git a/src/stm32f4/ao_usart_stm32f4.c b/src/stm32f4/ao_usart_stm32f4.c
new file mode 100644
index 00000000..28331b1e
--- /dev/null
+++ b/src/stm32f4/ao_usart_stm32f4.c
@@ -0,0 +1,350 @@
+/*
+ * Copyright © 2018 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>
+#include <ao_exti.h>
+
+/* ao_serial_stm.c */
+struct ao_stm_usart {
+ struct ao_fifo rx_fifo;
+ struct ao_fifo tx_fifo;
+ struct stm_usart *reg;
+ uint32_t clk;
+ uint8_t tx_running;
+ uint8_t draining;
+#if HAS_SERIAL_SW_FLOW
+ /* RTS - 0 if we have FIFO space, 1 if not
+ * CTS - 0 if we can send, 0 if not
+ */
+ struct stm_gpio *gpio_rts;
+ struct stm_gpio *gpio_cts;
+ uint8_t pin_rts;
+ uint8_t pin_cts;
+ uint8_t rts;
+#endif
+};
+
+static int
+_ao_usart_tx_start(struct ao_stm_usart *usart)
+{
+ if (!ao_fifo_empty(usart->tx_fifo)) {
+#if HAS_SERIAL_SW_FLOW
+ if (usart->gpio_cts && ao_gpio_get(usart->gpio_cts, usart->pin_cts) == 1) {
+ ao_exti_enable(usart->gpio_cts, usart->pin_cts);
+ return 0;
+ }
+#endif
+ if (usart->reg->sr & (1 << STM_USART_SR_TXE))
+ {
+ usart->tx_running = 1;
+ usart->reg->cr1 |= (1 << STM_USART_CR1_TXEIE) | (1 << STM_USART_CR1_TCIE);
+ ao_fifo_remove(usart->tx_fifo, usart->reg->dr);
+ ao_wakeup(&usart->tx_fifo);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+#if HAS_SERIAL_SW_FLOW
+static void
+_ao_usart_cts(struct ao_stm_usart *usart)
+{
+ if (_ao_usart_tx_start(usart))
+ ao_exti_disable(usart->gpio_cts, usart->pin_cts);
+}
+#endif
+
+static void
+_ao_usart_rx(struct ao_stm_usart *usart, int is_stdin)
+{
+ if (usart->reg->sr & (1 << STM_USART_SR_RXNE)) {
+ if (!ao_fifo_full(usart->rx_fifo)) {
+ ao_fifo_insert(usart->rx_fifo, usart->reg->dr);
+ ao_wakeup(&usart->rx_fifo);
+ if (is_stdin)
+ ao_wakeup(&ao_stdin_ready);
+#if HAS_SERIAL_SW_FLOW
+ /* If the fifo is nearly full, turn off RTS and wait
+ * for it to drain a bunch
+ */
+ if (usart->gpio_rts && ao_fifo_mostly(usart->rx_fifo)) {
+ ao_gpio_set(usart->gpio_rts, usart->pin_rts, 1);
+ usart->rts = 0;
+ }
+#endif
+ } else {
+ usart->reg->cr1 &= ~(1 << STM_USART_CR1_RXNEIE);
+ }
+ }
+}
+
+static void
+ao_usart_isr(struct ao_stm_usart *usart, int is_stdin)
+{
+ _ao_usart_rx(usart, is_stdin);
+
+ if (!_ao_usart_tx_start(usart))
+ usart->reg->cr1 &= ~(1<< STM_USART_CR1_TXEIE);
+
+ if (usart->reg->sr & (1 << STM_USART_SR_TC)) {
+ usart->tx_running = 0;
+ usart->reg->cr1 &= ~(1 << STM_USART_CR1_TCIE);
+ if (usart->draining) {
+ usart->draining = 0;
+ ao_wakeup(&usart->tx_fifo);
+ }
+ }
+}
+
+static int
+_ao_usart_pollchar(struct ao_stm_usart *usart)
+{
+ int c;
+
+ if (ao_fifo_empty(usart->rx_fifo))
+ c = AO_READ_AGAIN;
+ else {
+ uint8_t u;
+ ao_fifo_remove(usart->rx_fifo,u);
+ if ((usart->reg->cr1 & (1 << STM_USART_CR1_RXNEIE)) == 0) {
+ if (ao_fifo_barely(usart->rx_fifo))
+ usart->reg->cr1 |= (1 << STM_USART_CR1_RXNEIE);
+ }
+#if HAS_SERIAL_SW_FLOW
+ /* If we've cleared RTS, check if there's space now and turn it back on */
+ if (usart->gpio_rts && usart->rts == 0 && ao_fifo_barely(usart->rx_fifo)) {
+ ao_gpio_set(usart->gpio_rts, usart->pin_rts, 0);
+ usart->rts = 1;
+ }
+#endif
+ c = u;
+ }
+ return c;
+}
+
+static char
+ao_usart_getchar(struct ao_stm_usart *usart)
+{
+ int c;
+ ao_arch_block_interrupts();
+ while ((c = _ao_usart_pollchar(usart)) == AO_READ_AGAIN)
+ ao_sleep(&usart->rx_fifo);
+ ao_arch_release_interrupts();
+ return (char) c;
+}
+
+static inline uint8_t
+_ao_usart_sleep_for(struct ao_stm_usart *usart, uint16_t timeout)
+{
+ return ao_sleep_for(&usart->rx_fifo, timeout);
+}
+
+static void
+ao_usart_putchar(struct ao_stm_usart *usart, char c)
+{
+ ao_arch_block_interrupts();
+ while (ao_fifo_full(usart->tx_fifo))
+ ao_sleep(&usart->tx_fifo);
+ ao_fifo_insert(usart->tx_fifo, c);
+ _ao_usart_tx_start(usart);
+ ao_arch_release_interrupts();
+}
+
+static void
+ao_usart_drain(struct ao_stm_usart *usart)
+{
+ ao_arch_block_interrupts();
+ while (!ao_fifo_empty(usart->tx_fifo) || usart->tx_running) {
+ usart->draining = 1;
+ ao_sleep(&usart->tx_fifo);
+ }
+ ao_arch_release_interrupts();
+}
+
+static void
+ao_usart_set_speed(struct ao_stm_usart *usart, uint32_t speed)
+{
+ if (speed > 115200)
+ return;
+ usart->reg->brr = usart->clk / speed;
+}
+
+static void
+_ao_usart_init(struct ao_stm_usart *usart, int hw_flow)
+{
+ usart->reg->cr1 = ((0 << STM_USART_CR1_OVER8) |
+ (1 << STM_USART_CR1_UE) |
+ (0 << STM_USART_CR1_M) |
+ (0 << STM_USART_CR1_WAKE) |
+ (0 << STM_USART_CR1_PCE) |
+ (0 << STM_USART_CR1_PS) |
+ (0 << STM_USART_CR1_PEIE) |
+ (0 << STM_USART_CR1_TXEIE) |
+ (0 << STM_USART_CR1_TCIE) |
+ (1 << STM_USART_CR1_RXNEIE) |
+ (0 << STM_USART_CR1_IDLEIE) |
+ (1 << STM_USART_CR1_TE) |
+ (1 << STM_USART_CR1_RE) |
+ (0 << STM_USART_CR1_RWU) |
+ (0 << STM_USART_CR1_SBK));
+
+ usart->reg->cr2 = ((0 << STM_USART_CR2_LINEN) |
+ (STM_USART_CR2_STOP_1 << STM_USART_CR2_STOP) |
+ (0 << STM_USART_CR2_CLKEN) |
+ (0 << STM_USART_CR2_CPOL) |
+ (0 << STM_USART_CR2_CPHA) |
+ (0 << STM_USART_CR2_LBCL) |
+ (0 << STM_USART_CR2_LBDIE) |
+ (0 << STM_USART_CR2_LBDL) |
+ (0 << STM_USART_CR2_ADD));
+
+ usart->reg->cr3 = ((0 << STM_USART_CR3_ONEBIT) |
+ (0 << STM_USART_CR3_CTSIE) |
+ (0 << STM_USART_CR3_CTSE) |
+ (0 << STM_USART_CR3_RTSE) |
+ (0 << STM_USART_CR3_DMAT) |
+ (0 << STM_USART_CR3_DMAR) |
+ (0 << STM_USART_CR3_SCEN) |
+ (0 << STM_USART_CR3_NACK) |
+ (0 << STM_USART_CR3_HDSEL) |
+ (0 << STM_USART_CR3_IRLP) |
+ (0 << STM_USART_CR3_IREN) |
+ (0 << STM_USART_CR3_EIE));
+
+ if (hw_flow)
+ usart->reg->cr3 |= ((1 << STM_USART_CR3_CTSE) |
+ (1 << STM_USART_CR3_RTSE));
+
+ /* Pick a 9600 baud rate */
+ ao_usart_set_speed(usart, 9600);
+}
+
+#if HAS_SERIAL_HW_FLOW
+static void
+ao_usart_set_flow(struct ao_stm_usart *usart)
+{
+}
+#endif
+
+#if HAS_SERIAL_6
+
+struct ao_stm_usart ao_stm_usart6;
+
+void stm_usart6_isr(void) { ao_usart_isr(&ao_stm_usart6, USE_SERIAL_6_STDIN); }
+
+char
+ao_serial6_getchar(void)
+{
+ return ao_usart_getchar(&ao_stm_usart6);
+}
+
+void
+ao_serial6_putchar(char c)
+{
+ ao_usart_putchar(&ao_stm_usart6, c);
+}
+
+int
+_ao_serial6_pollchar(void)
+{
+ return _ao_usart_pollchar(&ao_stm_usart6);
+}
+
+uint8_t
+_ao_serial6_sleep_for(uint16_t timeout)
+{
+ return _ao_usart_sleep_for(&ao_stm_usart6, timeout);
+}
+
+void
+ao_serial6_set_speed(uint32_t speed)
+{
+ ao_usart_drain(&ao_stm_usart6);
+ ao_usart_set_speed(&ao_stm_usart6, speed);
+}
+
+void
+ao_serial6_drain(void)
+{
+ ao_usart_drain(&ao_stm_usart6);
+}
+#endif /* HAS_SERIAL_6 */
+
+#if HAS_SERIAL_SW_FLOW
+static void
+ao_serial_set_sw_rts_cts(struct ao_stm_usart *usart,
+ void (*isr)(void),
+ struct stm_gpio *port_rts,
+ int pin_rts,
+ struct stm_gpio *port_cts,
+ int pin_cts)
+{
+ /* Pull RTS low to note that there's space in the FIFO */
+ ao_enable_output(port_rts, pin_rts, 0);
+ usart->gpio_rts = port_rts;
+ usart->pin_rts = pin_rts;
+ usart->rts = 1;
+
+ ao_exti_setup(port_cts, pin_cts, AO_EXTI_MODE_FALLING|AO_EXTI_PRIORITY_MED, isr);
+ usart->gpio_cts = port_cts;
+ usart->pin_cts = pin_cts;
+}
+#endif
+
+void
+ao_usart_init(void)
+{
+#if HAS_SERIAL_6
+ stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_USART6EN);
+
+ ao_stm_usart6.reg = &stm_usart6;
+ ao_stm_usart6.clk = AO_P2CLK;
+
+ ao_enable_port(SERIAL_6_RX_PORT);
+ ao_enable_port(SERIAL_6_TX_PORT);
+
+ stm_afr_set(SERIAL_6_RX_PORT, SERIAL_6_RX_PIN, STM_AFR_AF8);
+ stm_afr_set(SERIAL_6_TX_PORT, SERIAL_6_TX_PIN, STM_AFR_AF8);
+
+ stm_nvic_set_enable(STM_ISR_USART6_POS);
+ stm_nvic_set_priority(STM_ISR_USART6_POS, AO_STM_NVIC_MED_PRIORITY);
+
+ _ao_usart_init(&ao_stm_usart6, USE_SERIAL_6_FLOW && !USE_SERIAL_6_SW_FLOW);
+
+# if USE_SERIAL_6_FLOW
+# if USE_SERIAL_6_SW_FLOW
+ ao_serial_set_sw_rts_cts(&ao_stm_usart6,
+ ao_serial6_cts,
+ SERIAL_6_PORT_RTS,
+ SERIAL_6_PIN_RTS,
+ SERIAL_6_PORT_CTS,
+ SERIAL_6_PIN_CTS);
+# else
+ stm_afr_set(SERIAL_6_PORT_RTS, SERIAL_6_PIN_RTS, STM_AFR_AF8);
+ stm_afr_set(SERIAL_6_PORT_CTS, SERIAL_6_PIN_CTS, STM_AFR_AF8);
+# endif
+#endif
+
+#if USE_SERIAL_6_STDIN && !DELAY_SERIAL_6_STDIN
+ ao_add_stdio(_ao_serial6_pollchar,
+ ao_serial6_putchar,
+ NULL);
+#endif
+#endif
+}
diff --git a/src/stm32f4/ao_usb_gen.c b/src/stm32f4/ao_usb_gen.c
new file mode 100644
index 00000000..760afad9
--- /dev/null
+++ b/src/stm32f4/ao_usb_gen.c
@@ -0,0 +1,712 @@
+/*
+ * Copyright © 2018 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_usb_gen.h"
+
+static uint8_t ao_usb_ep0_state;
+
+/* Pending EP0 IN data */
+static const uint8_t *ao_usb_ep0_in_data; /* Remaining data */
+static uint8_t ao_usb_ep0_in_len; /* Remaining amount */
+
+/* Temp buffer for smaller EP0 in data */
+static uint8_t ao_usb_ep0_in_buf[2];
+
+/* Pending EP0 OUT data */
+static uint8_t *ao_usb_ep0_out_data;
+static uint8_t ao_usb_ep0_out_len;
+
+/* System ram shadow of USB buffer; writing individual bytes is
+ * too much of a pain (sigh) */
+static uint8_t ao_usb_tx_buffer[AO_USB_IN_SIZE];
+static uint8_t ao_usb_tx_count;
+
+static uint8_t ao_usb_rx_buffer[AO_USB_OUT_SIZE];
+static uint8_t ao_usb_rx_count, ao_usb_rx_pos;
+
+/*
+ * End point register indices
+ */
+
+#define AO_USB_CONTROL_EPR 0
+#define AO_USB_INT_EPR 1
+#define AO_USB_OUT_EPR 2
+#define AO_USB_IN_EPR 3
+
+/* Marks when we don't need to send an IN packet.
+ * This happens only when the last IN packet is not full,
+ * otherwise the host will expect to keep seeing packets.
+ * Send a zero-length packet as required
+ */
+static uint8_t ao_usb_in_flushed;
+
+/* Marks when we have delivered an IN packet to the hardware
+ * and it has not been received yet. ao_sleep on this address
+ * to wait for it to be delivered.
+ */
+static uint8_t ao_usb_in_pending;
+
+/* Marks when an OUT packet has been received by the hardware
+ * but not pulled to the shadow buffer.
+ */
+static uint8_t ao_usb_out_avail;
+uint8_t ao_usb_running;
+static uint8_t ao_usb_configuration;
+
+static uint8_t ao_usb_address;
+static uint8_t ao_usb_address_pending;
+
+/*
+ * Set current device address and mark the
+ * interface as active
+ */
+static void
+ao_usb_set_address(uint8_t address)
+{
+ ao_usb_dev_set_address(address);
+ ao_usb_address_pending = 0;
+}
+
+#define TX_DBG 0
+#define RX_DBG 0
+
+#if TX_DBG
+#define _tx_dbg0(msg) _dbg(__LINE__,msg,0)
+#define _tx_dbg1(msg,value) _dbg(__LINE__,msg,value)
+#else
+#define _tx_dbg0(msg)
+#define _tx_dbg1(msg,value)
+#endif
+
+#if RX_DBG
+#define _rx_dbg0(msg) _dbg(__LINE__,msg,0)
+#define _rx_dbg1(msg,value) _dbg(__LINE__,msg,value)
+#else
+#define _rx_dbg0(msg)
+#define _rx_dbg1(msg,value)
+#endif
+
+#if TX_DBG || RX_DBG
+static void _dbg(int line, char *msg, uint32_t value);
+#endif
+
+/*
+ * Set just endpoint 0, for use during startup
+ */
+
+static void
+ao_usb_set_ep0(void)
+{
+ ao_usb_dev_ep0_init();
+
+ ao_usb_set_address(0);
+
+ ao_usb_running = 0;
+
+ /* Reset our internal state
+ */
+
+ ao_usb_ep0_state = AO_USB_EP0_IDLE;
+
+ ao_usb_ep0_in_data = NULL;
+ ao_usb_ep0_in_len = 0;
+
+ ao_usb_ep0_out_data = 0;
+ ao_usb_ep0_out_len = 0;
+}
+
+static void
+ao_usb_set_configuration(void)
+{
+#if 0
+ /* Set up the INT end point */
+ ao_usb_bdt[AO_USB_INT_EPR].single.addr_tx = ao_usb_sram_addr;
+ ao_usb_bdt[AO_USB_INT_EPR].single.count_tx = 0;
+ ao_usb_in_tx_buffer = ao_usb_packet_buffer_addr(ao_usb_sram_addr);
+ ao_usb_sram_addr += AO_USB_INT_SIZE;
+
+ ao_usb_init_ep(AO_USB_INT_EPR,
+ AO_USB_INT_EP);
+
+ /* Set up the OUT end point */
+ ao_usb_bdt[AO_USB_OUT_EPR].single.addr_rx = ao_usb_sram_addr;
+ ao_usb_bdt[AO_USB_OUT_EPR].single.count_rx = ((1 << STM_USB_BDT_COUNT_RX_BL_SIZE) |
+ (((AO_USB_OUT_SIZE / 32) - 1) << STM_USB_BDT_COUNT_RX_NUM_BLOCK));
+ ao_usb_out_rx_buffer = ao_usb_packet_buffer_addr(ao_usb_sram_addr);
+ ao_usb_sram_addr += AO_USB_OUT_SIZE;
+
+ ao_usb_init_ep(AO_USB_OUT_EPR,
+ AO_USB_OUT_EP,
+ STM_USB_EPR_EP_TYPE_BULK,
+ STM_USB_EPR_STAT_RX_VALID,
+ STM_USB_EPR_STAT_TX_DISABLED);
+
+ /* Set up the IN end point */
+ ao_usb_bdt[AO_USB_IN_EPR].single.addr_tx = ao_usb_sram_addr;
+ ao_usb_bdt[AO_USB_IN_EPR].single.count_tx = 0;
+ ao_usb_in_tx_buffer = ao_usb_packet_buffer_addr(ao_usb_sram_addr);
+ ao_usb_sram_addr += AO_USB_IN_SIZE;
+
+ ao_usb_init_ep(AO_USB_IN_EPR,
+ AO_USB_IN_EP,
+ STM_USB_EPR_EP_TYPE_BULK,
+ STM_USB_EPR_STAT_RX_DISABLED,
+ STM_USB_EPR_STAT_TX_NAK);
+#endif
+
+ ao_usb_in_flushed = 0;
+ ao_usb_in_pending = 0;
+ ao_wakeup(&ao_usb_in_pending);
+
+ ao_usb_out_avail = 0;
+ ao_usb_configuration = 0;
+
+ ao_usb_running = 1;
+ ao_wakeup(&ao_usb_running);
+}
+
+static uint16_t control_count;
+static uint16_t in_count;
+static uint16_t out_count;
+#if USB_DEBUG
+static uint16_t int_count;
+static uint16_t reset_count;
+#endif
+
+/* Send an IN data packet */
+static void
+ao_usb_ep0_flush(void)
+{
+ uint8_t this_len;
+
+ /* Check to see if the endpoint is still busy */
+ if (ao_usb_dev_ep0_in_busy()) {
+ return;
+ }
+
+ this_len = ao_usb_ep0_in_len;
+ if (this_len > AO_USB_CONTROL_SIZE)
+ this_len = AO_USB_CONTROL_SIZE;
+
+ if (this_len < AO_USB_CONTROL_SIZE)
+ ao_usb_ep0_state = AO_USB_EP0_IDLE;
+
+ ao_usb_ep0_in_len -= this_len;
+
+ ao_usb_dev_ep0_in(ao_usb_ep0_in_data, this_len);
+ ao_usb_ep0_in_data += this_len;
+}
+
+/* Read data from the ep0 OUT fifo */
+static void
+ao_usb_ep0_fill(void)
+{
+ uint16_t len;
+
+ len = ao_usb_dev_ep0_out(ao_usb_ep0_out_data, ao_usb_ep0_out_len);
+ ao_usb_ep0_out_len -= len;
+ ao_usb_ep0_out_data += len;
+}
+
+static void
+ao_usb_ep0_in_reset(void)
+{
+ ao_usb_ep0_in_data = ao_usb_ep0_in_buf;
+ ao_usb_ep0_in_len = 0;
+}
+
+static void
+ao_usb_ep0_in_queue_byte(uint8_t a)
+{
+ if (ao_usb_ep0_in_len < sizeof (ao_usb_ep0_in_buf))
+ ao_usb_ep0_in_buf[ao_usb_ep0_in_len++] = a;
+}
+
+static void
+ao_usb_ep0_in_set(const uint8_t *data, uint8_t len)
+{
+ ao_usb_ep0_in_data = data;
+ ao_usb_ep0_in_len = len;
+}
+
+static void
+ao_usb_ep0_out_set(uint8_t *data, uint8_t len)
+{
+ ao_usb_ep0_out_data = data;
+ ao_usb_ep0_out_len = len;
+}
+
+static void
+ao_usb_ep0_in_start(uint16_t max)
+{
+ /* Don't send more than asked for */
+ if (ao_usb_ep0_in_len > max)
+ ao_usb_ep0_in_len = max;
+
+ ao_usb_dev_ep0_in(ao_usb_ep0_in_data, ao_usb_ep0_in_len);
+}
+
+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, uint16_t length)
+{
+ const uint8_t *descriptor;
+ uint8_t type = value >> 8;
+ uint8_t index = value;
+
+ descriptor = ao_usb_descriptors;
+ while (descriptor[0] != 0) {
+ if (descriptor[1] == type && index-- == 0) {
+ uint8_t len;
+ if (type == AO_USB_DESC_CONFIGURATION)
+ len = descriptor[2];
+ else
+ len = descriptor[0];
+ if (len > length)
+ len = length;
+ ao_usb_ep0_in_set(descriptor, len);
+ break;
+ }
+ descriptor += descriptor[0];
+ }
+}
+
+static void
+ao_usb_ep0_setup(void)
+{
+ uint16_t setup_len;
+
+ /* Pull the setup packet out of the fifo */
+ setup_len = ao_usb_dev_ep0_out(&ao_usb_setup, 8);
+ if (setup_len != 8) {
+ return;
+ }
+
+ if ((ao_usb_setup.dir_type_recip & AO_USB_DIR_IN) || ao_usb_setup.length == 0)
+ ao_usb_ep0_state = AO_USB_EP0_DATA_IN;
+ else
+ ao_usb_ep0_state = AO_USB_EP0_DATA_OUT;
+
+ ao_usb_ep0_in_reset();
+
+ 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_in_queue_byte(0);
+ ao_usb_ep0_in_queue_byte(0);
+ break;
+ case AO_USB_REQ_SET_ADDRESS:
+ ao_usb_address = ao_usb_setup.value;
+ ao_usb_address_pending = 1;
+ break;
+ case AO_USB_REQ_GET_DESCRIPTOR:
+ ao_usb_get_descriptor(ao_usb_setup.value, ao_usb_setup.length);
+ break;
+ case AO_USB_REQ_GET_CONFIGURATION:
+ ao_usb_ep0_in_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:
+ switch(ao_usb_setup.request) {
+ case AO_USB_REQ_GET_STATUS:
+ ao_usb_ep0_in_queue_byte(0);
+ ao_usb_ep0_in_queue_byte(0);
+ break;
+ case AO_USB_REQ_GET_INTERFACE:
+ ao_usb_ep0_in_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_in_queue_byte(0);
+ ao_usb_ep0_in_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_set((uint8_t *) &ao_usb_line_coding, 7);
+ break;
+ case AO_USB_GET_LINE_CODING:
+ ao_usb_ep0_in_set((const uint8_t *) &ao_usb_line_coding, 7);
+ break;
+ case AO_USB_SET_CONTROL_LINE_STATE:
+ break;
+ }
+ break;
+ }
+
+ /* If we're not waiting to receive data from the host,
+ * queue an IN response
+ */
+ if (ao_usb_ep0_state == AO_USB_EP0_DATA_IN)
+ ao_usb_ep0_in_start(ao_usb_setup.length);
+}
+
+static void
+ao_usb_ep0_handle(uint8_t receive)
+{
+ if (receive & AO_USB_EP0_GOT_RESET) {
+ ao_usb_set_ep0();
+ return;
+ }
+ if (receive & AO_USB_EP0_GOT_SETUP) {
+ ao_usb_ep0_setup();
+ }
+ if (receive & AO_USB_EP0_GOT_RX_DATA) {
+ if (ao_usb_ep0_state == AO_USB_EP0_DATA_OUT) {
+ ao_usb_ep0_fill();
+ if (ao_usb_ep0_out_len == 0) {
+ ao_usb_ep0_state = AO_USB_EP0_DATA_IN;
+ ao_usb_ep0_in_start(0);
+ }
+ }
+ }
+ if (receive & AO_USB_EP0_GOT_TX_ACK) {
+#if HAS_FLIGHT && AO_USB_FORCE_IDLE
+ ao_flight_force_idle = 1;
+#endif
+ /* Wait until the IN packet is received from addr 0
+ * before assigning our local address
+ */
+ if (ao_usb_address_pending)
+ ao_usb_set_address(ao_usb_address);
+ if (ao_usb_ep0_state == AO_USB_EP0_DATA_IN)
+ ao_usb_ep0_flush();
+ }
+}
+
+void
+ao_usb_ep0_interrupt(uint8_t mask)
+{
+ if (mask) {
+ ++control_count;
+ ao_usb_ep0_handle(mask);
+ }
+}
+
+void
+ao_usb_in_interrupt(uint32_t mask)
+{
+ if (mask & (1 << AO_USB_IN_EPR)) {
+ ++in_count;
+ _tx_dbg1("TX ISR", epr);
+ ao_usb_in_pending = 0;
+ ao_wakeup(&ao_usb_in_pending);
+ }
+}
+
+void
+ao_usb_out_interrupt(uint32_t mask)
+{
+ if (mask & (1 << AO_USB_OUT_EPR)) {
+ ++out_count;
+ _rx_dbg1("RX ISR", epr);
+ ao_usb_out_avail = 1;
+ _rx_dbg0("out avail set");
+ ao_wakeup(AO_USB_OUT_SLEEP_ADDR);
+ _rx_dbg0("stdin awoken");
+ }
+}
+
+void
+ao_usb_int_interrupt(uint32_t mask)
+{
+ (void) mask;
+}
+
+void
+stm_usb_fs_wkup(void)
+{
+ /* USB wakeup, just clear the bit for now */
+// stm_usb.istr &= ~(1 << STM_USB_ISTR_WKUP);
+}
+
+/* Queue the current IN buffer for transmission */
+static void
+_ao_usb_in_send(void)
+{
+ _tx_dbg0("in_send start");
+
+ while (ao_usb_in_pending)
+ ao_sleep(&ao_usb_in_pending);
+
+ ao_usb_in_pending = 1;
+ if (ao_usb_tx_count != AO_USB_IN_SIZE)
+ ao_usb_in_flushed = 1;
+
+ ao_usb_dev_ep_in(AO_USB_IN_EPR, ao_usb_tx_buffer, ao_usb_tx_count);
+ ao_usb_tx_count = 0;
+
+ _tx_dbg0("in_send end");
+}
+
+/* Wait for a free IN buffer. Interrupts are blocked */
+static void
+_ao_usb_in_wait(void)
+{
+ for (;;) {
+ /* Check if the current buffer is writable */
+ if (ao_usb_tx_count < AO_USB_IN_SIZE)
+ break;
+
+ _tx_dbg0("in_wait top");
+ /* Wait for an IN buffer to be ready */
+ while (ao_usb_in_pending)
+ ao_sleep(&ao_usb_in_pending);
+ _tx_dbg0("in_wait bottom");
+ }
+}
+
+void
+ao_usb_flush(void)
+{
+ if (!ao_usb_running)
+ return;
+
+ /* Anytime we've sent a character since
+ * the last time we flushed, we'll need
+ * to send a packet -- the only other time
+ * we would send a packet is when that
+ * packet was full, in which case we now
+ * want to send an empty packet
+ */
+ ao_arch_block_interrupts();
+ while (!ao_usb_in_flushed) {
+ _tx_dbg0("flush top");
+ _ao_usb_in_send();
+ _tx_dbg0("flush end");
+ }
+ ao_arch_release_interrupts();
+}
+
+void
+ao_usb_putchar(char c)
+{
+ if (!ao_usb_running)
+ return;
+
+ ao_arch_block_interrupts();
+ _ao_usb_in_wait();
+
+ ao_usb_in_flushed = 0;
+ ao_usb_tx_buffer[ao_usb_tx_count++] = (uint8_t) c;
+
+ /* Send the packet when full */
+ if (ao_usb_tx_count == AO_USB_IN_SIZE) {
+ _tx_dbg0("putchar full");
+ _ao_usb_in_send();
+ _tx_dbg0("putchar flushed");
+ }
+ ao_arch_release_interrupts();
+}
+
+static void
+_ao_usb_out_recv(void)
+{
+ _rx_dbg0("out_recv top");
+ ao_usb_out_avail = 0;
+
+ ao_usb_rx_count = ao_usb_dev_ep_out(AO_USB_OUT_EPR, ao_usb_rx_buffer, sizeof (ao_usb_rx_buffer));
+
+ _rx_dbg1("out_recv count", ao_usb_rx_count);
+
+ ao_usb_rx_pos = 0;
+}
+
+int
+_ao_usb_pollchar(void)
+{
+ uint8_t c;
+
+ if (!ao_usb_running)
+ return AO_READ_AGAIN;
+
+ for (;;) {
+ if (ao_usb_rx_pos != ao_usb_rx_count)
+ break;
+
+ _rx_dbg0("poll check");
+ /* Check to see if a packet has arrived */
+ if (!ao_usb_out_avail) {
+ _rx_dbg0("poll none");
+ return AO_READ_AGAIN;
+ }
+ _ao_usb_out_recv();
+ }
+
+ /* Pull a character out of the fifo */
+ c = ao_usb_rx_buffer[ao_usb_rx_pos++];
+ return c;
+}
+
+char
+ao_usb_getchar(void)
+{
+ int c;
+
+ ao_arch_block_interrupts();
+ while ((c = _ao_usb_pollchar()) == AO_READ_AGAIN)
+ ao_sleep(AO_USB_OUT_SLEEP_ADDR);
+ ao_arch_release_interrupts();
+ return c;
+}
+
+#ifndef HAS_USB_DISABLE
+#define HAS_USB_DISABLE 1
+#endif
+
+#if HAS_USB_DISABLE
+void
+ao_usb_disable(void)
+{
+ ao_usb_dev_disable();
+}
+#endif
+
+void
+ao_usb_enable(void)
+{
+ ao_usb_dev_enable();
+
+ ao_usb_configuration = 0;
+}
+
+#if USB_ECHO
+struct ao_task ao_usb_echo_task;
+
+static void
+ao_usb_echo(void)
+{
+ char c;
+
+ for (;;) {
+ c = ao_usb_getchar();
+ ao_usb_putchar(c);
+ ao_usb_flush();
+ }
+}
+#endif
+
+#if USB_DEBUG
+static void
+ao_usb_irq(void)
+{
+ printf ("control: %d out: %d in: %d int: %d reset: %d\n",
+ control_count, out_count, in_count, int_count, reset_count);
+}
+
+const struct ao_cmds ao_usb_cmds[] = {
+ { ao_usb_irq, "I\0Show USB interrupt counts" },
+ { 0, NULL }
+};
+#endif
+
+void
+ao_usb_init(void)
+{
+ ao_usb_enable();
+
+ ao_usb_ep0_state = AO_USB_EP0_IDLE;
+#if USB_ECHO
+ ao_add_task(&ao_usb_echo_task, ao_usb_echo, "usb echo");
+#endif
+#if USB_DEBUG
+ ao_cmd_register(&ao_usb_cmds[0]);
+#endif
+#if !USB_ECHO
+#if USE_USB_STDIO
+ ao_add_stdio(_ao_usb_pollchar, ao_usb_putchar, ao_usb_flush);
+#endif
+#endif
+}
+
+#if TX_DBG || RX_DBG
+
+struct ao_usb_dbg {
+ int line;
+ char *msg;
+ uint32_t value;
+ uint32_t prival;
+#if TX_DBG
+ uint16_t in_count;
+ uint32_t in_epr;
+ uint32_t in_pending;
+ uint32_t tx_count;
+ uint32_t in_flushed;
+#endif
+#if RX_DBG
+ uint8_t rx_count;
+ uint8_t rx_pos;
+ uint8_t out_avail;
+ uint32_t out_epr;
+#endif
+};
+
+#define NUM_USB_DBG 16
+
+static struct ao_usb_dbg dbg[NUM_USB_DBG];
+static int dbg_i;
+
+static void _dbg(int line, char *msg, uint32_t value)
+{
+ uint32_t prival;
+ dbg[dbg_i].line = line;
+ dbg[dbg_i].msg = msg;
+ dbg[dbg_i].value = value;
+#if AO_NONMASK_INTERRUPT
+ asm("mrs %0,basepri" : "=&r" (prival));
+#else
+ asm("mrs %0,primask" : "=&r" (prival));
+#endif
+ dbg[dbg_i].prival = prival;
+#if TX_DBG
+ dbg[dbg_i].in_count = in_count;
+ dbg[dbg_i].in_epr = stm_usb.epr[AO_USB_IN_EPR];
+ dbg[dbg_i].in_pending = ao_usb_in_pending;
+ dbg[dbg_i].tx_count = ao_usb_tx_count;
+ dbg[dbg_i].in_flushed = ao_usb_in_flushed;
+#endif
+#if RX_DBG
+ dbg[dbg_i].rx_count = ao_usb_rx_count;
+ dbg[dbg_i].rx_pos = ao_usb_rx_pos;
+ dbg[dbg_i].out_avail = ao_usb_out_avail;
+ dbg[dbg_i].out_epr = stm_usb.epr[AO_USB_OUT_EPR];
+#endif
+ if (++dbg_i == NUM_USB_DBG)
+ dbg_i = 0;
+}
+#endif
diff --git a/src/stm32f4/ao_usb_gen.h b/src/stm32f4/ao_usb_gen.h
new file mode 100644
index 00000000..b059ddb7
--- /dev/null
+++ b/src/stm32f4/ao_usb_gen.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright © 2018 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.
+ */
+
+#ifndef _AO_USB_GEN_H_
+#define _AO_USB_GEN_H_
+
+#include "ao.h"
+#include "ao_usb.h"
+#include "ao_product.h"
+#include <stdint.h>
+
+#define USB_ECHO 0
+
+#ifndef USE_USB_STDIO
+#define USE_USB_STDIO 1
+#endif
+
+#if USE_USB_STDIO
+#define AO_USB_OUT_SLEEP_ADDR (&ao_stdin_ready)
+#else
+#define AO_USB_OUT_SLEEP_ADDR (&ao_usb_out_avail)
+#endif
+
+struct ao_usb_setup {
+ uint8_t dir_type_recip;
+ uint8_t request;
+ uint16_t value;
+ uint16_t index;
+ uint16_t length;
+} ao_usb_setup;
+
+#define AO_USB_EP0_GOT_RESET 1
+#define AO_USB_EP0_GOT_SETUP 2
+#define AO_USB_EP0_GOT_RX_DATA 4
+#define AO_USB_EP0_GOT_TX_ACK 8
+
+/*
+ * End point register indices
+ */
+
+#define AO_USB_CONTROL_EPR 0
+#define AO_USB_INT_EPR 1
+#define AO_USB_OUT_EPR 2
+#define AO_USB_IN_EPR 3
+
+/* Device interfaces required */
+
+/* Queue IN bytes to EP0 */
+void
+ao_usb_dev_ep0_init(void);
+
+void
+ao_usb_dev_ep0_in(const void *data, uint16_t len);
+
+bool
+ao_usb_dev_ep0_in_busy(void);
+
+/* Receive OUT bytes from EP0 */
+uint16_t
+ao_usb_dev_ep0_out(void *data, uint16_t len);
+
+/* Set device address */
+void
+ao_usb_dev_set_address(uint8_t address);
+
+void
+ao_usb_dev_enable(void);
+
+void
+ao_usb_dev_disable(void);
+
+void
+ao_usb_dev_init(void);
+
+/* Queue IN bytes to EPn */
+void
+ao_usb_dev_ep_in(uint8_t ep, const void *data, uint16_t len);
+
+bool
+ao_usb_dev_ep_in_busy(uint8_t ep);
+
+/* Receive OUT bytes from EPn */
+uint16_t
+ao_usb_dev_ep_out(uint8_t ep, void *data, uint16_t len);
+
+
+/* General interfaces provided */
+
+void
+ao_usb_ep0_interrupt(uint8_t mask);
+
+void
+ao_usb_in_interrupt(uint32_t mask);
+
+void
+ao_usb_out_interrupt(uint32_t mask);
+
+#endif /* _AO_USB_GEN_H_ */
+
diff --git a/src/stm32f4/ao_usb_stm32f4.c b/src/stm32f4/ao_usb_stm32f4.c
new file mode 100644
index 00000000..e65c3656
--- /dev/null
+++ b/src/stm32f4/ao_usb_stm32f4.c
@@ -0,0 +1,1144 @@
+/*
+ * Copyright © 2018 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_usb_gen.h"
+
+static uint32_t grxstsp;
+
+static inline uint8_t
+grxstsp_enum(void)
+{
+ return (grxstsp >> STM_USB_GRXSTSP_EPNUM) & STM_USB_GRXSTSP_EPNUM_MASK;
+}
+
+static inline uint8_t
+grxstsp_pktsts(void)
+{
+ return (grxstsp >> STM_USB_GRXSTSP_PKTSTS) & STM_USB_GRXSTSP_PKTSTS_MASK;
+}
+
+static inline uint16_t
+grxstsp_bcnt(void)
+{
+ return (grxstsp >> STM_USB_GRXSTSP_BCNT) & STM_USB_GRXSTSP_BCNT_MASK;
+}
+
+static void
+ao_usb_dev_ep_out_start(uint8_t ep)
+{
+ stm_usb.doep[ep].doeptsiz = ((1 << STM_USB_DOEPTSIZ_PKTCNT) |
+ (3 << STM_USB_DOEPTSIZ_STUPCNT) |
+ (24 << STM_USB_DOEPTSIZ_XFRSIZ));
+
+// stm_usb.doep[ep].doepctl |= (1 << STM_USB_DOEPCTL_EPENA);
+}
+
+static void
+ao_usb_mask_in_bits(vuint32_t *addr, uint32_t shift, uint32_t mask, uint32_t bits)
+{
+ uint32_t value;
+
+ value = *addr;
+ value &= ~(mask << shift);
+ value |= (bits << shift);
+ *addr = value;
+}
+
+static void
+ao_usb_activate_ep0(void)
+{
+ stm_usb.diep[0].diepctl = ((0 << STM_USB_DIEPCTL_TXFNUM) |
+ (0 << STM_USB_DIEPCTL_STALL) |
+ (STM_USB_DIEPCTL_EPTYP_CONTROL << STM_USB_DIEPCTL_EPTYP) |
+ (1 << STM_USB_DIEPCTL_USBAEP) |
+ (STM_USB_DIEPCTL_MPSIZ0_64 << STM_USB_DIEPCTL_MPSIZ));
+ stm_usb.doep[0].doepctl = ((0 << STM_USB_DOEPCTL_SNPM) |
+ (STM_USB_DOEPCTL_EPTYP_CONTROL << STM_USB_DOEPCTL_EPTYP) |
+ (1 << STM_USB_DOEPCTL_USBAEP) |
+ (STM_USB_DOEPCTL_MPSIZ0_64 << STM_USB_DOEPCTL_MPSIZ));
+}
+
+#if 0
+static void
+ao_usb_activate_in(int epnum)
+{
+ stm_usb.daintmsk |= (1 << (epnum + STM_USB_DAINTMSK_IEPM));
+ stm_usb.diep[epnum].diepctl = ((epnum << STM_USB_DIEPCTL_TXFNUM) |
+ (0 << STM_USB_DIEPCTL_STALL) |
+ (STM_USB_DIEPCTL_EPTYP_BULK << STM_USB_DIEPCTL_EPTYP) |
+ (1 << STM_USB_DIEPCTL_USBAEP) |
+ (64 << STM_USB_DIEPCTL_MPSIZ));
+}
+
+static void
+ao_usb_activate_out(int epnum)
+{
+ stm_usb.daintmsk |= (1 << (epnum + STM_USB_DAINTMSK_OEPM));
+ stm_usb.doep[epnum].doepctl = ((0 << STM_USB_DOEPCTL_SNPM) |
+ (STM_USB_DOEPCTL_EPTYP_BULK << STM_USB_DOEPCTL_EPTYP) |
+ (1 << STM_USB_DOEPCTL_USBAEP) |
+ (64 << STM_USB_DOEPCTL_MPSIZ));
+}
+#endif
+
+static void
+ao_usb_enum_done(void)
+{
+ /* Set turn-around delay. 6 is for high hclk (> 32MHz) */
+ ao_usb_mask_in_bits(&stm_usb.gusbcfg, STM_USB_GUSBCFG_TRDT, STM_USB_GUSBCFG_TRDT_MASK, 6);
+
+ ao_usb_activate_ep0();
+}
+
+static void
+ao_usb_flush_tx_fifo(uint32_t fifo)
+{
+ stm_usb.grstctl = ((1 << STM_USB_GRSTCTL_TXFFLSH) |
+ (fifo << STM_USB_GRSTCTL_TXFNUM));
+ while ((stm_usb.grstctl & (1 << STM_USB_GRSTCTL_TXFFLSH)) != 0)
+ ao_arch_nop();
+}
+
+static void
+ao_usb_flush_rx_fifo(void)
+{
+ stm_usb.grstctl = (1 << STM_USB_GRSTCTL_RXFFLSH);
+ while ((stm_usb.grstctl & (1 << STM_USB_GRSTCTL_RXFFLSH)) != 0)
+ ao_arch_nop();
+}
+
+/* reset and enable EP0 */
+void
+ao_usb_dev_ep0_init(void)
+{
+ uint32_t diepctl;
+
+ /* Flush TX fifo */
+ ao_usb_flush_tx_fifo(STM_USB_GRSTCTL_TXFNUM_ALL);
+
+ /* Clear interrupts */
+ for (int i = 0; i < 6; i++) {
+ stm_usb.diep[i].diepint = 0xfffffffful;
+ stm_usb.doep[i].doepint = 0xfffffffful;
+ }
+ stm_usb.daint = 0xfffffffful;
+
+ /* Enable EP0 in/out interrupts */
+ /* 2. Unmask interrupt bits */
+ stm_usb.daintmsk |= ((1 << (STM_USB_DAINTMSK_IEPM + 0)) |
+ (1 << (STM_USB_DAINTMSK_OEPM + 0)));
+
+ stm_usb.doepmsk |= ((1 << STM_USB_DOEPMSK_STUPM) |
+ (1 << STM_USB_DOEPMSK_EPDM) |
+ (1 << STM_USB_DOEPMSK_XFRCM));
+ stm_usb.diepmsk |= ((1 << STM_USB_DIEPMSK_TOM) |
+ (1 << STM_USB_DIEPMSK_XFRCM) |
+ (1 << STM_USB_DIEPMSK_EPDM));
+
+ /* 1. Set NAK bit for all OUT endpoints */
+ stm_usb.doep[0].doepctl |= (1 << STM_USB_DOEPCTL_CNAK);
+ for (int i = 1; i < 6; i++)
+ stm_usb.doep[i].doepctl |= (1 << STM_USB_DOEPCTL_SNAK);
+
+ /* 3. Setup FIFO ram allocation */
+
+ /* XXX make principled decisions here */
+ stm_usb.grxfsiz = 0x80;
+
+ stm_usb.dieptxf0 = ((0x40 << STM_USB_DIEPTXF0_TX0FD) | /* size = 256 bytes */
+ (0x80 << STM_USB_DIEPTXF0_TX0FSA)); /* start address = 0x80 */
+
+ /* 4. Program OUT endpoint 0 to receive a SETUP packet */
+
+ uint32_t doeptsiz;
+
+ doeptsiz = ((1 << STM_USB_DOEPTSIZ_PKTCNT) |
+ (0x40 << STM_USB_DOEPTSIZ_XFRSIZ) |
+ (1 << STM_USB_DOEPTSIZ_STUPCNT));
+
+ stm_usb.doep[0].doeptsiz = doeptsiz;
+
+ /* Program MPSIZ field to set maximum packet size */
+
+ diepctl = ((0 << STM_USB_DIEPCTL_EPENA ) |
+ (0 << STM_USB_DIEPCTL_EPDIS ) |
+ (0 << STM_USB_DIEPCTL_SNAK ) |
+ (0 << STM_USB_DIEPCTL_CNAK ) |
+ (0 << STM_USB_DIEPCTL_TXFNUM) |
+ (0 << STM_USB_DIEPCTL_STALL ) |
+ (STM_USB_DIEPCTL_EPTYP_CONTROL << STM_USB_DIEPCTL_EPTYP ) |
+ (0 << STM_USB_DIEPCTL_NAKSTS ) |
+ (0 << STM_USB_DIEPCTL_EONUM ) |
+ (1 << STM_USB_DIEPCTL_USBAEP ) |
+ (STM_USB_DIEPCTL_MPSIZ0_64 << STM_USB_DIEPCTL_MPSIZ));
+
+ stm_usb.diep[0].diepctl = diepctl;
+
+ uint32_t doepctl;
+
+ doepctl = ((0 << STM_USB_DOEPCTL_EPENA ) |
+ (0 << STM_USB_DOEPCTL_EPDIS ) |
+ (0 << STM_USB_DOEPCTL_SNAK ) |
+ (0 << STM_USB_DOEPCTL_CNAK ) |
+ (0 << STM_USB_DOEPCTL_STALL ) |
+ (0 << STM_USB_DOEPCTL_SNPM ) |
+ (STM_USB_DOEPCTL_EPTYP_CONTROL << STM_USB_DOEPCTL_EPTYP ) |
+ (0 << STM_USB_DOEPCTL_NAKSTS ) |
+ (1 << STM_USB_DOEPCTL_USBAEP ) |
+ (STM_USB_DOEPCTL_MPSIZ0_64 << STM_USB_DOEPCTL_MPSIZ));
+
+ stm_usb.doep[0].doepctl = doepctl;
+
+ /* Clear interrupts */
+ stm_usb.diep[0].diepint = 0xffffffff;
+ stm_usb.doep[0].doepint = 0xffffffff;
+
+ ao_usb_dev_ep_out_start(0);
+}
+
+void
+ao_usb_dev_ep0_in(const void *data, uint16_t len)
+{
+ return ao_usb_dev_ep_in(0, data, len);
+}
+
+bool
+ao_usb_dev_ep0_in_busy(void)
+{
+ return false;
+}
+
+uint16_t
+ao_usb_dev_ep0_out(void *data, uint16_t len)
+{
+ return ao_usb_dev_ep_out(0, data, len);
+}
+
+/* Queue IN bytes to EPn */
+void
+ao_usb_dev_ep_in(uint8_t ep, const void *data, uint16_t len)
+{
+ int l = len;
+
+ while (l > 0) {
+ stm_usb.dfifo[ep].fifo = *((__packed uint32_t *) data);
+ l -= 4;
+ data += 4;
+ }
+
+ /* Set the IN data size */
+ stm_usb.diep[ep].dieptsiz = ((1 << STM_USB_DIEPTSIZ_PKTCNT) |
+ (len << STM_USB_DIEPTSIZ_XFRSIZ));
+
+ /* Enable the TX empty interrupt */
+ stm_usb.diepempmsk |= (1 << ep);
+
+ /* Enable the endpoint to queue the packet for transmission */
+ stm_usb.diep[ep].diepctl |= (1 << STM_USB_DIEPCTL_EPENA);
+}
+
+bool
+ao_usb_dev_ep_in_busy(uint8_t ep)
+{
+ (void) ep;
+ return false;
+}
+
+/* Receive OUT bytes from EPn */
+uint16_t
+ao_usb_dev_ep_out(uint8_t ep, void *data, uint16_t len)
+{
+ uint16_t received;
+ int l = len;
+ uint32_t t;
+
+ if (grxstsp_enum() != ep)
+ return 0;
+
+ received = grxstsp_bcnt();
+ if (received > len)
+ received = len;
+
+ while (l >= 4) {
+ *((__packed uint32_t *) data) = stm_usb.dfifo[0].fifo;
+ l -= 4;
+ data += 4;
+ }
+
+ if (l != 0) {
+ t = stm_usb.dfifo[0].fifo;
+ memcpy(data, &t, l);
+ }
+
+ ao_usb_dev_ep_out_start(ep);
+ return received;
+}
+
+void
+ao_usb_dev_set_address(uint8_t address)
+{
+ uint32_t dcfg;
+
+ dcfg = stm_usb.dcfg;
+
+ dcfg &= ~(STM_USB_DCFG_DAD_MASK << STM_USB_DCFG_DAD);
+ dcfg |= address & STM_USB_DCFG_DAD_MASK;
+ stm_usb.dcfg = dcfg;
+}
+
+static void
+ao_usb_core_reset(void)
+{
+ /* Wait for AHB master IDLE state. */
+ while ((stm_usb.grstctl & (1 << STM_USB_GRSTCTL_AHBIDL)) == 0)
+ ao_arch_nop();
+
+
+ /* Core soft reset */
+ stm_usb.grstctl |= (1 << STM_USB_GRSTCTL_CSRST);
+
+ /* Wait for reset to complete */
+
+ while ((stm_usb.grstctl & (1 << STM_USB_GRSTCTL_CSRST)) != 0)
+ ao_arch_nop();
+}
+
+static void
+ao_usb_core_init(void)
+{
+ /* Enable embedded PHY */
+ stm_usb.gusbcfg |= (1 << STM_USB_GUSBCFG_PHYSEL);
+
+ /* Core reset */
+ ao_usb_core_reset();
+
+ /* Deactivate power down */
+ stm_usb.gccfg = (1 << STM_USB_GCCFG_PWRDWN);
+}
+
+static void
+ao_usb_delay(uint32_t ms)
+{
+ AO_TICK_TYPE now = ao_time();
+ AO_TICK_TYPE then = now + AO_MS_TO_TICKS(ms);
+
+ while ((int16_t) (then - ao_time()) > 0)
+ ao_arch_nop();
+}
+
+static void
+ao_usb_set_device_mode(void)
+{
+ uint32_t gusbcfg;
+
+ gusbcfg = stm_usb.gusbcfg;
+ gusbcfg &= ~((1 << STM_USB_GUSBCFG_FHMOD) |
+ (1 << STM_USB_GUSBCFG_FDMOD));
+ gusbcfg |= (1 << STM_USB_GUSBCFG_FDMOD);
+ stm_usb.gusbcfg = gusbcfg;
+ ao_usb_delay(50);
+}
+
+static void
+ao_usb_device_init(void)
+{
+ /* deactivate vbus sensing */
+ stm_usb.gccfg &= ~(1 << STM_USB_GCCFG_VBDEN);
+
+ /* Force device mode */
+ stm_usb.gotgctl |= ((1 << STM_USB_GOTGCTL_BVALOEN) |
+ (1 << STM_USB_GOTGCTL_BVALOVAL));
+
+ /* Restart the phy clock */
+ stm_usb.pcgcctl = 0;
+
+ /* Device mode configuration */
+ stm_usb.dcfg |= (STM_USB_DCFG_PFIVL_80 << STM_USB_DCFG_PFIVL);
+
+ /* Set full speed phy */
+ stm_usb.dcfg |= (STM_USB_DCFG_DSPD_FULL_SPEED << STM_USB_DCFG_DSPD);
+
+ /* Flush the fifos */
+ ao_usb_flush_tx_fifo(STM_USB_GRSTCTL_TXFNUM_ALL);
+ ao_usb_flush_rx_fifo();
+
+ /* Clear all pending device interrupts */
+ stm_usb.diepmsk = 0;
+ stm_usb.doepmsk = 0;
+ stm_usb.daint = 0xffffffffUL;
+ stm_usb.daintmsk = 0;
+
+ /* Reset all endpoints */
+ for (int i = 0; i < 6; i++) {
+
+ /* Reset IN endpoint */
+ if (stm_usb.diep[i].diepctl & (1 << STM_USB_DIEPCTL_EPENA))
+ stm_usb.diep[i].diepctl = ((1 << STM_USB_DIEPCTL_EPDIS) |
+ (1 << STM_USB_DIEPCTL_SNAK));
+ else
+ stm_usb.diep[i].diepctl = 0;
+ stm_usb.diep[i].dieptsiz = 0;
+ stm_usb.diep[i].diepint = 0xfffffffful;
+
+ /* Reset OUT endpoint */
+ if (stm_usb.doep[i].doepctl & (1 << STM_USB_DOEPCTL_EPENA))
+ stm_usb.doep[i].doepctl = ((1 << STM_USB_DOEPCTL_EPDIS) |
+ (1 << STM_USB_DOEPCTL_SNAK));
+ else
+ stm_usb.doep[i].doepctl = 0;
+
+ stm_usb.doep[i].doeptsiz = 0;
+ stm_usb.doep[i].doepint = 0xfffffffful;
+ }
+
+ /* Disable all interrupts */
+ stm_usb.gintmsk = 0;
+
+ /* Clear pending interrupts */
+ stm_usb.gintsts = 0xfffffffful;
+
+ /* Enable core interrupts */
+ stm_usb.gintmsk = ((1 << STM_USB_GINTMSK_WUIM ) |
+ (0 << STM_USB_GINTMSK_SRQIM ) |
+ (0 << STM_USB_GINTMSK_DISCINT ) |
+ (0 << STM_USB_GINTMSK_CIDSCHGM ) |
+ (0 << STM_USB_GINTMSK_LPMINTM ) |
+ (0 << STM_USB_GINTMSK_PTXFEM ) |
+ (0 << STM_USB_GINTMSK_HCIM) |
+ (0 << STM_USB_GINTMSK_PRTIM ) |
+ (0 << STM_USB_GINTMSK_RSTDETM ) |
+ (1 << STM_USB_GINTMSK_IISOOXFRM ) |
+ (1 << STM_USB_GINTMSK_IISOIXFRM ) |
+ (1 << STM_USB_GINTMSK_OEPINT) |
+ (1 << STM_USB_GINTMSK_IEPINT) |
+ (0 << STM_USB_GINTMSK_EOPFM ) |
+ (0 << STM_USB_GINTMSK_ISOODRPM ) |
+ (1 << STM_USB_GINTMSK_ENUMDNEM) |
+ (1 << STM_USB_GINTMSK_USBRST) |
+ (1 << STM_USB_GINTMSK_USBSUSPM ) |
+ (0 << STM_USB_GINTMSK_ESUSPM ) |
+ (0 << STM_USB_GINTMSK_GONAKEFFM ) |
+ (0 << STM_USB_GINTMSK_GINAKEFFM ) |
+ (0 << STM_USB_GINTMSK_NPTXFEM ) |
+ (0 << STM_USB_GINTMSK_RXFLVLM) |
+ (0 << STM_USB_GINTMSK_SOFM ) |
+ (0 << STM_USB_GINTMSK_OTGINT ) |
+ (0 << STM_USB_GINTMSK_MMISM));
+}
+
+static void
+ao_usb_device_connect(void)
+{
+ /* Enable pull-up/pull-down */
+ stm_usb.dctl &= ~(1 << STM_USB_DCTL_SDIS);
+ ao_usb_delay(20);
+}
+
+#if 0
+static void
+ao_usb_device_disconnect(void)
+{
+ /* Disable pull-up/pull-down */
+ stm_usb.dctl |= (1 << STM_USB_DCTL_SDIS);
+ ao_usb_delay(20);
+}
+#endif
+
+void
+ao_usb_dev_enable(void)
+{
+ ao_arch_block_interrupts();
+
+ /* Configure GPIOs */
+ ao_enable_port(&stm_gpioa);
+#if 0
+ stm_afr_set(&stm_gpioa, 8, STM_AFR_AF10); /* USB_FS_SOF */
+ stm_afr_set(&stm_gpioa, 9, STM_AFR_AF10); /* USB_FS_VBUS */
+ stm_afr_set(&stm_gpioa, 10, STM_AFR_AF10); /* USB_FS_ID */
+#endif
+ stm_afr_set(&stm_gpioa, 11, STM_AFR_AF10);
+ stm_ospeedr_set(&stm_gpioa, 11, STM_OSPEEDR_HIGH);
+ stm_pupdr_set(&stm_gpioa, 11, STM_PUPDR_NONE);
+ stm_afr_set(&stm_gpioa, 12, STM_AFR_AF10);
+ stm_ospeedr_set(&stm_gpioa, 12, STM_OSPEEDR_HIGH);
+ stm_pupdr_set(&stm_gpioa, 12, STM_PUPDR_NONE);
+
+ /* Power on USB */
+ stm_rcc.ahb2enr |= (1 << STM_RCC_AHB2ENR_OTGFSEN);
+
+ /* Route interrupts */
+ stm_nvic_set_priority(STM_ISR_OTG_FS_POS, AO_STM_NVIC_LOW_PRIORITY);
+ stm_nvic_set_enable(STM_ISR_OTG_FS_POS);
+
+ /* Core init */
+ ao_usb_core_init();
+
+ /* Set device mode */
+ ao_usb_set_device_mode();
+
+ /* Reset FIFO allocations */
+ for (int i = 1; i < 16; i++)
+ stm_usb.dieptxf[i-1] = 0x0;
+
+ ao_usb_device_init();
+
+ /* Connect */
+ ao_usb_device_connect();
+}
+
+void
+ao_usb_dev_disable(void)
+{
+ stm_usb.gusbcfg = ((1 << STM_USB_GUSBCFG_FDMOD) |
+ (0 << STM_USB_GUSBCFG_FHMOD) |
+ (6 << STM_USB_GUSBCFG_TRDT) |
+ (0 << STM_USB_GUSBCFG_HNPCAP) |
+ (0 << STM_USB_GUSBCFG_SRPCAP) |
+ (1 << STM_USB_GUSBCFG_PHYSEL) |
+ (0 << STM_USB_GUSBCFG_TOCAL));
+
+ stm_usb.gahbcfg = ((0 << STM_USB_GAHBCFG_PTXFELVL) |
+ (1 << STM_USB_GAHBCFG_TXFELVL) |
+ (0 << STM_USB_GAHBCFG_GINTMSK));
+
+ stm_usb.dctl = ((0 << STM_USB_DCTL_POPRGDNE) |
+ (1 << STM_USB_DCTL_SDIS));
+
+ stm_rcc.ahb2enr &= ~(1 << STM_RCC_AHB2ENR_OTGFSEN);
+}
+
+void
+stm_otg_fs_isr(void)
+{
+ uint32_t gintsts = stm_usb.gintsts;
+ uint8_t ep0_receive = 0;
+ uint32_t out_interrupt = 0;
+ uint32_t in_interrupt = 0;
+
+ /* Clear all received interrupts */
+ stm_usb.gintsts = gintsts;
+
+ if (gintsts & (1 << STM_USB_GINTSTS_USBRST)) {
+ ep0_receive |= AO_USB_EP0_GOT_RESET;
+ }
+
+ if (gintsts & (1 << STM_USB_GINTSTS_ENUMDNE)) {
+ ao_usb_enum_done();
+ }
+
+ if (gintsts & ((1 << STM_USB_GINTSTS_OEPINT) |
+ (1 << STM_USB_GINTSTS_IEPINT)))
+ {
+ uint32_t daint = stm_usb.daint;
+ uint32_t oepint = (daint >> STM_USB_DAINT_OEPINT) & STM_USB_DAINT_OEPINT_MASK;
+ uint32_t iepint = (daint >> STM_USB_DAINT_IEPINT) & STM_USB_DAINT_IEPINT_MASK;
+
+ for (int ep = 0; ep < 6; ep++) {
+ if (gintsts & (1 << STM_USB_GINTSTS_OEPINT)) {
+ if (oepint & (1 << ep)) {
+ uint32_t doepint = stm_usb.doep[ep].doepint;
+
+ stm_usb.doep[ep].doepint = doepint;
+ if (doepint & (1 << STM_USB_DOEPINT_XFRC)) {
+ if (ep == 0)
+ ep0_receive |= AO_USB_EP0_GOT_SETUP;
+ else
+ out_interrupt |= (1 << ep);
+ }
+ grxstsp = stm_usb.grxstsp;
+ }
+ }
+
+ if (gintsts & (1 << STM_USB_GINTSTS_IEPINT)) {
+ if (iepint & (1 << ep)) {
+ uint32_t diepint = stm_usb.diep[ep].diepint;
+
+ stm_usb.diep[ep].diepint = diepint;
+ if (diepint & (1 << STM_USB_DIEPINT_XFRC)) {
+ if (ep == 0)
+ ep0_receive |= AO_USB_EP0_GOT_TX_ACK;
+ else
+ in_interrupt |= (1 << ep);
+ }
+ }
+ }
+ }
+ } else {
+ grxstsp = 0;
+ }
+
+ if (ep0_receive)
+ ao_usb_ep0_interrupt(ep0_receive);
+
+ if (out_interrupt)
+ ao_usb_out_interrupt(out_interrupt);
+
+ if (in_interrupt)
+ ao_usb_in_interrupt(in_interrupt);
+}
+
+/*
+
+ running before plugging in at first packet
+ gotgctl = 0x04cd0000, 0x04c10000, 0x04cd0000 *************
+
+ CURMOD = 0
+ OTGVER = 0
+ BSVLD = 1 BSVLD = 0
+ ASVLD = 1 ASVLD = 0
+ DBCT = 0
+ CIDSTS = 1
+
+ gotgint = 0x00100000, 0x00100000, 0x00100000
+
+ IDCHNG = 1
+
+ gahbcfg = 0x1, 0x1, 0x00000001
+
+ TXFELVL = 0 trigger half empty
+ GINTMSK = 1 interrupts enabled
+
+ gusbcfg = 0x40001840, 0x40001440 0x40001840 *************
+
+ FDMOD = 1 force device mode
+ FHMOD = 0
+ TRDT = 6 5 6
+ HNPCAP = 0
+ SRPCAP = 0
+ PHYSEL = 1
+ TOCAL = 0
+
+ grstctl = 0x80000040, 0x80000000 0x80000400 ***********
+
+ AHBIDL = 1
+ TXFNUM = 1 TXFNUM = 0 TXFNUM = 0x20 (flush all)
+ TXFFLSH = 0
+ RXFFLSH = 0
+ FCRST = 0
+ PSRST = 0
+ CSRST = 0
+
+ gintsts = 0x0480b43a, 0x04008022 0x04888438 ***********
+
+ WKUPINT = 0 0
+ SRQINT = 0 0
+ DISCINT = 0 0
+ CIDSCHG = 0 0
+ LPMINT = 0 0
+ PTXFE = 1 PTXFE = 1 PTXFE = 1
+ HCINT = 0
+ HPRTINT = 0
+ RSTDET = 1 RSTDET = 0 RSTDET = 1
+ IPXFER = 0
+ IISOIXFR = 0
+ OEPINT = 0 OEPINT = 1
+ IEPINT = 0
+ EOPF = 1 EOPF = 1 EOPF = 1
+ ISOODRP = 0
+ ENUMDNE = 1
+ USBRST = 1
+ USBSUSP = 0
+ ESUSP = 1 ESUSP = 1
+ GONAKEFF = 0
+ GINAKEFF = 0
+ NPTXFE = 1 NPTXFE = 1 NPTXFE = 1
+ RXFLVL = 1 RXFLVL = 1
+ SOF = 1 SOF = 1
+ OTGINT = 0
+ MMIS = 1 MMIS = 1 MMIS = 0
+ CMOD = 0
+
+ gintmsk = 0xc03c3814, 0xc03c3814,
+
+ WUIM = 1
+ SRQIM = 1
+ DISCINT = 0
+ CIDSCHGM = 0
+ LPMINTM = 0
+ PTXFEM = 0
+ HCIM = 0
+ PRTIM = 0
+ RSTDETM = 0
+ IISOOXFRM = 1
+ IISOIXFRM = 1
+ OEPINT = 1
+ IEPINT = 1
+ EOPFM = 0
+ ISOODRPM = 0
+ ENUMDNEM = 1
+ USBRST = 1
+ USBSUSPM = 1
+ ESUSPM =0
+ GONAKEFFM = 0
+ GINAKEFFM = 0
+ NPTXFEM = 0
+ RXFLVLM = 1
+ SOFM = 0
+ OTGINT = 1
+ MMISM = 0
+
+ grxstsr = 0xac0080, 0x0 0x14c0080 ***************
+
+ STSPHST = 0 STSPHST = 0
+ FRMNUM = 5 FRMNUM = 10
+ PKTSTS = 6 -- SETUP data packet PKTSTS = 6 -- SETUP data packet
+ DPID = 0 DPID = 0
+ BCNT = 8 BCNT = 8
+ EPNUM = 0 EPNUM = 0
+
+ grxstsp = 0xac0080, 0x0 0x14c0080
+
+ (same)
+
+ grxfsiz = 0x80, 0x80 0x80
+
+ RXFD = 128 512 bytes
+
+ dieptxf0 = 0x00400080, 0x00400080 0x00400080
+
+ TX0FD = 64 256 bytes
+ TX0FSA = 0x80
+
+ gccfg = 0x21fff0, 0x21fff0 0x21fff0
+
+ VBDEN = 1
+ SDEN = 0
+ PDEN = 0
+ DCDEN = 0
+ BCDEN = 0
+ PWRDN = 1
+ PS2DET = 0
+ SDET = 0
+ PDET = 0
+ DCDET = 0
+
+ cid = 0x2000, 0x2000 0x2000
+
+ PRODUCT_ID = 0x2000
+
+ glpmcfg = 0x0, 0x0 0x0
+
+ ENBESL = 0
+ LPMRCNTTST = 0
+ SNDLPM = 0
+ LPMRCNT = 0
+ LPMCHIDX = 0
+ L1RSMOK = 0
+ SLPSTS = 0
+ LPMRSP = 0
+ L1DSEN = 0
+ BESLTHRS = 0
+ L1SSEN = 0
+ REMWAKE = 0
+ BESL = 0
+ LPMACK = 0
+ LPMEN = 0
+
+ dieptxf = {0x8000c0, 0x0, 0x0, 0x0, 0x0}, {0x8000c0, 0x0, 0x0, 0x0, 0x0}, {0x8000c0, 0x0, 0x0, 0x0, 0x0},
+
+ INEXPTXFD 0 = 0x80 512 bytes
+ INEXPTXSA 0 = 0xc0
+
+ dcfg = 0x82000b3, 0x8200003, 0x8200003
+
+ ERRATIM = 0
+ PFIVL = 0
+ DAD = 0xb DAD = 0x0 DAD = 0
+ NZLSOHSK = 0
+ DSPD = 3 Full speed USB 1.1
+
+ dctl = 0x0, 0x0 0x0
+
+ DSBESLRJCT = 0
+ POPRGDNE = 0
+ CGONAK = 0
+ SGONAK = 0
+ CGINAK = 0
+ SGINAK = 0
+ TCTL = 0
+ GONSTS = 0
+ GINSTS = 0
+ SDIS = 0
+ RWUSIG = 0
+
+ dsts = 0x0043ff06, 0x00000006 0x00400c06
+
+ DEVLNSTS = 1 (D+ low, D- high)
+ FNSOF = 0x3ff FNSOF = 0xc
+ EERR = 0
+ ENUMSPD = 3 Full speed ENUMSPD = 3
+ SUSPSTS = 0 SUSPSTS = 0
+
+ diepmsk = 0xb, 0x0 0xb
+
+ NAKM = 0
+ TXFURM = 0
+ INEPNEM = 0
+ INEPNMM = 0
+ ITTXFEMSK = 0
+ TOM = 1
+ EPDM = 1
+ XFRCM = 1
+
+ doepmsk = 0x2b, 0x0 0x2b
+
+ NYETMSK = 0
+ NAKMSK = 0
+ BERRM =0
+ OUTPKTERRM = 0
+ STSPHSRXM = 1
+ OTEPDM = 0
+ STUPM = 1
+ EPDM = 1
+ XFRCM = 1
+
+ daint = 0x0, 0x0 0x10000
+
+ daintmsk = 0x30003, 0x0 0x10001
+
+ OEPM = 0x3 endpoints 0 and 1 OEPM = 0x1 endpoint 0
+ IEPM = 0x3 endpoints 0 and 1 IEPM = 0x1 endpoint 0
+
+ dvbusdis = 0x17d7, 0x17d7 0x17d7
+
+ VBUSDT = 0x17d7 reset value
+
+ dvbuspulse = 0x5b8, 0x5b8 0x5b8
+
+ DVBUSP = 0x5b8 reset value
+
+ diepempmsk = 0x0, 0x0 0x0
+
+ INEPTXFEM = 0 no endpoints
+
+ diep = {{
+ diepctl = 0x28000,
+
+ EPENA = 0
+ EPDIS = 0
+ SNAK = 0
+ CNAK = 0
+ TXFNUM = 0
+ STALL = 0
+ EPTYP = 0
+ NAKSTS = 1
+ USBAEP = 1
+ MPSIZ = 0 64 bytes
+
+ diepint = 0x20c0,
+
+ NAK = 1
+ PKTDRPSTS = 0
+ TXFIFOUDRN = 0
+ TXFE = 1
+ INEPNE = 1
+ ITTXFE = 0
+ TOC = 0
+ EPDISD = 0
+ XFRC = 0
+
+ dieptsiz = 0x0,
+
+ PKTCNT = 0
+ XFRSIZ = 0
+
+ dtxfsts = 0x40,
+
+ INEPTFSAV = 0x40 256 bytes available
+
+ }, {
+ diepctl = 0x00490040,
+
+ EPENA = 0
+ EPDIS = 0
+ SODDFRM = 0
+ SD0PID = 0
+ SNAK = 0
+ CNAK = 0
+ TXFNUM = 1
+ STALL = 0
+ EPTYP = 2 bulk
+ NAKSTS = 0
+ EONUM = 1
+ USBAEP = 0
+ MPSIZ = 64 256 bytes
+
+ diepint = 0x2090,
+
+ NAK = 1
+ PKTDRPSTS = 0
+ TXFIFOUDRN = 0
+ TXFE = 1
+ INEPNE = 0
+ INPENM = 0
+ ITTXFE = 1
+ TOC = 0
+ EPDISD = 0
+ XFRC = 0
+
+ dieptsiz = 0x0,
+
+ MCNT = 0
+ PKTCNT = 0
+ XFRSIZ = 0
+
+ dtxfsts = 0x80,
+
+ INEPTFSAV = 0x80 512 bytes available
+
+ }, {
+ diepctl = 0x0,
+ pad_04 = 0x0,
+ diepint = 0x80,
+ pad_0c = 0x0,
+ dieptsiz = 0x0,
+ pad_14 = 0x43425355,
+ dtxfsts = 0x40,
+ pad_1c = 0x400000
+ }, {
+ diepctl = 0x0,
+ pad_04 = 0x0,
+ diepint = 0x80,
+ pad_0c = 0x0,
+ dieptsiz = 0x0,
+ pad_14 = 0x43425355,
+ dtxfsts = 0x40,
+ pad_1c = 0x400000
+ }, {
+ diepctl = 0x0,
+ pad_04 = 0x0,
+ diepint = 0x80,
+ pad_0c = 0x0,
+ dieptsiz = 0x0,
+ pad_14 = 0x43425355,
+ dtxfsts = 0x40,
+ pad_1c = 0x400000
+ }, {
+ diepctl = 0x0,
+ pad_04 = 0x0,
+ diepint = 0x80,
+ pad_0c = 0x0,
+ dieptsiz = 0x0,
+ pad_14 = 0x43425355,
+ dtxfsts = 0x40,
+ pad_1c = 0x400000
+ }},
+
+ doep = {{
+ doepctl = 0x80028000, 0x00008000, 0x28000
+
+ EPENA = 1 EPENA = 0 EPENA = 0
+ EPDIS = 0
+ SNAK =0
+ CNAK = 0
+ STALL = 0
+ SNPM = 0
+ EPTYP = 0
+ NAKSTS = 1 NAKSTS = 0 NAKSTS = 1
+ USPAEP = 1 USPAEP = 1
+ MPSIZ = 0 64 bytes MPSIZ = 0
+
+ doepint = 0x8010, 0x0 0x8008
+
+ NYET = 0
+ NAK = 0
+ BERR = 0
+ OUTPKTERR = 0
+ STSPHSRX = 0
+ OTEPDIS = 1
+ STUP = 0 STUP = 1
+ EPDISD = 0
+ XFRC = 0
+
+ doeptsiz = 0x38, 0x0 0x20080008
+
+ STPCNT = 0 1 packet STPCNT = 1
+ PKTCNT = 0 PKTCNT = 1
+ XFRSIZ = 0x38 56 bytes (64 - 8) XFRSIZ = 8
+
+ }, {
+ doepctl = 0x800b0040,
+
+ EPENA = 1
+ EPDIS = 0
+ SD1PID = 0
+ SD0PID = 0
+ SNAK = 0
+ CNAK = 0
+ STALL = 0
+ SNPM =0
+ EPTYP = 2 Bulk
+ NAKSTS = 1
+ EONUM = 1
+ USBAEP = 0
+ MPSIZ = 0x40 64 bytes
+
+ doepint = 0x0,
+ doeptsiz = 0x21,
+
+ RXDPID = 0
+ PKTCNT = 0
+ XFRSIZ = 0x21 33 bytes ?
+
+ }, {
+ doepctl = 0x0,
+ pad_04 = 0x0,
+ doepint = 0x0,
+ pad_0c = 0x0,
+ doeptsiz = 0x0,
+ pad_14 = 0x43425355,
+ pad_18 = 0x40,
+ pad_1c = 0x400000
+ }, {
+ doepctl = 0x0,
+ pad_04 = 0x0,
+ doepint = 0x0,
+ pad_0c = 0x0,
+ doeptsiz = 0x0,
+ pad_14 = 0x43425355,
+ pad_18 = 0x40,
+ pad_1c = 0x400000
+ }, {
+ doepctl = 0x0,
+ pad_04 = 0x0,
+ doepint = 0x0,
+ pad_0c = 0x0,
+ doeptsiz = 0x0,
+ pad_14 = 0x43425355,
+ pad_18 = 0x40,
+ pad_1c = 0x400000
+ }, {
+ doepctl = 0x0,
+ pad_04 = 0x0,
+ doepint = 0x0,
+ pad_0c = 0x0,
+ doeptsiz = 0x0,
+ pad_14 = 0x43425355,
+ pad_18 = 0x40,
+ pad_1c = 0x400000
+ }},
+
+ pcgcctl = 0x0, 0x0, 0x0
+
+ SUSP = 0
+ PHYSLEEP = 0
+ ENL1GTG = 0
+ PHYSUSP = 0
+ GATEHCLK = 0
+ STPPCLK = 0
+
+ dfifo = {{
+ fifo = 0x1000680,
+
+
+ Clock configuration:
+
+$5 = {
+ cr = 0x0f077d83,
+
+ PLLI2SRDY = 1
+ PLLI2SON = 1
+ PLLRDY = 1
+ PLLON = 1
+ CSSON = 0
+ HSEBYP = 1
+ HSERDY = 1
+ HSEON = 1
+ HSICAL = 0x7d
+ HSITRIM = 0x10
+ HSIRDY = 1
+ HSION = 1
+
+ pllcfgr = 0x27403208,
+
+ PLLR = 2
+ PLLQ = 7
+ PLLSRC = 1 HSE
+ PLLP = 0 2
+ PLLN = 0xc8 200
+ PLLM = 8
+
+ clk_pllin = 8000000 / 8 = 1000000
+ vco = 1000000 * 200 = 200000000
+ clk_pll1p = 200000000 / 2 = 100000000 (100MHz)
+ clk_pll1q = 200000000 / 7 = ???
+ clk_pll1r = 200000000 / 2 = 100000000 (100MHz)
+
+ cfgr = 0x0000100a,
+ cir = 0x00000000,
+ ahb1rstr = 0x0,
+ ahb2rstr = 0x0,
+ ahb3rstr = 0x0,
+ pad_1c = 0x0,
+ apb1rstr = 0x0,
+ apb2rstr = 0x0,
+ pad_28 = 0x0,
+ pad_2c = 0x0,
+ ahb1enr = 0x40107f,
+ ahb2enr = 0x80,
+ ahbdnr = 0x3,
+ pad_3c = 0x0,
+ apb1enr = 0x11000410,
+ apb2enr = 0xc800,
+ pad_48 = 0x0,
+ pad_4c = 0x0,
+ ahb1lpenr = 0x6390ff,
+ ahb2lpenr = 0xd0,
+ ahb3lpenr = 0x3,
+ pad_5c = 0x0,
+ apb1lpenr = 0xfffecfff,
+ apb2lpenr = 0x357f9f3,
+ pad_68 = 0x0,
+ pad_6c = 0x0,
+ bdcr = 0x8200,
+ csr = 0x1e000003,
+ pad_78 = 0x0,
+ pad_7c = 0x0,
+ sscgr = 0x0,
+ plli2scfgr = 0x44003008,
+
+ PLLI2SR = 4
+ PLLI2SQ = 4
+ PLLI2SSRC = 0 HSE (due to PLLSRC)
+ PLLI2SN = 0xc0 192
+ PLLI2SM = 8
+
+ clk_plli2sin = 8000000 / 8 = 1000000
+ vcoi2s = 1000000 * 192 = 192000000
+ ck_pl2q = 192000000 / 4 = 48000000
+ ck_pl2r = 192000000 / 4 = 48000000
+
+ pad_88 = 0x0,
+ dckcfgr = 0x0,
+
+
+ ckgatenr = 0x0,
+
+ All clock gates enabled
+
+ dckcfgr2 = 0x08000000
+
+ LPTIMER1SEL = 0 APB
+ CKSDIOSEL = 0 CK_48MHz
+ CK48MSEL = 1 PLLI2S_Q
+ I2CFMP1SEL = 0 APB
+}
+
+
+
+*/
diff --git a/src/stm32f4/registers.ld b/src/stm32f4/registers.ld
new file mode 100644
index 00000000..bc924106
--- /dev/null
+++ b/src/stm32f4/registers.ld
@@ -0,0 +1,75 @@
+
+stm_tim2 = 0x40000000;
+stm_tim3 = 0x40000400;
+stm_tim4 = 0x40000800;
+stm_tim5 = 0x40000c00;
+stm_tim6 = 0x40001000;
+stm_tim7 = 0x40001400;
+stm_tim12 = 0x40001800;
+stm_tim13 = 0x40001c00;
+stm_tim14 = 0x40002000;
+stm_lptim1 = 0x40002400;
+stm_rtc = 0x40002800;
+stm_wwdg = 0x40002c00;
+stm_iwdg = 0x40003000;
+stm_can1 = 0x40006400;
+stm_can2 = 0x40006800;
+stm_can3 = 0x40006c00;
+stm_pwr = 0x40007000;
+stm_dac1 = 0x40007400;
+stm_uart7 = 0x40007800;
+stm_uart8 = 0x40007c00;
+
+stm_tim1 = 0x40010000;
+stm_tim8 = 0x40010400;
+stm_usart1 = 0x40011000;
+stm_usart6 = 0x40011400;
+stm_uart9 = 0x40011800;
+stm_uart10 = 0x40011c00;
+stm_adc = 0x40012000;
+stm_sdio = 0x40012c00;
+stm_spi1 = 0x40013000;
+stm_spi4 = 0x40013400;
+stm_syscfg = 0x40013800;
+stm_exti = 0x40013c00;
+stm_tim9 = 0x40014000;
+stm_tim10 = 0x40014400;
+stm_tim11 = 0x40014800;
+stm_spi5 = 0x40015000;
+stm_sai1 = 0x40015800;
+stm_dfsdm1 = 0x40016000;
+stm_dfsdm2 = 0x40016400;
+
+/* AHB1 */
+
+stm_gpioa = 0x40020000;
+stm_gpiob = 0x40020400;
+stm_gpioc = 0x40020800;
+stm_gpiod = 0x40020c00;
+stm_gpioe = 0x40021000;
+stm_gpiof = 0x40021400;
+stm_gpiog = 0x40021800;
+stm_gpioh = 0x40021c00;
+
+stm_crc = 0x40023000;
+stm_rcc = 0x40023800;
+stm_flash = 0x40023c00;
+stm_dma1 = 0x40026000;
+stm_dma2 = 0x40026400;
+
+/* AHB2 */
+
+stm_usb = 0x50000000;
+stm_rng = 0x50060800;
+
+stm_systick = 0xe000e010;
+
+stm_ictr = 0xe000e004;
+stm_nvic = 0xe000e100;
+
+stm_scb = 0xe000ed00;
+
+stm_mpu = 0xe000ed90;
+
+stm_flash_size = 0x1fff7a22;
+stm_device_id = 0x1fff7a10;
diff --git a/src/stm32f4/stm32f4.h b/src/stm32f4/stm32f4.h
new file mode 100644
index 00000000..dcdce667
--- /dev/null
+++ b/src/stm32f4/stm32f4.h
@@ -0,0 +1,1522 @@
+/*
+ * Copyright © 2018 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.
+ */
+
+#ifndef _STM32F4_H_
+#define _STM32F4_H_
+
+#include <stdint.h>
+
+typedef volatile uint32_t vuint32_t;
+typedef volatile void * vvoid_t;
+typedef volatile uint16_t vuint16_t;
+typedef volatile uint8_t vuint8_t;
+
+struct stm_pwr {
+ vuint32_t cr;
+ vuint32_t csr;
+};
+
+extern struct stm_pwr stm_pwr;
+
+#define stm_pwr (*((struct stm_pwr *) 0x40007000))
+
+#define STM_PWR_CR_FISSR 21
+#define STM_PWR_CR_FMSSR 20
+#define STM_PWR_CR_VOS 14
+#define STM_PWR_CR_VOS_SCALE_MODE_3 1
+#define STM_PWR_CR_VOS_SCALE_MODE_2 2
+#define STM_PWR_CR_VOS_SCALE_MODE_1 3
+#define STM_PWR_CR_VOS_SCALE_MODE_MASK 3
+#define STM_PWR_CR_ADCDC1 13
+#define STM_PWR_CR_MRLVDS 11
+#define STM_PWR_CR_LPLVDS 10
+#define STM_PWR_CR_FPDS 9
+#define STM_PWR_CR_DBP 8
+#define STM_PWR_CR_PLS 5
+#define STM_PWR_CR_PVDE 4
+#define STM_PWR_CR_CSBF 3
+#define STM_PWR_CR_CWUF 2
+#define STM_PWR_CR_PDDS 1
+#define STM_PWR_CR_LPDS 0
+
+struct stm_rcc {
+ vuint32_t cr;
+ vuint32_t pllcfgr;
+ vuint32_t cfgr;
+ vuint32_t cir;
+
+ vuint32_t ahb1rstr;
+ vuint32_t ahb2rstr;
+ vuint32_t ahb3rstr;
+ uint32_t pad_1c;
+
+ vuint32_t apb1rstr;
+ vuint32_t apb2rstr;
+ vuint32_t pad_28;
+ vuint32_t pad_2c;
+
+ vuint32_t ahb1enr;
+ vuint32_t ahb2enr;
+ vuint32_t ahbdnr;
+ vuint32_t pad_3c;
+
+ vuint32_t apb1enr;
+ vuint32_t apb2enr;
+ vuint32_t pad_48;
+ vuint32_t pad_4c;
+
+ vuint32_t ahb1lpenr;
+ vuint32_t ahb2lpenr;
+ vuint32_t ahb3lpenr;
+ vuint32_t pad_5c;
+
+ vuint32_t apb1lpenr;
+ vuint32_t apb2lpenr;
+ vuint32_t pad_68;
+ vuint32_t pad_6c;
+
+ vuint32_t bdcr;
+ vuint32_t csr;
+ vuint32_t pad_78;
+ vuint32_t pad_7c;
+
+ vuint32_t sscgr;
+ vuint32_t plli2scfgr;
+ vuint32_t pad_88;
+ vuint32_t dckcfgr;
+
+ vuint32_t ckgatenr;
+ vuint32_t dckcfgr2;
+};
+
+extern struct stm_rcc stm_rcc;
+
+#define stm_rcc (*((struct stm_rcc *) 0x40023800))
+
+/* Internal HSI is 16MHz */
+#define STM_HSI_FREQ 16000000
+
+#define STM_RCC_CR_PLLI2SRDY (27)
+#define STM_RCC_CR_PLLI2SON (26)
+#define STM_RCC_CR_PLLRDY (25)
+#define STM_RCC_CR_PLLON (24)
+#define STM_RCC_CR_CSSON (19)
+#define STM_RCC_CR_HSEBYP (18)
+#define STM_RCC_CR_HSERDY (17)
+#define STM_RCC_CR_HSEON (16)
+#define STM_RCC_CR_HSICAL (8)
+#define STM_RCC_CR_HSITRIM (3)
+#define STM_RCC_CR_HSIRDY (1)
+#define STM_RCC_CR_HSION (0)
+
+#define STM_RCC_PLLCFGR_PLLM 0
+#define STM_RCC_PLLCFGR_PLLM_MASK 0x3f
+#define STM_RCC_PLLCFGR_PLLN 6
+#define STM_RCC_PLLCFGR_PLLN_MASK 0x1ff
+#define STM_RCC_PLLCFGR_PLLP 16
+#define STM_RCC_PLLCFGR_PLLP_DIV_2 0
+#define STM_RCC_PLLCFGR_PLLP_DIV_4 1
+#define STM_RCC_PLLCFGR_PLLP_DIV_6 2
+#define STM_RCC_PLLCFGR_PLLP_DIV_8 3
+#define STM_RCC_PLLCFGR_PLLP_MASK 0x3
+#define STM_RCC_PLLCFGR_PLLSRC 22
+#define STM_RCC_PLLCFGR_PLLSRC_HSI 0
+#define STM_RCC_PLLCFGR_PLLSRC_HSE 1
+#define STM_RCC_PLLCFGR_PLLQ 24
+#define STM_RCC_PLLCFGR_PLLQ_MASK 0xf
+#define STM_RCC_PLLCFGR_PLLR 28
+#define STM_RCC_PLLCFGR_PLLR_MASK 0x7
+
+#define STM_RCC_CFGR_MCO2 (30)
+#define STM_RCC_CFGR_MCO2PRE (27)
+#define STM_RCC_CFGR_MCO1PRE (24)
+#define STM_RCC_CFGR_MCO1 (21)
+#define STM_RCC_CFGR_RTCPRE (16)
+
+#define STM_RCC_CFGR_PPRE2 (13)
+#define STM_RCC_CFGR_PPRE2_DIV_1 0
+#define STM_RCC_CFGR_PPRE2_DIV_2 4
+#define STM_RCC_CFGR_PPRE2_DIV_4 5
+#define STM_RCC_CFGR_PPRE2_DIV_8 6
+#define STM_RCC_CFGR_PPRE2_DIV_16 7
+#define STM_RCC_CFGR_PPRE2_MASK 7
+
+#define STM_RCC_CFGR_PPRE1 (10)
+#define STM_RCC_CFGR_PPRE1_DIV_1 0
+#define STM_RCC_CFGR_PPRE1_DIV_2 4
+#define STM_RCC_CFGR_PPRE1_DIV_4 5
+#define STM_RCC_CFGR_PPRE1_DIV_8 6
+#define STM_RCC_CFGR_PPRE1_DIV_16 7
+#define STM_RCC_CFGR_PPRE1_MASK 7
+
+#define STM_RCC_CFGR_HPRE (4)
+#define STM_RCC_CFGR_HPRE_DIV_1 0x0
+#define STM_RCC_CFGR_HPRE_DIV_2 0x8
+#define STM_RCC_CFGR_HPRE_DIV_4 0x9
+#define STM_RCC_CFGR_HPRE_DIV_8 0xa
+#define STM_RCC_CFGR_HPRE_DIV_16 0xb
+#define STM_RCC_CFGR_HPRE_DIV_64 0xc
+#define STM_RCC_CFGR_HPRE_DIV_128 0xd
+#define STM_RCC_CFGR_HPRE_DIV_256 0xe
+#define STM_RCC_CFGR_HPRE_DIV_512 0xf
+#define STM_RCC_CFGR_HPRE_MASK 0xf
+
+#define STM_RCC_CFGR_SWS (2)
+#define STM_RCC_CFGR_SWS_HSI 0
+#define STM_RCC_CFGR_SWS_HSE 1
+#define STM_RCC_CFGR_SWS_PLL 2
+#define STM_RCC_CFGR_SWS_MASK 3
+
+#define STM_RCC_CFGR_SW (0)
+#define STM_RCC_CFGR_SW_HSI 0
+#define STM_RCC_CFGR_SW_HSE 1
+#define STM_RCC_CFGR_SW_PLL 2
+#define STM_RCC_CFGR_SW_MASK 3
+
+#define STM_RCC_AHB1ENR_IOPAEN 0
+#define STM_RCC_AHB1ENR_IOPBEN 1
+#define STM_RCC_AHB1ENR_IOPCEN 2
+#define STM_RCC_AHB1ENR_IOPDEN 3
+#define STM_RCC_AHB1ENR_IOPEEN 4
+#define STM_RCC_AHB1ENR_IOPFEN 5
+#define STM_RCC_AHB1ENR_IOPGEN 6
+#define STM_RCC_AHB1ENR_IOPHEN 7
+
+#define STM_RCC_AHB2ENR_OTGFSEN 7
+#define STM_RCC_AHB2ENR_RNGEN 6
+#define STM_RCC_AHB2ENR_CRYPEN 4
+
+#define STM_RCC_APB1ENR_UART8EN 31
+#define STM_RCC_APB1ENR_UART7EN 30
+#define STM_RCC_APB1ENR_DACEN 29
+#define STM_RCC_APB1ENR_PWREN 28
+#define STM_RCC_APB1ENR_CAN3EN 27
+#define STM_RCC_APB1ENR_CAN2EN 26
+#define STM_RCC_APB1ENR_CAN1EN 25
+#define STM_RCC_APB1ENR_I2CFMP1EN 24
+#define STM_RCC_APB1ENR_I2C3EN 23
+#define STM_RCC_APB1ENR_I2C2EN 22
+#define STM_RCC_APB1ENR_I2C1EN 21
+#define STM_RCC_APB1ENR_UART5EN 20
+#define STM_RCC_APB1ENR_UART4EN 19
+#define STM_RCC_APB1ENR_USART3EN 18
+#define STM_RCC_APB1ENR_USART2EN 17
+#define STM_RCC_APB1ENR_SPI3EN 15
+#define STM_RCC_APB1ENR_SPI2EN 14
+#define STM_RCC_APB1ENR_WWDGEN 11
+#define STM_RCC_APB1ENR_RTCAPBEN 10
+#define STM_RCC_APB1ENR_LPTIMER1EN 9
+#define STM_RCC_APB1ENR_TIM14EN 8
+#define STM_RCC_APB1ENR_TIM13EN 7
+#define STM_RCC_APB1ENR_TIM12EN 6
+#define STM_RCC_APB1ENR_TIM7EN 5
+#define STM_RCC_APB1ENR_TIM6EN 4
+#define STM_RCC_APB1ENR_TIM5EN 3
+#define STM_RCC_APB1ENR_TIM4EN 2
+#define STM_RCC_APB1ENR_TIM3EN 1
+#define STM_RCC_APB1ENR_TIM2EN 0
+
+#define STM_RCC_APB2ENR_DFSDM2EN 25
+#define STM_RCC_APB2ENR_DFSDM1EN 24
+#define STM_RCC_APB2ENR_SAI1EN 22
+#define STM_RCC_APB2ENR_SPI5EN 20
+#define STM_RCC_APB2ENR_TIM11EN 18
+#define STM_RCC_APB2ENR_TIM10EN 17
+#define STM_RCC_APB2ENR_TIM9EN 16
+#define STM_RCC_APB2ENR_EXITEN 15
+#define STM_RCC_APB2ENR_SYSCFGEN 14
+#define STM_RCC_APB2ENR_SPI4EN 13
+#define STM_RCC_APB2ENR_SPI1EN 12
+#define STM_RCC_APB2ENR_SDIOEN 11
+#define STM_RCC_APB2ENR_ADC1EN 8
+#define STM_RCC_APB2ENR_UART10EN 7
+#define STM_RCC_APB2ENR_UART9EN 5
+#define STM_RCC_APB2ENR_USART6EN 5
+#define STM_RCC_APB2ENR_USART1EN 4
+#define STM_RCC_APB2ENR_TIM8EN 1
+#define STM_RCC_APB2ENR_TIM1EN 0
+
+#define STM_RCC_CSR_RMVF 24
+
+#define STM_RCC_DCKCFGR_CKDFSDMSEL 31
+#define STM_RCC_DCKCFGR_I2S2SRC 27
+#define STM_RCC_DCKCFGR_I2S1SRC 25
+#define STM_RCC_DCKCFGR_TIMPRE 24
+#define STM_RCC_DCKCFGR_SAII1BSRC 22
+#define STM_RCC_DCKCFGR_SAII1ASRC 20
+#define STM_RCC_DCKCFGR_CKDFSDM1ASEL 15
+#define STM_RCC_DCKCFGR_CKDFSDM2ASEL 14
+#define STM_RCC_DCKCFGR_PLLDIVR 8
+#define STM_RCC_DCKCFGR_PLLI2SDIVR 0
+
+#define STM_RCC_DCKCFGR2_LPTIMER1SEL 30
+#define STM_RCC_DCKCFGR2_LPTIMER1SEL_APB 0
+#define STM_RCC_DCKCFGR2_LPTIMER1SEL_HSI 1
+#define STM_RCC_DCKCFGR2_LPTIMER1SEL_LSI 2
+#define STM_RCC_DCKCFGR2_LPTIMER1SEL_LSE 3
+#define STM_RCC_DCKCFGR2_SDIOSEL 28
+#define STM_RCC_DCKCFGR2_SDIOSEL_CK_48MHZ 0
+#define STM_RCC_DCKCFGR2_SDIOSEL_SYSTEM_CLOCK 1
+#define STM_RCC_DCKCFGR2_CK48MSEL 27
+#define STM_RCC_DCKCFGR2_CK48MSEL_PLL_Q 1
+#define STM_RCC_DCKCFGR2_CK48MSEL_PLLI2S_Q 1
+#define STM_RCC_DCKCFGR2_I2CFMP1SEL 22
+#define STM_RCC_DCKCFGR2_I2CFMP1SEL_APB 0
+#define STM_RCC_DCKCFGR2_I2CFMP1SEL_SYSTEM_CLOCK 1
+#define STM_RCC_DCKCFGR2_I2CFMP1SEL_HSI 2
+#define STM_RCC_DCKCFGR2_I2CFMP1SEL_APB_ALSO 3
+
+struct stm_ictr {
+ vuint32_t ictr;
+};
+
+extern struct stm_ictr stm_ictr;
+
+#define stm_ictr (*((struct stm_ictr *) 0xe000e004))
+
+#define STM_ICTR_ICTR_INTLINESNUM 0
+#define STM_ICTR_ICTR_INTLINESNUM_MASK 0xf
+
+struct stm_nvic {
+ vuint32_t iser[8]; /* 0x000 0xe000e100 Set Enable Register */
+
+ uint8_t _unused020[0x080 - 0x020];
+
+ vuint32_t icer[8]; /* 0x080 0xe000e180 Clear Enable Register */
+
+ uint8_t _unused0a0[0x100 - 0x0a0];
+
+ vuint32_t ispr[8]; /* 0x100 0xe000e200 Set Pending Register */
+
+ uint8_t _unused120[0x180 - 0x120];
+
+ vuint32_t icpr[8]; /* 0x180 0xe000e280 Clear Pending Register */
+
+ uint8_t _unused1a0[0x200 - 0x1a0];
+
+ vuint32_t iabr[8]; /* 0x200 0xe000e300 Active Bit Register */
+
+ uint8_t _unused220[0x300 - 0x220];
+
+ vuint32_t ipr[60]; /* 0x300 0xe000e400 Priority Register */
+};
+
+extern struct stm_nvic stm_nvic;
+
+#define stm_nvic (*((struct stm_nvic *) 0xe000e100))
+
+#define IRQ_REG(irq) ((irq) >> 5)
+#define IRQ_BIT(irq) ((irq) & 0x1f)
+#define IRQ_MASK(irq) (1 << IRQ_BIT(irq))
+#define IRQ_BOOL(v,irq) (((v) >> IRQ_BIT(irq)) & 1)
+
+static inline void
+stm_nvic_set_enable(int irq) {
+ stm_nvic.iser[IRQ_REG(irq)] = IRQ_MASK(irq);
+}
+
+static inline void
+stm_nvic_clear_enable(int irq) {
+ stm_nvic.icer[IRQ_REG(irq)] = IRQ_MASK(irq);
+}
+
+static inline int
+stm_nvic_enabled(int irq) {
+ return IRQ_BOOL(stm_nvic.iser[IRQ_REG(irq)], irq);
+}
+
+static inline void
+stm_nvic_set_pending(int irq) {
+ stm_nvic.ispr[IRQ_REG(irq)] = IRQ_MASK(irq);
+}
+
+static inline void
+stm_nvic_clear_pending(int irq) {
+ stm_nvic.icpr[IRQ_REG(irq)] = IRQ_MASK(irq);
+}
+
+static inline int
+stm_nvic_pending(int irq) {
+ return IRQ_BOOL(stm_nvic.ispr[IRQ_REG(irq)], irq);
+}
+
+static inline int
+stm_nvic_active(int irq) {
+ return IRQ_BOOL(stm_nvic.iabr[IRQ_REG(irq)], irq);
+}
+
+#define IRQ_PRIO_REG(irq) ((irq) >> 2)
+#define IRQ_PRIO_BIT(irq) (((irq) & 3) << 3)
+#define IRQ_PRIO_MASK(irq) (0xff << IRQ_PRIO_BIT(irq))
+
+static inline void
+stm_nvic_set_priority(int irq, uint8_t prio) {
+ int n = IRQ_PRIO_REG(irq);
+ uint32_t v;
+
+ v = stm_nvic.ipr[n];
+ v &= ~IRQ_PRIO_MASK(irq);
+ v |= (prio) << IRQ_PRIO_BIT(irq);
+ stm_nvic.ipr[n] = v;
+}
+
+static inline uint8_t
+stm_nvic_get_priority(int irq) {
+ return (stm_nvic.ipr[IRQ_PRIO_REG(irq)] >> IRQ_PRIO_BIT(irq)) & IRQ_PRIO_MASK(0);
+}
+
+#define isr(name) void stm_ ## name ## _isr(void)
+
+isr(nmi);
+isr(hardfault);
+isr(memmanage);
+isr(busfault);
+isr(usagefault);
+isr(svc);
+isr(debugmon);
+isr(pendsv);
+isr(systick);
+isr(wwdg);
+isr(pvd);
+isr(tamper_stamp);
+isr(rtc_wkup);
+isr(flash);
+isr(rcc);
+isr(exti0);
+isr(exti1);
+isr(exti2);
+isr(exti3);
+isr(exti4);
+isr(dma1_stream0);
+isr(dma1_stream1);
+isr(dma1_stream2);
+isr(dma1_stream3);
+isr(dma1_stream4);
+isr(dma1_stream5);
+isr(dma1_stream6);
+isr(adc);
+isr(can1_tx);
+isr(can1_rx0);
+isr(can1_rx1);
+isr(can1_sce);
+isr(exti9_5);
+isr(tim1_brk_tim9);
+isr(tim1_up_tim10);
+isr(tim_trg_com_tim11);
+isr(tim1_cc);
+isr(tim2);
+isr(tim3);
+isr(tim4);
+isr(i2c1_evt);
+isr(i2c1_err);
+isr(i2c2_evt);
+isr(i2c2_err);
+isr(spi1);
+isr(spi2);
+isr(usart1);
+isr(usart2);
+isr(usart3);
+isr(exti15_10);
+isr(rtc_alarm);
+isr(otg_fs_wkup);
+isr(tim8_brk_tim12);
+isr(tim8_up_tim13);
+isr(tim8_trg_com_tim14);
+isr(tim8_cc);
+isr(dma1_stream7);
+isr(fsmc);
+isr(sdio);
+isr(tim5);
+isr(spi3);
+isr(uart4);
+isr(uart5);
+isr(tim6_glb_it);
+isr(tim7);
+isr(dma2_stream0);
+isr(dma2_stream1);
+isr(dma2_stream2);
+isr(dma2_stream3);
+isr(dma2_stream4);
+isr(dfsdm1_flt0);
+isr(dfsdm1_flt1);
+isr(can2_tx);
+isr(can2_rx0);
+isr(can2_rx1);
+isr(can2_sce);
+isr(otg_fs);
+isr(dma2_stream5);
+isr(dma2_stream6);
+isr(dma2_stream7);
+isr(usart6);
+isr(i2c3_ev);
+isr(i2c3_er);
+isr(can3_tx);
+isr(can3_rx0);
+isr(can3_rx1);
+isr(can3_sce);
+isr(crypto);
+isr(rng);
+isr(fpu);
+isr(uart7);
+isr(uart8);
+isr(spi4);
+isr(spi5);
+isr(sai1);
+isr(uart9);
+isr(uart10);
+isr(quad_spi);
+isr(i2cfmp1_ev);
+isr(i2cfmp1_er);
+isr(exti23);
+isr(dfsdm2_flt0);
+isr(dfsdm2_flt1);
+isr(dfsdm2_flt2);
+isr(dfsdm2_flt3);
+
+#undef isr
+
+#define STM_ISR_WWDG_POS 0
+#define STM_ISR_PVD_POS 1
+#define STM_ISR_TAMPER_STAMP_POS 2
+#define STM_ISR_RTC_WKUP_POS 3
+#define STM_ISR_FLASH_POS 4
+#define STM_ISR_RCC_POS 5
+#define STM_ISR_EXTI0_POS 6
+#define STM_ISR_EXTI1_POS 7
+#define STM_ISR_EXTI2_POS 8
+#define STM_ISR_EXTI3_POS 9
+#define STM_ISR_EXTI4_POS 10
+#define STM_ISR_DMA1_STREAM0_POS 11
+#define STM_ISR_DMA1_STREAM1_POS 12
+#define STM_ISR_DMA1_STREAM2_POS 13
+#define STM_ISR_DMA1_STREAM3_POS 14
+#define STM_ISR_DMA1_STREAM4_POS 15
+#define STM_ISR_DMA1_STREAM5_POS 16
+#define STM_ISR_DMA1_STREAM6_POS 17
+#define STM_ISR_ADC_POS 18
+#define STM_ISR_CAN1_TX_POS 19
+#define STM_ISR_CAN1_RX0_POS 20
+#define STM_ISR_CAN1_RX1_POS 21
+#define STM_ISR_CAN1_SCE_POS 22
+#define STM_ISR_EXTI9_5_POS 23
+#define STM_ISR_TIM1_BRK_TIM9_POS 24
+#define STM_ISR_TIM1_UP_TIM10_POS 25
+#define STM_ISR_TIM_TRG_COM_TIM11_POS 26
+#define STM_ISR_TIM1_CC_POS 27
+#define STM_ISR_TIM2_POS 28
+#define STM_ISR_TIM3_POS 29
+#define STM_ISR_TIM4_POS 30
+#define STM_ISR_I2C1_EVT_POS 31
+#define STM_ISR_I2C1_ERR_POS 32
+#define STM_ISR_I2C2_EVT_POS 33
+#define STM_ISR_I2C2_ERR_POS 34
+#define STM_ISR_SPI1_POS 35
+#define STM_ISR_SPI2_POS 36
+#define STM_ISR_USART1_POS 37
+#define STM_ISR_USART2_POS 38
+#define STM_ISR_USART3_POS 39
+#define STM_ISR_EXTI15_10_POS 40
+#define STM_ISR_EXTI17_RTC_ALARM_POS 41
+#define STM_ISR_EXTI18_OTG_FS_WKUP_POS 42
+#define STM_ISR_TIM2_BRK_TIM12_POS 43
+#define STM_ISR_TIM8_UP_TIM13_POS 44
+#define STM_ISR_TIM8_TRG_COM_TIM14_POS 45
+#define STM_ISR_TIM8_CC_POS 46
+#define STM_ISR_DMA1_STREAM7_POS 47
+#define STM_ISR_FSMC_POS 48
+#define STM_ISR_SDIO_POS 49
+#define STM_ISR_TIM5_POS 50
+#define STM_ISR_SPI3_POS 41
+#define STM_ISR_UART4_POS 52
+#define STM_ISR_UART5_POS 53
+#define STM_ISR_TIM6_GLB_IT_DAC1_DAC2_POS 54
+#define STM_ISR_TIM7_POS 55
+#define STM_ISR_DMA2_STREAM0_POS 56
+#define STM_ISR_DMA2_STREAM1_POS 57
+#define STM_ISR_DMA2_STREAM2_POS 58
+#define STM_ISR_DMA2_STREAM3_POS 59
+#define STM_ISR_DMA2_STREAM4_POS 60
+#define STM_ISR_DFSDM1_FLT0_POS 61
+#define STM_ISR_DFSDM1_FLT1_POS 62
+#define STM_ISR_CAN2_TX_POS 63
+#define STM_ISR_CAN2_RX0_POS 64
+#define STM_ISR_CAN2_RX1_POS 65
+#define STM_ISR_CAN2_SCE_POS 66
+#define STM_ISR_OTG_FS_POS 67
+#define STM_ISR_DMA2_STREAM5_POS 68
+#define STM_ISR_DMA2_STREAM6_POS 69
+#define STM_ISR_DMA2_STREAM7_POS 70
+#define STM_ISR_USART6_POS 71
+#define STM_ISR_UART7_POS 82
+#define STM_ISR_UART9_POS 88
+#define STM_ISR_UART10_POS 89
+
+#define STM_ISR_EXTI15_10_POS 40
+
+struct stm_flash {
+ vuint32_t acr;
+ vuint32_t keyr;
+ vuint32_t optkeyr;
+ vuint32_t sr;
+
+ vuint32_t cr;
+ vuint32_t optcr;
+ vuint32_t wrpr;
+};
+
+extern struct stm_flash stm_flash;
+
+#define stm_flash (*((struct stm_flash *) 0x40023c00))
+
+#define STM_FLASH_ACR_DCRST 12
+#define STM_FLASH_ACR_ICRST 11
+#define STM_FLASH_ACR_DCEN 10
+#define STM_FLASH_ACR_ICEN 9
+#define STM_FLASH_ACR_PRFTEN 8
+#define STM_FLASH_ACR_LATENCY 0
+
+struct stm_flash_size {
+ vuint16_t f_size;
+};
+
+extern struct stm_flash_size stm_flash_size;
+
+#define stm_flash_size (*((struct stm_flash_size *) 0x1fff7a22))
+
+struct stm_gpio {
+ vuint32_t moder;
+ vuint32_t otyper;
+ vuint32_t ospeedr;
+ vuint32_t pupdr;
+
+ vuint32_t idr;
+ vuint32_t odr;
+ vuint32_t bsrr;
+ vuint32_t lckr;
+
+ vuint32_t afrl;
+ vuint32_t afrh;
+};
+
+#define STM_MODER_SHIFT(pin) ((pin) << 1)
+#define STM_MODER_MASK 3
+#define STM_MODER_INPUT 0
+#define STM_MODER_OUTPUT 1
+#define STM_MODER_ALTERNATE 2
+#define STM_MODER_ANALOG 3
+
+static inline void
+stm_moder_set(struct stm_gpio *gpio, int pin, vuint32_t value) {
+ gpio->moder = ((gpio->moder &
+ ~(STM_MODER_MASK << STM_MODER_SHIFT(pin))) |
+ value << STM_MODER_SHIFT(pin));
+}
+
+static inline uint32_t
+stm_moder_get(struct stm_gpio *gpio, int pin) {
+ return (gpio->moder >> STM_MODER_SHIFT(pin)) & STM_MODER_MASK;
+}
+
+#define STM_OTYPER_SHIFT(pin) (pin)
+#define STM_OTYPER_MASK 1
+#define STM_OTYPER_PUSH_PULL 0
+#define STM_OTYPER_OPEN_DRAIN 1
+
+static inline void
+stm_otyper_set(struct stm_gpio *gpio, int pin, vuint32_t value) {
+ gpio->otyper = ((gpio->otyper &
+ ~(STM_OTYPER_MASK << STM_OTYPER_SHIFT(pin))) |
+ value << STM_OTYPER_SHIFT(pin));
+}
+
+static inline uint32_t
+stm_otyper_get(struct stm_gpio *gpio, int pin) {
+ return (gpio->otyper >> STM_OTYPER_SHIFT(pin)) & STM_OTYPER_MASK;
+}
+
+#define STM_OSPEEDR_SHIFT(pin) ((pin) << 1)
+#define STM_OSPEEDR_MASK 3
+#define STM_OSPEEDR_LOW 0 /* 2-8MHz */
+#define STM_OSPEEDR_MEDIUM 1 /* 12.5-50MHz */
+#define STM_OSPEEDR_FAST 2 /* 25-100MHz */
+#define STM_OSPEEDR_HIGH 3 /* 50-100MHz */
+
+static inline void
+stm_ospeedr_set(struct stm_gpio *gpio, int pin, vuint32_t value) {
+ gpio->ospeedr = ((gpio->ospeedr &
+ ~(STM_OSPEEDR_MASK << STM_OSPEEDR_SHIFT(pin))) |
+ value << STM_OSPEEDR_SHIFT(pin));
+}
+
+static inline uint32_t
+stm_ospeedr_get(struct stm_gpio *gpio, int pin) {
+ return (gpio->ospeedr >> STM_OSPEEDR_SHIFT(pin)) & STM_OSPEEDR_MASK;
+}
+
+#define STM_PUPDR_SHIFT(pin) ((pin) << 1)
+#define STM_PUPDR_MASK 3
+#define STM_PUPDR_NONE 0
+#define STM_PUPDR_PULL_UP 1
+#define STM_PUPDR_PULL_DOWN 2
+#define STM_PUPDR_RESERVED 3
+
+static inline void
+stm_pupdr_set(struct stm_gpio *gpio, int pin, uint32_t value) {
+ gpio->pupdr = ((gpio->pupdr &
+ ~(STM_PUPDR_MASK << STM_PUPDR_SHIFT(pin))) |
+ value << STM_PUPDR_SHIFT(pin));
+}
+
+static inline uint32_t
+stm_pupdr_get(struct stm_gpio *gpio, int pin) {
+ return (gpio->pupdr >> STM_PUPDR_SHIFT(pin)) & STM_PUPDR_MASK;
+}
+
+#define STM_AFR_SHIFT(pin) ((pin) << 2)
+#define STM_AFR_MASK 0xf
+#define STM_AFR_NONE 0
+#define STM_AFR_AF0 0x0
+#define STM_AFR_AF1 0x1
+#define STM_AFR_AF2 0x2
+#define STM_AFR_AF3 0x3
+#define STM_AFR_AF4 0x4
+#define STM_AFR_AF5 0x5
+#define STM_AFR_AF6 0x6
+#define STM_AFR_AF7 0x7
+#define STM_AFR_AF8 0x8
+#define STM_AFR_AF9 0x9
+#define STM_AFR_AF10 0xa
+#define STM_AFR_AF11 0xb
+#define STM_AFR_AF12 0xc
+#define STM_AFR_AF13 0xd
+#define STM_AFR_AF14 0xe
+#define STM_AFR_AF15 0xf
+
+static inline void
+stm_afr_set(struct stm_gpio *gpio, int pin, uint32_t value) {
+ /*
+ * Set alternate pin mode too
+ */
+ stm_moder_set(gpio, pin, STM_MODER_ALTERNATE);
+ if (pin < 8)
+ gpio->afrl = ((gpio->afrl &
+ ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
+ value << STM_AFR_SHIFT(pin));
+ else {
+ pin -= 8;
+ gpio->afrh = ((gpio->afrh &
+ ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
+ value << STM_AFR_SHIFT(pin));
+ }
+}
+
+static inline uint32_t
+stm_afr_get(struct stm_gpio *gpio, int pin) {
+ if (pin < 8)
+ return (gpio->afrl >> STM_AFR_SHIFT(pin)) & STM_AFR_MASK;
+ else {
+ pin -= 8;
+ return (gpio->afrh >> STM_AFR_SHIFT(pin)) & STM_AFR_MASK;
+ }
+}
+
+static inline void
+stm_gpio_set(struct stm_gpio *gpio, int pin, uint8_t value) {
+ /* Use the bit set/reset register to do this atomically */
+ gpio->bsrr = ((uint32_t) (value ^ 1) << (pin + 16)) | ((uint32_t) value << pin);
+}
+
+static inline uint8_t
+stm_gpio_get(struct stm_gpio *gpio, int pin) {
+ return (gpio->idr >> pin) & 1;
+}
+
+static inline uint16_t
+stm_gpio_get_all(struct stm_gpio *gpio) {
+ return gpio->idr;
+}
+
+/*
+ * We can't define these in registers.ld or our fancy
+ * ao_enable_gpio macro will expand into a huge pile of code
+ * as the compiler won't do correct constant folding and
+ * dead-code elimination
+ */
+
+extern struct stm_gpio stm_gpioa;
+extern struct stm_gpio stm_gpiob;
+extern struct stm_gpio stm_gpioc;
+extern struct stm_gpio stm_gpiod;
+extern struct stm_gpio stm_gpioe;
+extern struct stm_gpio stm_gpiof;
+extern struct stm_gpio stm_gpiog;
+extern struct stm_gpio stm_gpioh;
+
+#define stm_gpioa (*((struct stm_gpio *) 0x40020000))
+#define stm_gpiob (*((struct stm_gpio *) 0x40020400))
+#define stm_gpioc (*((struct stm_gpio *) 0x40020800))
+#define stm_gpiod (*((struct stm_gpio *) 0x40020c00))
+#define stm_gpioe (*((struct stm_gpio *) 0x40021000))
+#define stm_gpiof (*((struct stm_gpio *) 0x40021400))
+#define stm_gpiog (*((struct stm_gpio *) 0x40021800))
+#define stm_gpioh (*((struct stm_gpio *) 0x40021c00))
+
+struct stm_scb {
+ vuint32_t cpuid;
+ vuint32_t icsr;
+ vuint32_t vtor;
+ vuint32_t aircr;
+
+ vuint32_t scr;
+ vuint32_t ccr;
+ vuint32_t shpr1;
+ vuint32_t shpr2;
+
+ vuint32_t shpr3;
+ vuint32_t shcsr;
+ vuint32_t cfsr;
+ vuint32_t hfsr;
+
+ vuint32_t dfsr;
+ vuint32_t mmcar;
+ vuint32_t bcar;
+ vuint32_t afsr;
+
+ vuint32_t id_pfr0;
+ vuint32_t id_pfr1;
+ vuint32_t id_dfr0;
+ vuint32_t id_afr0;
+
+ vuint32_t id_mmfr0;
+ vuint32_t id_mmfr1;
+ vuint32_t id_mmfr2;
+ vuint32_t id_mmfr3;
+
+ vuint32_t id_isar0;
+ vuint32_t id_isar1;
+ vuint32_t id_isar2;
+ vuint32_t id_isar3;
+
+ vuint32_t id_isar4;
+ vuint32_t pad_d74;
+ vuint32_t pad_d78;
+ vuint32_t pad_d7c;
+
+ vuint32_t pad_d80;
+ vuint32_t pad_d84;
+ vuint32_t cpacr;
+ vuint32_t pad_d8c;
+
+ vuint8_t pad_d90[0xf00 - 0xd90];
+
+ vuint32_t stir;
+};
+
+extern struct stm_scb stm_scb;
+
+#define stm_scb (*((struct stm_scb *) 0xe000ed00))
+
+#define STM_SCB_CPACR_CP(n) ((n) <<1)
+#define STM_SCB_CPACR_DENIED 0
+#define STM_SCB_CPACR_PRIVILEGED 1
+#define STM_SCB_CPACR_RESERVED 2
+#define STM_SCB_CPACR_FULL 3
+#define STM_SCB_CPACR_FP0 STM_SCB_CPACR_CP(10)
+#define STM_SCB_CPACR_FP1 STM_SCB_CPACR_CP(11)
+
+#define STM_SCB_AIRCR_VECTKEY 16
+#define STM_SCB_AIRCR_VECTKEY_KEY 0x05fa
+#define STM_SCB_AIRCR_PRIGROUP 8
+#define STM_SCB_AIRCR_SYSRESETREQ 2
+#define STM_SCB_AIRCR_VECTCLRACTIVE 1
+#define STM_SCB_AIRCR_VECTRESET 0
+
+/* The SYSTICK starts at 0xe000e010 */
+
+struct stm_systick {
+ vuint32_t csr;
+ vuint32_t rvr;
+ vuint32_t cvr;
+ vuint32_t calib;
+};
+
+extern struct stm_systick stm_systick;
+
+#define stm_systick (*((struct stm_systick *) 0xe000e010))
+
+#define STM_SYSTICK_CSR_ENABLE 0
+#define STM_SYSTICK_CSR_TICKINT 1
+#define STM_SYSTICK_CSR_CLKSOURCE 2
+#define STM_SYSTICK_CSR_CLKSOURCE_AHB_8 0
+#define STM_SYSTICK_CSR_CLKSOURCE_AHB 1
+#define STM_SYSTICK_CSR_COUNTFLAG 16
+
+#define STM_SYSCFG_EXTICR_PA 0
+#define STM_SYSCFG_EXTICR_PB 1
+#define STM_SYSCFG_EXTICR_PC 2
+#define STM_SYSCFG_EXTICR_PD 3
+#define STM_SYSCFG_EXTICR_PE 4
+#define STM_SYSCFG_EXTICR_PF 5
+#define STM_SYSCFG_EXTICR_PG 6
+#define STM_SYSCFG_EXTICR_PH 7
+
+struct stm_syscfg {
+ vuint32_t memrmp;
+ vuint32_t pmc;
+ vuint32_t exticr[4];
+};
+
+extern struct stm_syscfg stm_syscfg;
+
+#define stm_syscfg (*((struct stm_syscfg *) 0x40013800))
+
+#define STM_SYSCFG_MEMRMP_MEM_MODE 0
+#define STM_SYSCFG_MEMRMP_MEM_MODE_MAIN_FLASH 0
+#define STM_SYSCFG_MEMRMP_MEM_MODE_SYSTEM_FLASH 1
+#define STM_SYSCFG_MEMRMP_MEM_MODE_SRAM 3
+#define STM_SYSCFG_MEMRMP_MEM_MODE_MASK 3
+
+#define STM_SYSCFG_PMC_ADC1DC2 0
+
+static inline void
+stm_exticr_set(struct stm_gpio *gpio, int pin) {
+ uint8_t reg = pin >> 2;
+ uint8_t shift = (pin & 3) << 2;
+ uint8_t val = 0;
+
+ /* Enable SYSCFG */
+ stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_SYSCFGEN);
+
+ if (gpio == &stm_gpioa)
+ val = STM_SYSCFG_EXTICR_PA;
+ else if (gpio == &stm_gpiob)
+ val = STM_SYSCFG_EXTICR_PB;
+ else if (gpio == &stm_gpioc)
+ val = STM_SYSCFG_EXTICR_PC;
+ else if (gpio == &stm_gpiod)
+ val = STM_SYSCFG_EXTICR_PD;
+ else if (gpio == &stm_gpioe)
+ val = STM_SYSCFG_EXTICR_PE;
+ else if (gpio == &stm_gpiof)
+ val = STM_SYSCFG_EXTICR_PF;
+ else if (gpio == &stm_gpiog)
+ val = STM_SYSCFG_EXTICR_PG;
+ else if (gpio == &stm_gpioh)
+ val = STM_SYSCFG_EXTICR_PH;
+
+ stm_syscfg.exticr[reg] = (stm_syscfg.exticr[reg] & ~(0xf << shift)) | val << shift;
+}
+
+struct stm_exti {
+ vuint32_t imr;
+ vuint32_t emr;
+ vuint32_t rtsr;
+ vuint32_t ftsr;
+
+ vuint32_t swier;
+ vuint32_t pr;
+};
+
+extern struct stm_exti stm_exti;
+
+#define stm_exti (*((struct stm_exti *) 0x40013c00))
+
+struct stm_usart {
+ vuint32_t sr; /* status register */
+ vuint32_t dr; /* data register */
+ vuint32_t brr; /* baud rate register */
+ vuint32_t cr1; /* control register 1 */
+
+ vuint32_t cr2; /* control register 2 */
+ vuint32_t cr3; /* control register 3 */
+ vuint32_t gtpr; /* guard time and prescaler */
+};
+
+extern struct stm_usart stm_usart6;
+
+#define stm_usart6 (*((struct stm_usart *) 0x40011400))
+
+#define STM_USART_SR_CTS (9) /* CTS flag */
+#define STM_USART_SR_LBD (8) /* LIN break detection flag */
+#define STM_USART_SR_TXE (7) /* Transmit data register empty */
+#define STM_USART_SR_TC (6) /* Transmission complete */
+#define STM_USART_SR_RXNE (5) /* Read data register not empty */
+#define STM_USART_SR_IDLE (4) /* IDLE line detected */
+#define STM_USART_SR_ORE (3) /* Overrun error */
+#define STM_USART_SR_NF (2) /* Noise detected flag */
+#define STM_USART_SR_FE (1) /* Framing error */
+#define STM_USART_SR_PE (0) /* Parity error */
+
+#define STM_USART_CR1_OVER8 (15) /* Oversampling mode */
+#define STM_USART_CR1_UE (13) /* USART enable */
+#define STM_USART_CR1_M (12) /* Word length */
+#define STM_USART_CR1_WAKE (11) /* Wakeup method */
+#define STM_USART_CR1_PCE (10) /* Parity control enable */
+#define STM_USART_CR1_PS (9) /* Parity selection */
+#define STM_USART_CR1_PEIE (8) /* PE interrupt enable */
+#define STM_USART_CR1_TXEIE (7) /* TXE interrupt enable */
+#define STM_USART_CR1_TCIE (6) /* Transmission complete interrupt enable */
+#define STM_USART_CR1_RXNEIE (5) /* RXNE interrupt enable */
+#define STM_USART_CR1_IDLEIE (4) /* IDLE interrupt enable */
+#define STM_USART_CR1_TE (3) /* Transmitter enable */
+#define STM_USART_CR1_RE (2) /* Receiver enable */
+#define STM_USART_CR1_RWU (1) /* Receiver wakeup */
+#define STM_USART_CR1_SBK (0) /* Send break */
+
+#define STM_USART_CR2_LINEN (14) /* LIN mode enable */
+#define STM_USART_CR2_STOP (12) /* STOP bits */
+#define STM_USART_CR2_STOP_MASK 3
+#define STM_USART_CR2_STOP_1 0
+#define STM_USART_CR2_STOP_0_5 1
+#define STM_USART_CR2_STOP_2 2
+#define STM_USART_CR2_STOP_1_5 3
+
+#define STM_USART_CR2_CLKEN (11) /* Clock enable */
+#define STM_USART_CR2_CPOL (10) /* Clock polarity */
+#define STM_USART_CR2_CPHA (9) /* Clock phase */
+#define STM_USART_CR2_LBCL (8) /* Last bit clock pulse */
+#define STM_USART_CR2_LBDIE (6) /* LIN break detection interrupt enable */
+#define STM_USART_CR2_LBDL (5) /* lin break detection length */
+#define STM_USART_CR2_ADD (0)
+#define STM_USART_CR2_ADD_MASK 0xf
+
+#define STM_USART_CR3_ONEBIT (11) /* One sample bit method enable */
+#define STM_USART_CR3_CTSIE (10) /* CTS interrupt enable */
+#define STM_USART_CR3_CTSE (9) /* CTS enable */
+#define STM_USART_CR3_RTSE (8) /* RTS enable */
+#define STM_USART_CR3_DMAT (7) /* DMA enable transmitter */
+#define STM_USART_CR3_DMAR (6) /* DMA enable receiver */
+#define STM_USART_CR3_SCEN (5) /* Smartcard mode enable */
+#define STM_USART_CR3_NACK (4) /* Smartcard NACK enable */
+#define STM_USART_CR3_HDSEL (3) /* Half-duplex selection */
+#define STM_USART_CR3_IRLP (2) /* IrDA low-power */
+#define STM_USART_CR3_IREN (1) /* IrDA mode enable */
+#define STM_USART_CR3_EIE (0) /* Error interrupt enable */
+
+/* USB */
+struct stm_usb {
+ vuint32_t gotgctl;
+ vuint32_t gotgint;
+ vuint32_t gahbcfg;
+ vuint32_t gusbcfg;
+
+ vuint32_t grstctl;
+ vuint32_t gintsts;
+ vuint32_t gintmsk;
+ vuint32_t grxstsr;
+
+ vuint32_t grxstsp;
+ vuint32_t grxfsiz;
+ vuint32_t dieptxf0;
+ vuint32_t hnptxsts;
+
+ vuint32_t pad_30;
+ vuint32_t pad_34;
+ vuint32_t gccfg;
+ vuint32_t cid;
+
+ vuint32_t pad_40;
+ vuint32_t pad_44;
+ vuint32_t pad_48;
+ vuint32_t ghwcfg3; /* not in docs? */
+
+ vuint32_t pad_50;
+ vuint32_t glpmcfg;
+ vuint32_t pad_58;
+ vuint32_t gdfifocfg; /* not in docs? */
+
+ uint8_t pad_60[0x100 - 0x60];
+
+ vuint32_t hptxfsiz; /* 0x100 */
+ vuint32_t dieptxf[0xf]; /* 0x104 5 in docs? */
+
+ uint8_t pad_140[0x400 - 0x140];
+
+ vuint32_t hcfg;
+ vuint32_t hfir;
+ vuint32_t hfnum;
+ vuint32_t pad_40c;
+
+ vuint32_t hptxsts;
+ vuint32_t haint;
+ vuint32_t haintmsk;
+ vuint32_t pad_41c;
+
+ uint8_t pad_420[0x440-0x420];
+
+ vuint32_t hprt;
+
+ uint8_t pad_444[0x500 - 0x444];
+
+ vuint32_t hcchar0;
+ vuint32_t pad_504;
+ vuint32_t hcint0;
+ vuint32_t hcintmsk0;
+
+ vuint32_t hctsiz0;
+ vuint32_t pad_514;
+ vuint32_t pad_518;
+ vuint32_t pad_51c;
+
+ struct {
+ vuint32_t hcchar;
+ vuint32_t pad_4;
+ vuint32_t hcint;
+ vuint32_t hcintmsk;
+
+ vuint32_t hctsiz;
+ vuint32_t pad_14;
+ vuint32_t pad_18;
+ vuint32_t pad_1c;
+ } h[11];
+
+ uint8_t pad_680[0x800 - 0x680];
+
+ vuint32_t dcfg;
+ vuint32_t dctl;
+ vuint32_t dsts;
+ vuint32_t pad_80c;
+
+ vuint32_t diepmsk;
+ vuint32_t doepmsk;
+ vuint32_t daint;
+ vuint32_t daintmsk;
+
+ vuint32_t pad_820;
+ vuint32_t pad_824;
+ vuint32_t dvbusdis;
+ vuint32_t dvbuspulse;
+
+ vuint32_t pad_830;
+ vuint32_t diepempmsk;
+
+ uint8_t pad_838[0x900 - 0x838];
+
+ struct {
+ vuint32_t diepctl;
+ vuint32_t pad_04;
+ vuint32_t diepint;
+ vuint32_t pad_0c;
+
+ vuint32_t dieptsiz;
+ vuint32_t pad_14;
+ vuint32_t dtxfsts;
+ vuint32_t pad_1c;
+ } diep[6];
+
+ uint8_t pad_9c0[0xb00 - 0x9c0];
+
+ struct {
+ vuint32_t doepctl;
+ vuint32_t pad_04;
+ vuint32_t doepint;
+ vuint32_t pad_0c;
+
+ vuint32_t doeptsiz;
+ vuint32_t pad_14;
+ vuint32_t pad_18;
+ vuint32_t pad_1c;
+ } doep[6];
+
+ uint8_t pad_bc0[0xe00 - 0xbc0];
+
+ vuint32_t pcgcctl;
+
+ uint8_t pad_e04[0x1000 - 0xe04];
+
+ struct {
+ vuint32_t fifo;
+ uint8_t pad_004[0x1000 - 0x004];
+ } dfifo[6];
+};
+
+extern struct stm_usb stm_usb;
+
+#define stm_usb (*((struct stm_usb *) 0x50000000))
+
+#define STM_USB_GOTGCTL_CURMOD 21
+#define STM_USB_GOTGCTL_OTGVER 20
+#define STM_USB_GOTGCTL_BSVLD 19
+#define STM_USB_GOTGCTL_ASVLD 18
+#define STM_USB_GOTGCTL_DBCT 17
+#define STM_USB_GOTGCTL_CIDSTS 16
+#define STM_USB_GOTGCTL_EHEN 12
+#define STM_USB_GOTGCTL_DHNPEN 11
+#define STM_USB_GOTGCTL_HSHNPEN 10
+#define STM_USB_GOTGCTL_HNPRQ 9
+#define STM_USB_GOTGCTL_HNGSCS 8
+#define STM_USB_GOTGCTL_BVALOVAL 7
+#define STM_USB_GOTGCTL_BVALOEN 6
+#define STM_USB_GOTGCTL_AVALOVAL 5
+#define STM_USB_GOTGCTL_AVALOEN 4
+#define STM_USB_GOTGCTL_VBVALOVAL 3
+#define STM_USB_GOTGCTL_VBVALOEN 2
+#define STM_USB_GOTGCTL_SRQ 1
+#define STM_USB_GOTGCTL_SRQSCS 0
+
+#define STM_USB_GOTGINT_IDCHNG 20
+#define STM_USB_GOTGINT_DBCDNE 19
+#define STM_USB_GOTGINT_ADTOCHG 18
+#define STM_USB_GOTGINT_HNGDET 17
+#define STM_USB_GOTGINT_HNSSCHG 9
+#define STM_USB_GOTGINT_SRSSCHG 8
+#define STM_USB_GOTGINT_SEDET 2
+
+#define STM_USB_GAHBCFG_PTXFELVL 8
+#define STM_USB_GAHBCFG_TXFELVL 7
+#define STM_USB_GAHBCFG_GINTMSK 0
+
+#define STM_USB_GUSBCFG_FDMOD 30
+#define STM_USB_GUSBCFG_FHMOD 29
+#define STM_USB_GUSBCFG_TRDT 10
+#define STM_USB_GUSBCFG_TRDT_MASK 0xf
+#define STM_USB_GUSBCFG_HNPCAP 9
+#define STM_USB_GUSBCFG_SRPCAP 8
+#define STM_USB_GUSBCFG_PHYSEL 6
+#define STM_USB_GUSBCFG_TOCAL 0
+#define STM_USB_GUSBCFG_TOCAL_MASK 0x7
+
+#define STM_USB_GRSTCTL_AHBIDL 31
+#define STM_USB_GRSTCTL_TXFNUM 6
+#define STM_USB_GRSTCTL_TXFNUM_ALL 0x10
+#define STM_USB_GRSTCTL_TXFNUM_MASK 0x1f
+#define STM_USB_GRSTCTL_TXFFLSH 5
+#define STM_USB_GRSTCTL_RXFFLSH 4
+#define STM_USB_GRSTCTL_FCRST 2
+#define STM_USB_GRSTCTL_PSRST 1
+#define STM_USB_GRSTCTL_CSRST 0
+
+#define STM_USB_GINTSTS_WKUPINT 31
+#define STM_USB_GINTSTS_SRQINT 30
+#define STM_USB_GINTSTS_DISCINT 29
+#define STM_USB_GINTSTS_CIDSCHG 28
+#define STM_USB_GINTSTS_LPMINT 27
+#define STM_USB_GINTSTS_PTXFE 26
+#define STM_USB_GINTSTS_HCINT 25
+#define STM_USB_GINTSTS_HPRTINT 24
+#define STM_USB_GINTSTS_RSTDET 23
+#define STM_USB_GINTSTS_IPXFER 21
+#define STM_USB_GINTSTS_IISOIXFR 20
+#define STM_USB_GINTSTS_OEPINT 19
+#define STM_USB_GINTSTS_IEPINT 18
+#define STM_USB_GINTSTS_EOPF 15
+#define STM_USB_GINTSTS_ISOODRP 14
+#define STM_USB_GINTSTS_ENUMDNE 13
+#define STM_USB_GINTSTS_USBRST 12
+#define STM_USB_GINTSTS_USBSUSP 11
+#define STM_USB_GINTSTS_ESUSP 10
+#define STM_USB_GINTSTS_GONAKEFF 7
+#define STM_USB_GINTSTS_GINAKEFF 6
+#define STM_USB_GINTSTS_NPTXFE 5
+#define STM_USB_GINTSTS_RXFLVL 4
+#define STM_USB_GINTSTS_SOF 3
+#define STM_USB_GINTSTS_OTGINT 2
+#define STM_USB_GINTSTS_MMIS 1
+#define STM_USB_GINTSTS_CMOD 0
+
+#define STM_USB_GINTMSK_WUIM 31
+#define STM_USB_GINTMSK_SRQIM 30
+#define STM_USB_GINTMSK_DISCINT 29
+#define STM_USB_GINTMSK_CIDSCHGM 28
+#define STM_USB_GINTMSK_LPMINTM 27
+#define STM_USB_GINTMSK_PTXFEM 26
+#define STM_USB_GINTMSK_HCIM 25
+#define STM_USB_GINTMSK_PRTIM 24
+#define STM_USB_GINTMSK_RSTDETM 23
+#define STM_USB_GINTMSK_IPXFERM 21 /* host mode */
+#define STM_USB_GINTMSK_IISOOXFRM 21 /* device mode */
+#define STM_USB_GINTMSK_IISOIXFRM 20
+#define STM_USB_GINTMSK_OEPINT 19
+#define STM_USB_GINTMSK_IEPINT 18
+#define STM_USB_GINTMSK_EOPFM 15
+#define STM_USB_GINTMSK_ISOODRPM 14
+#define STM_USB_GINTMSK_ENUMDNEM 13
+#define STM_USB_GINTMSK_USBRST 12
+#define STM_USB_GINTMSK_USBSUSPM 11
+#define STM_USB_GINTMSK_ESUSPM 10
+#define STM_USB_GINTMSK_GONAKEFFM 7
+#define STM_USB_GINTMSK_GINAKEFFM 6
+#define STM_USB_GINTMSK_NPTXFEM 5
+#define STM_USB_GINTMSK_RXFLVLM 4
+#define STM_USB_GINTMSK_SOFM 3
+#define STM_USB_GINTMSK_OTGINT 2
+#define STM_USB_GINTMSK_MMISM 1
+
+#define STM_USB_GRXSTSP_STSPHST 27
+#define STM_USB_GRXSTSP_FRMNUM 21
+#define STM_USB_GRXSTSP_FRMNUM_MASK 0xf
+#define STM_USB_GRXSTSP_PKTSTS 17
+#define STM_USB_GRXSTSP_PKTSTS_NAK 1
+#define STM_USB_GRXSTSP_PKTSTS_OUT_DATA 2
+#define STM_USB_GRXSTSP_PKTSTS_OUT_COMPLETE 3
+#define STM_USB_GRXSTSP_PKTSTS_SETUP_COMPLETE 4
+#define STM_USB_GRXSTSP_PKTSTS_SETUP_DATA 5
+#define STM_USB_GRXSTSP_PKTSTS_MASK 0xf
+#define STM_USB_GRXSTSP_DPID 15
+#define STM_USB_GRXSTSP_DPID_MASK 3
+#define STM_USB_GRXSTSP_BCNT 4
+#define STM_USB_GRXSTSP_BCNT 4
+#define STM_USB_GRXSTSP_BCNT_MASK 0x3ff
+#define STM_USB_GRXSTSP_EPNUM 0
+#define STM_USB_GRXSTSP_EPNUM_MASK 0xf
+
+#define STM_USB_GRXFSIZ_RXFD 0
+#define STM_USB_GRXFSIZ_RXFD_MASK 0xffff
+
+#define STM_USB_GCCFG_VBDEN 21
+#define STM_USB_GCCFG_SDEN 20
+#define STM_USB_GCCFG_PDEN 19
+#define STM_USB_GCCFG_DCDEN 18
+#define STM_USB_GCCFG_BCDEN 17
+#define STM_USB_GCCFG_PWRDWN 16
+#define STM_USB_GCCFG_PS2DET 3
+#define STM_USB_GCCFG_SDET 2
+#define STM_USB_GCCFG_PDET 1
+#define STM_USB_GCCFG_DCDET 0
+
+#define STM_USB_DIEPTXF0_TX0FD 16
+#define STM_USB_DIEPTXF0_TX0FSA 0
+
+#define STM_USB_DCFG_ERRATIM 15
+#define STM_USB_DCFG_PFIVL 11
+#define STM_USB_DCFG_PFIVL_80 0
+#define STM_USB_DCFG_PFIVL_85 1
+#define STM_USB_DCFG_PFIVL_90 2
+#define STM_USB_DCFG_PFIVL_95 3
+#define STM_USB_DCFG_PFIVL_MASK 3
+#define STM_USB_DCFG_DAD 4
+#define STM_USB_DCFG_DAD_MASK 0x7f
+#define STM_USB_DCFG_NZLSOHSK 2
+#define STM_USB_DCFG_DSPD 0
+#define STM_USB_DCFG_DSPD_FULL_SPEED 3
+#define STM_USB_DCFG_DSPD_MASK 3
+#define STM_USB_DCFG_
+#define STM_USB_DCFG_
+#define STM_USB_DCFG_
+#define STM_USB_DCFG_
+#define STM_USB_DCFG_
+#define STM_USB_DCFG_
+#define STM_USB_DCFG_
+
+#define STM_USB_DCTL_DSBESLRJCT 18
+#define STM_USB_DCTL_POPRGDNE 11
+#define STM_USB_DCTL_CGONAK 10
+#define STM_USB_DCTL_SGONAK 9
+#define STM_USB_DCTL_CGINAK 8
+#define STM_USB_DCTL_SGINAK 7
+#define STM_USB_DCTL_TCTL 4
+#define STM_USB_DCTL_GONSTS 3
+#define STM_USB_DCTL_GINSTS 2
+#define STM_USB_DCTL_SDIS 1
+#define STM_USB_DCTL_RWUSIG 0
+
+#define STM_USB_DSTS_DEVLNSTS 22
+#define STM_USB_DSTS_DEVLNSTS_MASK 0x3
+#define STM_USB_DSTS_FNSOF 8
+#define STM_USB_DSTS_FNSOF_MASK 0x3fff
+#define STM_USB_DSTS_EERR 3
+#define STM_USB_DSTS_ENUMSPD 1
+#define STM_USB_DSTS_ENUMSPD_MASK 3
+#define STM_USB_DSTS_SUSPSTS 0
+
+#define STM_USB_DIEPMSK_NAKM 13
+#define STM_USB_DIEPMSK_TXFURM 8
+#define STM_USB_DIEPMSK_INEPNEM 6
+#define STM_USB_DIEPMSK_INEPNMM 5
+#define STM_USB_DIEPMSK_ITTXFEMSK 4
+#define STM_USB_DIEPMSK_TOM 3
+#define STM_USB_DIEPMSK_EPDM 1
+#define STM_USB_DIEPMSK_XFRCM 0
+
+#define STM_USB_DOEPMSK_NYETMSK 14
+#define STM_USB_DOEPMSK_NAKMSK 13
+#define STM_USB_DOEPMSK_BERRM 12
+#define STM_USB_DOEPMSK_OUTPKTERRM 8
+#define STM_USB_DOEPMSK_STSPHSRXM 5
+#define STM_USB_DOEPMSK_OTEPDM 4
+#define STM_USB_DOEPMSK_STUPM 3
+#define STM_USB_DOEPMSK_EPDM 1
+#define STM_USB_DOEPMSK_XFRCM 0
+
+#define STM_USB_DAINT_OEPINT 16
+#define STM_USB_DAINT_OEPINT_MASK 0xffff
+#define STM_USB_DAINT_IEPINT 16
+#define STM_USB_DAINT_IEPINT_MASK 0xffff
+
+#define STM_USB_DAINTMSK_OEPM 16
+#define STM_USB_DAINTMSK_OEPM_MASK 0xffff
+#define STM_USB_DAINTMSK_IEPM 0
+#define STM_USB_DAINTMSK_IEPM_MASK 0xffff
+
+#define STM_USB_DIEPCTL_EPENA 31
+#define STM_USB_DIEPCTL_EPDIS 30
+#define STM_USB_DIEPCTL_SNAK 27
+#define STM_USB_DIEPCTL_CNAK 26
+#define STM_USB_DIEPCTL_TXFNUM 22
+#define STM_USB_DIEPCTL_TXFNUM_MASK 0xf
+#define STM_USB_DIEPCTL_STALL 21
+#define STM_USB_DIEPCTL_EPTYP 18
+#define STM_USB_DIEPCTL_EPTYP_CONTROL 0
+#define STM_USB_DIEPCTL_EPTYP_ISOCHRONOUS 1
+#define STM_USB_DIEPCTL_EPTYP_BULK 2
+#define STM_USB_DIEPCTL_EPTYP_INTERRUPT 3
+#define STM_USB_DIEPCTL_EPTYP_MASK 3
+#define STM_USB_DIEPCTL_NAKSTS 17
+#define STM_USB_DIEPCTL_EONUM 16
+#define STM_USB_DIEPCTL_USBAEP 15
+#define STM_USB_DIEPCTL_MPSIZ 0
+#define STM_USB_DIEPCTL_MPSIZ0_64 0
+#define STM_USB_DIEPCTL_MPSIZ0_32 1
+#define STM_USB_DIEPCTL_MPSIZ0_16 2
+#define STM_USB_DIEPCTL_MPSIZ0_8 3
+#define STM_USB_DIEPCTL_MPSIZ0_MASK 3
+#define STM_USB_DIEPCTL_MPSIZ_MASK 0x7f
+
+#define STM_USB_DIEPINT_NAK 13
+#define STM_USB_DIEPINT_PKTDRPSTS 11
+#define STM_USB_DIEPINT_TXFIFOUDRN 8
+#define STM_USB_DIEPINT_TXFE 7
+#define STM_USB_DIEPINT_INEPNE 6
+#define STM_USB_DIEPINT_INEPNM 5
+#define STM_USB_DIEPINT_ITTXFE 4
+#define STM_USB_DIEPINT_TOC 3
+#define STM_USB_DIEPINT_EPDISD 1
+#define STM_USB_DIEPINT_XFRC 0
+
+#define STM_USB_DIEPTSIZ_MCNT 29
+#define STM_USB_DIEPTSIZ_MCNT_MASK 3
+#define STM_USB_DIEPTSIZ_PKTCNT 19
+#define STM_USB_DIEPTSIZ_PKTCNT0_MASK 3
+#define STM_USB_DIEPTSIZ_PKTCNT_MASK 0x3ff
+#define STM_USB_DIEPTSIZ_XFRSIZ 0
+#define STM_USB_DIEPTSIZ_XFRSIZ0_MASK 0x7f
+#define STM_USB_DIEPTSIZ_XFRSIZ_MASK 0x7ffff
+
+#define STM_USB_DOEPCTL_EPENA 31
+#define STM_USB_DOEPCTL_EPDIS 30
+#define STM_USB_DOEPCTL_SNAK 27
+#define STM_USB_DOEPCTL_CNAK 26
+#define STM_USB_DOEPCTL_STALL 21
+#define STM_USB_DOEPCTL_SNPM 20
+#define STM_USB_DOEPCTL_EPTYP 18
+#define STM_USB_DOEPCTL_EPTYP_CONTROL 0
+#define STM_USB_DOEPCTL_EPTYP_ISOCHRONOUS 1
+#define STM_USB_DOEPCTL_EPTYP_BULK 2
+#define STM_USB_DOEPCTL_EPTYP_INTERRUPT 3
+#define STM_USB_DOEPCTL_EPTYP_MASK 3
+#define STM_USB_DOEPCTL_NAKSTS 17
+#define STM_USB_DOEPCTL_USBAEP 15
+#define STM_USB_DOEPCTL_MPSIZ 0
+#define STM_USB_DOEPCTL_MPSIZ0_64 0
+#define STM_USB_DOEPCTL_MPSIZ0_32 1
+#define STM_USB_DOEPCTL_MPSIZ0_16 2
+#define STM_USB_DOEPCTL_MPSIZ0_8 3
+#define STM_USB_DOEPCTL_MPSIZ0_MASK 3
+
+#define STM_USB_DOEPINT_NAK 13
+#define STM_USB_DOEPINT_BERR 12
+#define STM_USB_DOEPINT_OUTPKTERR 8
+#define STM_USB_DOEPINT_STSPHSRX 5
+#define STM_USB_DOEPINT_OTEPDIS 4
+#define STM_USB_DOEPINT_STUP 3
+#define STM_USB_DOEPINT_EPDISD 1
+#define STM_USB_DOEPINT_XFRC 0
+
+#define STM_USB_DOEPTSIZ_STUPCNT 29
+#define STM_USB_DOEPTSIZ_STUPCNT_MASK 3
+#define STM_USB_DOEPTSIZ_PKTCNT 19
+#define STM_USB_DOEPTSIZ_XFRSIZ 0
+#define STM_USB_DOEPTSIZ_XFRSIZ_MASK 0x7f
+
+/* Errata 2.1.5
+
+ Delay after an RCC peripheral clock enabling
+
+ Description
+
+ A delay between an RCC peripheral clock enable and the effective
+ peripheral enabling should be taken into account in order to manage
+ the peripheral read/write to registers.
+
+ This delay depends on the peripheral’s mapping:
+
+ • If the peripheral is mapped on AHB: the delay should be equal to
+ 2 AHB cycles.
+
+ • If the peripheral is mapped on APB: the delay should be equal to
+ 1 + (AHB/APB prescaler) cycles.
+
+ Workarounds
+
+ 1. Use the DSB instruction to stall the Cortex-M4 CPU pipeline
+ until the instruction is completed.
+
+ 2. Insert “n” NOPs between the RCC enable bit write and the
+ peripheral register writes
+*/
+
+static inline void
+stm32f4_set_rcc(uint32_t *rcc, uint32_t value)
+{
+ *rcc = value;
+ asm("dsb");
+}
+
+/* Errata 2.1.8
+
+ In some specific cases, DMA2 data corruption occurs when managing
+ AHB and APB2 peripherals in a concurrent way
+
+ Description
+
+ When the DMA2 is managing concurrent requests of AHB and APB2
+ peripherals, the transfer on the AHB could be performed several
+ times.
+
+ Impacted peripheral are:
+
+ • Quad-SPI: indirect mode read and write transfers
+
+ • FSMC: read and write operation with external device having FIFO
+
+ • GPIO: DMA2 transfers to GPIO registers (in memory-to-peripheral
+ transfer mode).The transfers from GPIOs register are not
+ impacted.
+
+
+ The data corruption is due to multiple DMA2 accesses over AHB
+ peripheral port impacting peripherals embedding a FIFO.
+
+ For transfer to the internal SRAM through the DMA2 AHB peripheral
+ port the accesses could be performed several times but without data
+ corruptions in cases of concurrent requests.
+
+ Workaround
+
+ • The DMA2 AHB memory port must be used when reading/writing
+ from/to Quad-SPI and FSMC instead of DMA2 AHB default peripheral
+ port.
+
+ • The DMA2 AHB memory port must be used when writing to GPIOs
+ instead of DMA2 AHB default peripheral port.
+
+ Refer to application note AN4031 section “Take benefits of DMA2
+ controller and system architecture flexibility” for more details
+ about DMA controller feature.
+
+*/
+
+
+
+#endif /* _STM32F4_H_ */
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 }
};
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 <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.
- */
-
-#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 <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"
-#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/teleballoon-v2.0/Makefile b/src/teleballoon-v2.0/Makefile
index 28588778..ddbfaf5f 100644
--- a/src/teleballoon-v2.0/Makefile
+++ b/src/teleballoon-v2.0/Makefile
@@ -38,9 +38,6 @@ INC = \
#STACK_GUARD=ao_mpu_stm.c
#STACK_GUARD_DEF=-DHAS_STACK_GUARD=1
-MATH_SRC=\
- ef_log.c
-
ALTOS_SRC = \
ao_boot_chain.c \
ao_interrupt.c \
@@ -49,7 +46,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
@@ -88,7 +85,6 @@ ALTOS_SRC = \
ao_packet.c \
ao_companion.c \
ao_aprs.c \
- $(MATH_SRC) \
$(PROFILE) \
$(SAMPLE_PROFILE) \
$(STACK_GUARD)
diff --git a/src/teleballoon-v2.0/ao_pins.h b/src/teleballoon-v2.0/ao_pins.h
index d98e85d7..cb0ec838 100644
--- a/src/teleballoon-v2.0/ao_pins.h
+++ b/src/teleballoon-v2.0/ao_pins.h
@@ -74,6 +74,9 @@
#define HAS_BEEP 1
#define HAS_BATTERY_REPORT 1
#define BEEPER_CHANNEL 4
+#define BEEPER_TIMER 3
+#define BEEPER_PORT (&stm_gpiob)
+#define BEEPER_PIN 1
#define HAS_RADIO 1
#define HAS_TELEMETRY 1
#define HAS_APRS 1
@@ -142,9 +145,6 @@
#define AO_IGNITER_MAIN_PORT (&stm_gpioa)
#define AO_IGNITER_MAIN_PIN 9
-#define AO_IGNITER_SET_DROGUE(v) stm_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v)
-#define AO_IGNITER_SET_MAIN(v) stm_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, v)
-
/*
* ADC
*/
diff --git a/src/teleballoon-v2.0/ao_teleballoon.c b/src/teleballoon-v2.0/ao_teleballoon.c
index 2432c272..94393da0 100644
--- a/src/teleballoon-v2.0/ao_teleballoon.c
+++ b/src/teleballoon-v2.0/ao_teleballoon.c
@@ -43,8 +43,8 @@ main(void)
ao_task_init();
ao_serial_init();
- ao_led_init(LEDS_AVAILABLE);
- ao_led_on(AO_LED_RED);
+ ao_led_init();
+ ao_led_on(LEDS_AVAILABLE);
ao_timer_init();
ao_spi_init();
@@ -77,7 +77,7 @@ main(void)
ao_gps_report_metrum_init();
ao_telemetry_init();
ao_radio_init();
- ao_packet_slave_init(FALSE);
+ ao_packet_slave_init(false);
ao_companion_init();
ao_config_init();
@@ -87,7 +87,8 @@ main(void)
#if HAS_SAMPLE_PROFILE
ao_sample_profile_init();
#endif
-
+ ao_led_off(LEDS_AVAILABLE);
+
ao_start_scheduler();
return 0;
}
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 <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.
- */
-
-#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 <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"
-
-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/telebt-v3.0/Makefile b/src/telebt-v3.0/Makefile
index 4636c046..9892ad5f 100644
--- a/src/telebt-v3.0/Makefile
+++ b/src/telebt-v3.0/Makefile
@@ -37,7 +37,7 @@ ALTOS_SRC = \
ao_config.c \
ao_data.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/telebt-v3.0/ao_telebt.c b/src/telebt-v3.0/ao_telebt.c
index 63633c90..3d48b6b9 100644
--- a/src/telebt-v3.0/ao_telebt.c
+++ b/src/telebt-v3.0/ao_telebt.c
@@ -34,7 +34,7 @@ main(void)
ao_clock_init();
ao_task_init();
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
ao_led_on(LEDS_AVAILABLE);
ao_timer_init();
diff --git a/src/telebt-v4.0/Makefile b/src/telebt-v4.0/Makefile
index 38ac7513..4ad3287d 100644
--- a/src/telebt-v4.0/Makefile
+++ b/src/telebt-v4.0/Makefile
@@ -27,7 +27,7 @@ ALTOS_SRC = \
ao_config.c \
ao_data.c \
ao_task.c \
- ao_led.c \
+ ao_led_stmf0.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/telebt-v4.0/ao_telebt.c b/src/telebt-v4.0/ao_telebt.c
index 953ec4bc..7c3c6e2a 100644
--- a/src/telebt-v4.0/ao_telebt.c
+++ b/src/telebt-v4.0/ao_telebt.c
@@ -29,7 +29,7 @@ main(void)
ao_clock_init();
ao_task_init();
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
ao_led_on(LEDS_AVAILABLE);
ao_timer_init();
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/teledongle-v1.8/.gitignore b/src/teledongle-v1.8/.gitignore
deleted file mode 100644
index 9a30cbb6..00000000
--- a/src/teledongle-v1.8/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-ao_product.h
-teledongle-*.elf
diff --git a/src/teledongle-v1.8/Makefile b/src/teledongle-v1.8/Makefile
deleted file mode 100644
index 6c05ce9f..00000000
--- a/src/teledongle-v1.8/Makefile
+++ /dev/null
@@ -1,88 +0,0 @@
-#
-# AltOS build
-#
-#
-
-include ../stm/Makefile.defs
-
-INC = \
- ao.h \
- ao_arch.h \
- ao_arch_funcs.h \
- ao_boot.h \
- ao_pins.h \
- ao_product.h \
- ao_task.h \
- ao_whiten.h \
- stm32l.h \
- ao_cc1200.h \
- ao_cc1200_CC1200.h \
- Makefile
-
-#PROFILE=ao_profile.c
-#PROFILE_DEF=-DAO_PROFILE=1
-
-#SAMPLE_PROFILE=ao_sample_profile.c \
-# ao_sample_profile_timer.c
-#SAMPLE_PROFILE_DEF=-DHAS_SAMPLE_PROFILE=1
-
-#STACK_GUARD=ao_mpu_stm.c
-#STACK_GUARD_DEF=-DHAS_STACK_GUARD=1
-
-ALTOS_SRC = \
- ao_boot_chain.c \
- ao_interrupt.c \
- ao_product.c \
- ao_romconfig.c \
- ao_cc1200.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_usb_stm.c \
- ao_exti_stm.c \
- ao_send_packet.c \
- ao_eeprom_stm.c \
- ao_monitor.c \
- ao_packet_master.c \
- ao_packet.c
-
-PRODUCT=TeleDongle-v1.8
-PRODUCT_DEF=-DTELEDONGLE
-IDPRODUCT=0x000c
-
-CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) $(PROFILE_DEF) $(SAMPLE_PROFILE_DEF) $(STACK_GUARD_DEF) -Os -g
-
-PROGNAME=teledongle-v1.8
-PROG=$(PROGNAME)-$(VERSION).elf
-HEX=$(PROGNAME)-$(VERSION).ihx
-
-SRC=$(ALTOS_SRC) ao_teledongle.c
-OBJ=$(SRC:.c=.o)
-
-all: $(PROG) $(HEX)
-
-$(PROG): Makefile $(OBJ) altos.ld
- $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS)
-
-$(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/teledongle-v1.8/ao_pins.h b/src/teledongle-v1.8/ao_pins.h
deleted file mode 100644
index 72bea368..00000000
--- a/src/teledongle-v1.8/ao_pins.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright © 2012 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.
- */
-
-/* Using TeleMetrum v1.9 board */
-
-#ifndef _AO_PINS_H_
-#define _AO_PINS_H_
-
-#define HAS_TASK_QUEUE 1
-
-/* 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_SERIAL_1 0
-#define USE_SERIAL_1_STDIN 0
-#define SERIAL_1_PB6_PB7 0
-#define SERIAL_1_PA9_PA10 0
-
-#define HAS_SERIAL_2 0
-#define USE_SERIAL_2_STDIN 0
-#define SERIAL_2_PA2_PA3 0
-#define SERIAL_2_PD5_PD6 0
-
-#define HAS_SERIAL_3 0
-#define USE_SERIAL_3_STDIN 0
-#define SERIAL_3_PB10_PB11 0
-#define SERIAL_3_PC10_PC11 0
-#define SERIAL_3_PD8_PD9 0
-
-#define HAS_EEPROM 1
-#define USE_INTERNAL_FLASH 1
-#define USE_STORAGE_CONFIG 0
-#define USE_EEPROM_CONFIG 1
-#define HAS_USB 1
-#define HAS_BEEP 0
-#define HAS_RADIO 1
-#define HAS_TELEMETRY 0
-#define HAS_RSSI 0
-
-#define HAS_SPI_1 0
-#define SPI_1_PA5_PA6_PA7 0 /* Barometer */
-#define SPI_1_PB3_PB4_PB5 0
-#define SPI_1_PE13_PE14_PE15 0 /* Accelerometer */
-
-#define HAS_SPI_2 1
-#define SPI_2_PB13_PB14_PB15 1 /* Radio */
-#define SPI_2_PD1_PD3_PD4 0
-#define SPI_2_OSPEEDR STM_OSPEEDR_10MHz
-
-#define SPI_2_PORT (&stm_gpiob)
-#define SPI_2_SCK_PIN 13
-#define SPI_2_MISO_PIN 14
-#define SPI_2_MOSI_PIN 15
-
-#define PACKET_HAS_SLAVE 0
-#define PACKET_HAS_MASTER 1
-
-#define LOW_LEVEL_DEBUG 0
-
-#define LED_PORT_0_ENABLE STM_RCC_AHBENR_GPIOCEN
-#define LED_PORT_0 (&stm_gpioc)
-#define LED_PORT_0_MASK (0xffff)
-#define LED_PORT_0_SHIFT 0
-#define LED_PIN_RED 8
-#define LED_PIN_GREEN 9
-#define AO_LED_RED (1 << LED_PIN_RED)
-#define AO_LED_GREEN (1 << LED_PIN_GREEN)
-
-#define LEDS_AVAILABLE (AO_LED_RED | AO_LED_GREEN)
-
-#define HAS_GPS 0
-#define HAS_FLIGHT 0
-#define HAS_ADC 0
-#define HAS_LOG 0
-
-/*
- * Telemetry monitoring
- */
-#define HAS_MONITOR 1
-#define LEGACY_MONITOR 0
-#define HAS_MONITOR_PUT 1
-#define AO_MONITOR_LED AO_LED_GREEN
-#define AO_MONITOR_BAD AO_LED_RED
-
-/*
- * Radio (cc1200)
- */
-
-/* gets pretty close to 434.550 */
-
-#define AO_RADIO_CAL_DEFAULT 5695733
-
-#define AO_FEC_DEBUG 0
-#define AO_CC1200_SPI_CS_PORT (&stm_gpioc)
-#define AO_CC1200_SPI_CS_PIN 5
-#define AO_CC1200_SPI_BUS AO_SPI_2_PB13_PB14_PB15
-#define AO_CC1200_SPI stm_spi2
-
-#define AO_CC1200_INT_PORT (&stm_gpioe)
-#define AO_CC1200_INT_PIN 1
-
-#define AO_CC1200_INT_GPIO 2
-#define AO_CC1200_INT_GPIO_IOCFG CC1200_IOCFG2
-
-/*
- * Profiling Viterbi decoding
- */
-
-#ifndef AO_PROFILE
-#define AO_PROFILE 0
-#endif
-
-#endif /* _AO_PINS_H_ */
diff --git a/src/teledongle-v1.8/ao_teledongle.c b/src/teledongle-v1.8/ao_teledongle.c
deleted file mode 100644
index 7fd6acdb..00000000
--- a/src/teledongle-v1.8/ao_teledongle.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright © 2012 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>
-#include <ao_exti.h>
-#include <ao_packet.h>
-#include <ao_send_packet.h>
-
-int
-main(void)
-{
- ao_clock_init();
-
-#if HAS_STACK_GUARD
- ao_mpu_init();
-#endif
-
- ao_task_init();
- ao_led_init(LEDS_AVAILABLE);
- ao_led_on(AO_LED_RED);
- ao_timer_init();
-
- ao_spi_init();
- ao_dma_init();
- ao_exti_init();
-
- ao_cmd_init();
-
- ao_usb_init();
- ao_radio_init();
- ao_monitor_init();
- ao_packet_master_init();
- ao_send_packet_init();
-
- ao_config_init();
-
- ao_led_off(AO_LED_RED);
- ao_start_scheduler();
- return 0;
-}
diff --git a/src/teledongle-v3.0/ao_teledongle.c b/src/teledongle-v3.0/ao_teledongle.c
index 32899af2..69abea6e 100644
--- a/src/teledongle-v3.0/ao_teledongle.c
+++ b/src/teledongle-v3.0/ao_teledongle.c
@@ -31,7 +31,7 @@ main(void)
#endif
ao_task_init();
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
ao_led_on(LEDS_AVAILABLE);
ao_timer_init();
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 <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.
- */
-
-#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 <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>
-#include <ao_pad.h>
-#include <ao_74hc497.h>
-#include <ao_radio_cmac_cmd.h>
-
-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 <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.
- */
-
-#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 <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>
-#include <ao_pad.h>
-#include <ao_74hc165.h>
-#include <ao_radio_cmac_cmd.h>
-
-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/telefireeight-v1.0/ao_pins.h b/src/telefireeight-v1.0/ao_pins.h
index 15e1fa11..c15e06bf 100644
--- a/src/telefireeight-v1.0/ao_pins.h
+++ b/src/telefireeight-v1.0/ao_pins.h
@@ -25,6 +25,10 @@
#define HAS_FLIGHT 0
#define HAS_USB 1
#define HAS_BEEP 0
+#define BEEPER_TIMER 3
+#define BEEPER_CHANNEL 1
+#define BEEPER_PORT (&stm_gpioc)
+#define BEEPER_PIN 6
#define HAS_GPS 0
#define HAS_SERIAL_1 0
#define HAS_ADC 1
@@ -107,7 +111,7 @@
#define AO_CC1200_INT_GPIO 2
#define AO_CC1200_INT_GPIO_IOCFG CC1200_IOCFG2
-#define LED_PER_LED 1
+#define HAS_LED 1
#define LED_TYPE uint16_t
/* Continuity leds 1-8 */
@@ -128,14 +132,8 @@
#define LED_7_PORT (&stm_gpioa)
#define LED_7_PIN 10
-#define LED_PIN_CONTINUITY_0 0
-#define LED_PIN_CONTINUITY_1 1
-#define LED_PIN_CONTINUITY_2 2
-#define LED_PIN_CONTINUITY_3 3
-#define LED_PIN_CONTINUITY_4 4
-#define LED_PIN_CONTINUITY_5 5
-#define LED_PIN_CONTINUITY_6 6
-#define LED_PIN_CONTINUITY_7 7
+#define AO_LED_CONTINUITY(c) (1 << (c))
+#define AO_LED_CONTINUITY_MASK (0xff)
/* ARM */
#define LED_8_PORT (&stm_gpioe)
@@ -151,19 +149,10 @@
#define LED_11_PORT (&stm_gpioe)
#define LED_11_PIN 6
-#define LED_PIN_GREEN 9
-#define LED_PIN_AMBER 10
-#define LED_PIN_RED 11
-
-#define AO_LED_CONTINUITY(c) (1 << (c))
-#define AO_LED_CONTINUITY_MASK (0xff)
-
-#define AO_LED_ARMED (1 << LED_PIN_ARMED)
-#define AO_LED_GREEN (1 << LED_PIN_GREEN)
-#define AO_LED_AMBER (1 << LED_PIN_AMBER)
-#define AO_LED_RED (1 << LED_PIN_RED)
-
-#define LEDS_AVAILABLE (0xfff)
+#define AO_LED_ARMED AO_LED_8
+#define AO_LED_GREEN AO_LED_9
+#define AO_LED_AMBER AO_LED_10
+#define AO_LED_RED AO_LED_11
/* Alarm A */
#define AO_SIREN
diff --git a/src/telefireeight-v1.0/ao_telefireeight.c b/src/telefireeight-v1.0/ao_telefireeight.c
index bdcf3213..89541a02 100644
--- a/src/telefireeight-v1.0/ao_telefireeight.c
+++ b/src/telefireeight-v1.0/ao_telefireeight.c
@@ -26,7 +26,8 @@ main(void)
{
ao_clock_init();
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
+ ao_led_on(LEDS_AVAILABLE);
ao_task_init();
@@ -51,5 +52,7 @@ main(void)
// ao_radio_cmac_cmd_init();
+ ao_led_off(LEDS_AVAILABLE);
+
ao_start_scheduler();
}
diff --git a/src/telefireone-v1.0/Makefile b/src/telefireone-v1.0/Makefile
index 53f088cb..773c8f69 100644
--- a/src/telefireone-v1.0/Makefile
+++ b/src/telefireone-v1.0/Makefile
@@ -34,7 +34,7 @@ ALTOS_SRC = \
ao_data.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/telefireone-v1.0/ao_pins.h b/src/telefireone-v1.0/ao_pins.h
index d36d9d82..15b158ef 100644
--- a/src/telefireone-v1.0/ao_pins.h
+++ b/src/telefireone-v1.0/ao_pins.h
@@ -27,6 +27,7 @@
#define HAS_USB 1
#define HAS_BEEP 1
#define BEEPER_CHANNEL 4
+#define BEEPER_TIMER 3
#define HAS_GPS 0
#define HAS_SERIAL_1 0
#define HAS_ADC 1
diff --git a/src/telefireone-v1.0/ao_telefireone.c b/src/telefireone-v1.0/ao_telefireone.c
index 115b3e91..6506235a 100644
--- a/src/telefireone-v1.0/ao_telefireone.c
+++ b/src/telefireone-v1.0/ao_telefireone.c
@@ -26,12 +26,11 @@
static void
set_logging(void)
{
- ao_cmd_hex();
- ao_log_running = ao_cmd_lex_i;
+ ao_log_running = ao_cmd_hex();
ao_wakeup(&ao_log_running);
}
-__code struct ao_cmds ao_firetwo_cmds[] = {
+const struct ao_cmds ao_firetwo_cmds[] = {
{ set_logging, "L <0 off, 1 on>\0Log sensors to flash" },
{ 0, NULL },
};
diff --git a/src/telefiretwo-v0.1/Makefile b/src/telefiretwo-v0.1/Makefile
index 6454d6fd..72171fac 100644
--- a/src/telefiretwo-v0.1/Makefile
+++ b/src/telefiretwo-v0.1/Makefile
@@ -33,7 +33,7 @@ ALTOS_SRC = \
ao_data.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/telefiretwo-v0.1/ao_telefiretwo.c b/src/telefiretwo-v0.1/ao_telefiretwo.c
index bdcf3213..89541a02 100644
--- a/src/telefiretwo-v0.1/ao_telefiretwo.c
+++ b/src/telefiretwo-v0.1/ao_telefiretwo.c
@@ -26,7 +26,8 @@ main(void)
{
ao_clock_init();
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
+ ao_led_on(LEDS_AVAILABLE);
ao_task_init();
@@ -51,5 +52,7 @@ main(void)
// ao_radio_cmac_cmd_init();
+ ao_led_off(LEDS_AVAILABLE);
+
ao_start_scheduler();
}
diff --git a/src/telefiretwo-v0.2/Makefile b/src/telefiretwo-v0.2/Makefile
index 30985f9c..f43ece71 100644
--- a/src/telefiretwo-v0.2/Makefile
+++ b/src/telefiretwo-v0.2/Makefile
@@ -33,7 +33,7 @@ ALTOS_SRC = \
ao_data.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/telefiretwo-v0.2/ao_pins.h b/src/telefiretwo-v0.2/ao_pins.h
index 469e9937..01faace2 100644
--- a/src/telefiretwo-v0.2/ao_pins.h
+++ b/src/telefiretwo-v0.2/ao_pins.h
@@ -27,6 +27,7 @@
#define HAS_USB 1
#define HAS_BEEP 1
#define BEEPER_CHANNEL 4
+#define BEEPER_TIMER 3
#define HAS_GPS 0
#define HAS_SERIAL_1 0
#define HAS_ADC 1
diff --git a/src/telegps-v0.1/Makefile b/src/telegps-v0.1/Makefile
index 46eb0ac5..0365f91f 100644
--- a/src/telegps-v0.1/Makefile
+++ b/src/telegps-v0.1/Makefile
@@ -44,7 +44,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/telegps-v2.0/Makefile b/src/telegps-v2.0/Makefile
index 19d088d3..617efa65 100644
--- a/src/telegps-v2.0/Makefile
+++ b/src/telegps-v2.0/Makefile
@@ -21,7 +21,7 @@ INC = \
ALTOS_SRC = \
ao_adc_stm.c \
- ao_led.c \
+ ao_led_stmf0.c \
ao_interrupt.c \
ao_boot_chain.c \
ao_product.c \
diff --git a/src/telegps-v2.0/ao_telegps.c b/src/telegps-v2.0/ao_telegps.c
index 998c2008..1ba67f67 100644
--- a/src/telegps-v2.0/ao_telegps.c
+++ b/src/telegps-v2.0/ao_telegps.c
@@ -29,8 +29,8 @@ main(void)
ao_cmd_init();
ao_config_init();
- ao_led_init(LEDS_AVAILABLE);
- ao_led_on(AO_LED_GREEN);
+ ao_led_init();
+ ao_led_on(LEDS_AVAILABLE);
/* internal systems */
ao_timer_init();
@@ -53,8 +53,7 @@ main(void)
ao_telemetry_init();
ao_tracker_init();
- ao_led_off(AO_LED_GREEN);
+ ao_led_off(LEDS_AVAILABLE);
ao_start_scheduler();
- return 0;
}
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 <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>
-#include <ao_lco.h>
-#include <ao_event.h>
-#include <ao_seven_segment.h>
-#include <ao_quadrature.h>
-#include <ao_lco_func.h>
-#include <ao_radio_cmac.h>
-
-#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 <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.
- */
-
-#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 <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.
- */
-
-#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 <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>
-#include <ao_exti.h>
-#include <ao_packet.h>
-#include <ao_companion.h>
-#include <ao_profile.h>
-#include <ao_pyro.h>
-#include <ao_aes.h>
-#include <ao_seven_segment.h>
-#include <ao_quadrature.h>
-#include <ao_button.h>
-#include <ao_lco.h>
-#include <ao_lco_cmd.h>
-#include <ao_radio_cmac_cmd.h>
-
-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/telelco-v0.2-cc1200/Makefile b/src/telelco-v0.2-cc1200/Makefile
index 4ccf494c..9307aa2d 100644
--- a/src/telelco-v0.2-cc1200/Makefile
+++ b/src/telelco-v0.2-cc1200/Makefile
@@ -40,7 +40,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/telelco-v0.2-cc1200/ao_pins.h b/src/telelco-v0.2-cc1200/ao_pins.h
index bc325e06..f3850ebd 100644
--- a/src/telelco-v0.2-cc1200/ao_pins.h
+++ b/src/telelco-v0.2-cc1200/ao_pins.h
@@ -50,6 +50,10 @@
#define USE_STORAGE_CONFIG 0
#define HAS_USB 1
#define HAS_BEEP 1
+#define BEEPER_TIMER 3
+#define BEEPER_CHANNEL 1
+#define BEEPER_PORT (&stm_gpioc)
+#define BEEPER_PIN 6
#define HAS_RADIO 1
#define HAS_RADIO_RATE 1
#define HAS_TELEMETRY 0
diff --git a/src/telelco-v0.2-cc1200/ao_telelco.c b/src/telelco-v0.2-cc1200/ao_telelco.c
index 3266da00..26f49d59 100644
--- a/src/telelco-v0.2-cc1200/ao_telelco.c
+++ b/src/telelco-v0.2-cc1200/ao_telelco.c
@@ -45,9 +45,8 @@ main(void)
ao_timer_init();
ao_dma_init();
- ao_led_init(LEDS_AVAILABLE);
- ao_led_on(AO_LED_GREEN);
-
+ ao_led_init();
+ ao_led_on(LEDS_AVAILABLE);
ao_spi_init();
ao_exti_init();
@@ -74,6 +73,8 @@ main(void)
ao_lco_cmd_init();
// ao_radio_cmac_cmd_init();
+ ao_led_off(LEDS_AVAILABLE);
+
ao_start_scheduler();
return 0;
}
diff --git a/src/telelco-v0.2/Makefile b/src/telelco-v0.2/Makefile
index 8279cac1..91ae67f0 100644
--- a/src/telelco-v0.2/Makefile
+++ b/src/telelco-v0.2/Makefile
@@ -39,7 +39,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/telelco-v0.2/ao_pins.h b/src/telelco-v0.2/ao_pins.h
index f0da4fe4..3d06a647 100644
--- a/src/telelco-v0.2/ao_pins.h
+++ b/src/telelco-v0.2/ao_pins.h
@@ -48,6 +48,10 @@
#define USE_STORAGE_CONFIG 0
#define HAS_USB 1
#define HAS_BEEP 1
+#define BEEPER_TIMER 3
+#define BEEPER_CHANNEL 1
+#define BEEPER_PORT (&stm_gpioc)
+#define BEEPER_PIN 6
#define HAS_RADIO 1
#define HAS_RADIO_RATE 1
#define HAS_TELEMETRY 0
diff --git a/src/telelco-v0.2/ao_telelco.c b/src/telelco-v0.2/ao_telelco.c
index 7b04d386..4eba3597 100644
--- a/src/telelco-v0.2/ao_telelco.c
+++ b/src/telelco-v0.2/ao_telelco.c
@@ -35,9 +35,9 @@ int
main(void)
{
ao_clock_init();
-
- ao_led_init(LEDS_AVAILABLE);
- ao_led_on(AO_LED_GREEN);
+
+ ao_led_init();
+ ao_led_on(LEDS_AVAILABLE);
ao_task_init();
ao_timer_init();
@@ -55,17 +55,19 @@ main(void)
ao_button_init();
ao_eeprom_init();
-
+
ao_radio_init();
ao_usb_init();
ao_config_init();
-
+
ao_lco_init();
ao_lco_cmd_init();
// ao_radio_cmac_cmd_init();
-
+
+ ao_led_off(LEDS_AVAILABLE);
+
ao_start_scheduler();
return 0;
}
diff --git a/src/telelco-v0.3/Makefile b/src/telelco-v0.3/Makefile
index c2592bf8..567ddf41 100644
--- a/src/telelco-v0.3/Makefile
+++ b/src/telelco-v0.3/Makefile
@@ -40,7 +40,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/telelco-v0.3/ao_pins.h b/src/telelco-v0.3/ao_pins.h
index 6023739c..c806268f 100644
--- a/src/telelco-v0.3/ao_pins.h
+++ b/src/telelco-v0.3/ao_pins.h
@@ -50,6 +50,10 @@
#define USE_STORAGE_CONFIG 0
#define HAS_USB 1
#define HAS_BEEP 1
+#define BEEPER_TIMER 3
+#define BEEPER_CHANNEL 1
+#define BEEPER_PORT (&stm_gpioc)
+#define BEEPER_PIN 6
#define HAS_RADIO 1
#define HAS_RADIO_RATE 1
#define HAS_TELEMETRY 0
diff --git a/src/telelco-v0.3/ao_telelco.c b/src/telelco-v0.3/ao_telelco.c
index 7b04d386..c2ca68aa 100644
--- a/src/telelco-v0.3/ao_telelco.c
+++ b/src/telelco-v0.3/ao_telelco.c
@@ -36,8 +36,8 @@ main(void)
{
ao_clock_init();
- ao_led_init(LEDS_AVAILABLE);
- ao_led_on(AO_LED_GREEN);
+ ao_led_init();
+ ao_led_on(LEDS_AVAILABLE);
ao_task_init();
ao_timer_init();
@@ -66,6 +66,8 @@ main(void)
ao_lco_cmd_init();
// ao_radio_cmac_cmd_init();
+ ao_led_off(LEDS_AVAILABLE);
+
ao_start_scheduler();
return 0;
}
diff --git a/src/telelco-v2.0/ao_lco_v2.c b/src/telelco-v2.0/ao_lco_v2.c
index a9933d59..daecf380 100644
--- a/src/telelco-v2.0/ao_lco_v2.c
+++ b/src/telelco-v2.0/ao_lco_v2.c
@@ -243,9 +243,9 @@ ao_lco_display_test()
ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, 8 | 0x10);
ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, 8 | 0x10);
ao_mutex_put(&ao_lco_display_mutex);
- ao_led_on(LEDS_AVAILABLE);
+ ao_led_on(AO_LEDS_AVAILABLE);
ao_delay(AO_MS_TO_TICKS(1000));
- ao_led_off(LEDS_AVAILABLE);
+ ao_led_off(AO_LEDS_AVAILABLE);
}
static void
@@ -282,12 +282,12 @@ ao_lco_main(void)
void
ao_lco_set_debug(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status == ao_cmd_success)
- ao_lco_debug = ao_cmd_lex_i != 0;
+ ao_lco_debug = r != 0;
}
-__code struct ao_cmds ao_lco_cmds[] = {
+const struct ao_cmds ao_lco_cmds[] = {
{ ao_lco_set_debug, "D <0 off, 1 on>\0Debug" },
{ ao_lco_search, "s\0Search for pad boxes" },
{ 0, NULL }
diff --git a/src/telelco-v2.0/ao_pins.h b/src/telelco-v2.0/ao_pins.h
index 95998dc7..e0663314 100644
--- a/src/telelco-v2.0/ao_pins.h
+++ b/src/telelco-v2.0/ao_pins.h
@@ -50,6 +50,10 @@
#define USE_STORAGE_CONFIG 0
#define HAS_USB 1
#define HAS_BEEP 1
+#define BEEPER_TIMER 3
+#define BEEPER_CHANNEL 1
+#define BEEPER_PORT (&stm_gpioc)
+#define BEEPER_PIN 6
#define HAS_RADIO 1
#define HAS_RADIO_RATE 1
#define HAS_TELEMETRY 0
@@ -99,13 +103,7 @@
#define LOW_LEVEL_DEBUG 0
-#define LED_PER_LED 1
-#define LED_TYPE uint16_t
-
-#define LED_ENABLE_BITS ((1 << STM_RCC_AHBENR_GPIOAEN) | \
- (1 << STM_RCC_AHBENR_GPIOCEN) | \
- (1 << STM_RCC_AHBENR_GPIODEN) | \
- (1 << STM_RCC_AHBENR_GPIOEEN))
+#define HAS_LED 1
/* PC7 - PC9, LED 0 - 2 */
#define LED_0_PORT (&stm_gpioc)
@@ -147,56 +145,23 @@
#define LED_15_PORT (&stm_gpioa)
#define LED_15_PIN 5
-#define LED_PIN_RED 0
-#define LED_PIN_AMBER 1
-#define LED_PIN_GREEN 2
-#define LED_PIN_BOX 3
-#define LED_PIN_PAD 4
-#define LED_PIN_DRAG 5
-#define LED_PIN_CONTINUITY_7 6
-#define LED_PIN_CONTINUITY_6 7
-#define LED_PIN_CONTINUITY_5 8
-#define LED_PIN_CONTINUITY_4 9
-#define LED_PIN_CONTINUITY_3 10
-#define LED_PIN_CONTINUITY_2 11
-#define LED_PIN_CONTINUITY_1 12
-#define LED_PIN_CONTINUITY_0 13
-#define LED_PIN_REMOTE_ARM 14
-#define LED_PIN_FIRE 15
-#define AO_LED_RED (1 << LED_PIN_RED)
-#define AO_LED_AMBER (1 << LED_PIN_AMBER)
-#define AO_LED_GREEN (1 << LED_PIN_GREEN)
-#define AO_LED_BOX (1 << LED_PIN_BOX)
-#define AO_LED_PAD (1 << LED_PIN_PAD)
-#define AO_LED_DRAG (1 << LED_PIN_DRAG)
-#define AO_LED_CONTINUITY_7 (1 << LED_PIN_CONTINUITY_7)
-#define AO_LED_CONTINUITY_6 (1 << LED_PIN_CONTINUITY_6)
-#define AO_LED_CONTINUITY_5 (1 << LED_PIN_CONTINUITY_5)
-#define AO_LED_CONTINUITY_4 (1 << LED_PIN_CONTINUITY_4)
-#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_RED AO_LED_0
+#define AO_LED_AMBER AO_LED_1
+#define AO_LED_GREEN AO_LED_2
+#define AO_LED_BOX AO_LED_3
+#define AO_LED_PAD AO_LED_4
+#define AO_LED_DRAG AO_LED_5
+#define AO_LED_CONTINUITY_7 AO_LED_6
+#define AO_LED_CONTINUITY_6 AO_LED_7
+#define AO_LED_CONTINUITY_5 AO_LED_8
+#define AO_LED_CONTINUITY_4 AO_LED_9
+#define AO_LED_CONTINUITY_3 AO_LED_10
+#define AO_LED_CONTINUITY_2 AO_LED_11
+#define AO_LED_CONTINUITY_1 AO_LED_12
+#define AO_LED_CONTINUITY_0 AO_LED_13
#define AO_LED_CONTINUITY_NUM 8
-#define AO_LED_REMOTE_ARM (1 << LED_PIN_REMOTE_ARM)
-#define AO_LED_FIRE (1 << LED_PIN_FIRE)
-
-#define LEDS_AVAILABLE (AO_LED_RED | \
- AO_LED_AMBER | \
- AO_LED_GREEN | \
- AO_LED_BOX | \
- AO_LED_PAD | \
- AO_LED_DRAG | \
- AO_LED_CONTINUITY_7 | \
- AO_LED_CONTINUITY_6 | \
- AO_LED_CONTINUITY_5 | \
- AO_LED_CONTINUITY_4 | \
- AO_LED_CONTINUITY_3 | \
- AO_LED_CONTINUITY_2 | \
- AO_LED_CONTINUITY_1 | \
- AO_LED_CONTINUITY_0 | \
- AO_LED_REMOTE_ARM | \
- AO_LED_FIRE)
+#define AO_LED_REMOTE_ARM AO_LED_14
+#define AO_LED_FIRE AO_LED_15
/* LCD displays */
diff --git a/src/telelco-v2.0/ao_telelco.c b/src/telelco-v2.0/ao_telelco.c
index 9693c657..59582569 100644
--- a/src/telelco-v2.0/ao_telelco.c
+++ b/src/telelco-v2.0/ao_telelco.c
@@ -37,8 +37,8 @@ main(void)
{
ao_clock_init();
- ao_led_init(LEDS_AVAILABLE);
- ao_led_on(AO_LED_GREEN);
+ ao_led_init();
+ ao_led_on(LEDS_AVAILABLE);
ao_task_init();
ao_timer_init();
@@ -68,6 +68,8 @@ main(void)
ao_lco_cmd_init();
// ao_radio_cmac_cmd_init();
+ ao_led_off(LEDS_AVAILABLE);
+
ao_start_scheduler();
return 0;
}
diff --git a/src/telelcotwo-v0.1/Makefile b/src/telelcotwo-v0.1/Makefile
index c68f3eb5..6a114aae 100644
--- a/src/telelcotwo-v0.1/Makefile
+++ b/src/telelcotwo-v0.1/Makefile
@@ -36,7 +36,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/telelcotwo-v0.1/ao_pins.h b/src/telelcotwo-v0.1/ao_pins.h
index 1941e03d..3ef88c74 100644
--- a/src/telelcotwo-v0.1/ao_pins.h
+++ b/src/telelcotwo-v0.1/ao_pins.h
@@ -51,6 +51,9 @@
#define HAS_USB 1
#define HAS_BEEP 1
#define BEEPER_CHANNEL 4
+#define BEEPER_TIMER 3
+#define BEEPER_PORT (&stm_gpiob)
+#define BEEPER_PIN 1
#define HAS_RADIO 1
#define HAS_RADIO_RATE 1
#define HAS_TELEMETRY 0
diff --git a/src/telelcotwo-v0.1/ao_telelcotwo.c b/src/telelcotwo-v0.1/ao_telelcotwo.c
index b3fcd200..6ced1912 100644
--- a/src/telelcotwo-v0.1/ao_telelcotwo.c
+++ b/src/telelcotwo-v0.1/ao_telelcotwo.c
@@ -34,8 +34,8 @@ main(void)
{
ao_clock_init();
- ao_led_init(LEDS_AVAILABLE);
- ao_led_on(AO_LED_GREEN);
+ ao_led_init();
+ ao_led_on(LEDS_AVAILABLE);
ao_beep_init();
ao_task_init();
@@ -61,6 +61,8 @@ main(void)
ao_lco_cmd_init();
// ao_radio_cmac_cmd_init();
+ ao_led_off(LEDS_AVAILABLE);
+
ao_start_scheduler();
return 0;
}
diff --git a/src/telemega-v0.1/Makefile b/src/telemega-v0.1/Makefile
index 28ed7c98..fde35aae 100644
--- a/src/telemega-v0.1/Makefile
+++ b/src/telemega-v0.1/Makefile
@@ -26,7 +26,6 @@ INC = \
ao_whiten.h \
ao_sample_profile.h \
ao_quaternion.h \
- math.h \
ao_mpu.h \
stm32l.h \
Makefile
@@ -46,21 +45,6 @@ INC = \
#STACK_GUARD=ao_mpu_stm.c
#STACK_GUARD_DEF=-DHAS_STACK_GUARD=1
-MATH_SRC=\
- ef_acos.c \
- ef_sqrt.c \
- ef_rem_pio2.c \
- kf_cos.c \
- kf_sin.c \
- kf_rem_pio2.c \
- sf_copysign.c \
- sf_cos.c \
- sf_sin.c \
- sf_fabs.c \
- sf_floor.c \
- sf_scalbn.c \
- ef_log.c
-
ALTOS_SRC = \
ao_boot_chain.c \
ao_interrupt.c \
@@ -69,7 +53,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
@@ -112,7 +96,6 @@ ALTOS_SRC = \
ao_companion.c \
ao_pyro.c \
ao_aprs.c \
- $(MATH_SRC) \
$(PROFILE) \
$(SAMPLE_PROFILE) \
$(STACK_GUARD)
diff --git a/src/telemega-v0.1/ao_pins.h b/src/telemega-v0.1/ao_pins.h
index 94e77f98..0208fafa 100644
--- a/src/telemega-v0.1/ao_pins.h
+++ b/src/telemega-v0.1/ao_pins.h
@@ -77,6 +77,10 @@
#define USE_STORAGE_CONFIG 0
#define HAS_USB 1
#define HAS_BEEP 1
+#define BEEPER_TIMER 3
+#define BEEPER_CHANNEL 1
+#define BEEPER_PORT (&stm_gpioc)
+#define BEEPER_PIN 6
#define HAS_BATTERY_REPORT 1
#define HAS_RADIO 1
#define HAS_TELEMETRY 1
@@ -165,9 +169,6 @@
/* Number of general purpose pyro channels available */
#define AO_PYRO_NUM 4
-#define AO_IGNITER_SET_DROGUE(v) stm_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v)
-#define AO_IGNITER_SET_MAIN(v) stm_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, v)
-
/*
* ADC
*/
diff --git a/src/telemega-v0.1/ao_telemega.c b/src/telemega-v0.1/ao_telemega.c
index 3cfc9b44..d6ecbf31 100644
--- a/src/telemega-v0.1/ao_telemega.c
+++ b/src/telemega-v0.1/ao_telemega.c
@@ -45,8 +45,8 @@ main(void)
ao_task_init();
ao_serial_init();
- ao_led_init(LEDS_AVAILABLE);
- ao_led_on(AO_LED_GREEN);
+ ao_led_init();
+ ao_led_on(LEDS_AVAILABLE);
ao_timer_init();
ao_i2c_init();
@@ -85,7 +85,7 @@ main(void)
ao_gps_report_mega_init();
ao_telemetry_init();
ao_radio_init();
- ao_packet_slave_init(FALSE);
+ ao_packet_slave_init(false);
ao_igniter_init();
ao_companion_init();
ao_pyro_init();
@@ -98,6 +98,7 @@ main(void)
ao_sample_profile_init();
#endif
+ ao_led_off(LEDS_AVAILABLE);
ao_start_scheduler();
return 0;
}
diff --git a/src/telemega-v1.0/Makefile b/src/telemega-v1.0/Makefile
index 4a1b3908..62eda4ad 100644
--- a/src/telemega-v1.0/Makefile
+++ b/src/telemega-v1.0/Makefile
@@ -27,10 +27,8 @@ INC = \
ao_whiten.h \
ao_sample_profile.h \
ao_quaternion.h \
- math.h \
ao_mpu.h \
stm32l.h \
- math.h \
ao_ms5607_convert.c \
Makefile
@@ -49,21 +47,6 @@ INC = \
#STACK_GUARD=ao_mpu_stm.c
#STACK_GUARD_DEF=-DHAS_STACK_GUARD=1
-MATH_SRC=\
- ef_acos.c \
- ef_sqrt.c \
- ef_rem_pio2.c \
- kf_cos.c \
- kf_sin.c \
- kf_rem_pio2.c \
- sf_copysign.c \
- sf_cos.c \
- sf_fabs.c \
- sf_floor.c \
- sf_scalbn.c \
- sf_sin.c \
- ef_log.c
-
ALTOS_SRC = \
ao_boot_chain.c \
ao_interrupt.c \
@@ -72,7 +55,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
@@ -115,7 +98,6 @@ ALTOS_SRC = \
ao_companion.c \
ao_pyro.c \
ao_aprs.c \
- $(MATH_SRC) \
$(PROFILE) \
$(SAMPLE_PROFILE) \
$(STACK_GUARD)
diff --git a/src/telemega-v1.0/ao_pins.h b/src/telemega-v1.0/ao_pins.h
index d44394f0..a154225e 100644
--- a/src/telemega-v1.0/ao_pins.h
+++ b/src/telemega-v1.0/ao_pins.h
@@ -77,6 +77,10 @@
#define USE_STORAGE_CONFIG 0
#define HAS_USB 1
#define HAS_BEEP 1
+#define BEEPER_TIMER 3
+#define BEEPER_CHANNEL 1
+#define BEEPER_PORT (&stm_gpioc)
+#define BEEPER_PIN 6
#define HAS_BATTERY_REPORT 1
#define HAS_RADIO 1
#define HAS_TELEMETRY 1
@@ -165,9 +169,6 @@
/* Number of general purpose pyro channels available */
#define AO_PYRO_NUM 4
-#define AO_IGNITER_SET_DROGUE(v) stm_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v)
-#define AO_IGNITER_SET_MAIN(v) stm_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, v)
-
/*
* ADC
*/
diff --git a/src/telemega-v1.0/ao_telemega.c b/src/telemega-v1.0/ao_telemega.c
index 2deb852e..328c17ff 100644
--- a/src/telemega-v1.0/ao_telemega.c
+++ b/src/telemega-v1.0/ao_telemega.c
@@ -45,7 +45,7 @@ main(void)
ao_task_init();
ao_serial_init();
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
ao_led_on(LEDS_AVAILABLE);
ao_timer_init();
@@ -85,7 +85,7 @@ main(void)
ao_gps_report_mega_init();
ao_telemetry_init();
ao_radio_init();
- ao_packet_slave_init(FALSE);
+ ao_packet_slave_init(false);
ao_igniter_init();
ao_companion_init();
ao_pyro_init();
diff --git a/src/telemega-v2.0/Makefile b/src/telemega-v2.0/Makefile
index 6a1c05b0..78829fff 100644
--- a/src/telemega-v2.0/Makefile
+++ b/src/telemega-v2.0/Makefile
@@ -27,10 +27,8 @@ INC = \
ao_whiten.h \
ao_sample_profile.h \
ao_quaternion.h \
- math.h \
ao_mpu.h \
stm32l.h \
- math.h \
ao_ms5607_convert.c \
Makefile
@@ -49,21 +47,6 @@ INC = \
#STACK_GUARD=ao_mpu_stm.c
#STACK_GUARD_DEF=-DHAS_STACK_GUARD=1
-MATH_SRC=\
- ef_acos.c \
- ef_sqrt.c \
- ef_rem_pio2.c \
- kf_cos.c \
- kf_sin.c \
- kf_rem_pio2.c \
- sf_copysign.c \
- sf_cos.c \
- sf_fabs.c \
- sf_floor.c \
- sf_scalbn.c \
- sf_sin.c \
- ef_log.c
-
ALTOS_SRC = \
ao_boot_chain.c \
ao_interrupt.c \
@@ -72,7 +55,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
@@ -114,7 +97,6 @@ ALTOS_SRC = \
ao_pyro.c \
ao_aprs.c \
ao_pwm_stm.c \
- $(MATH_SRC) \
$(PROFILE) \
$(SAMPLE_PROFILE) \
$(STACK_GUARD)
diff --git a/src/telemega-v2.0/ao_pins.h b/src/telemega-v2.0/ao_pins.h
index 42c00c94..ba302c74 100644
--- a/src/telemega-v2.0/ao_pins.h
+++ b/src/telemega-v2.0/ao_pins.h
@@ -77,6 +77,10 @@
#define USE_STORAGE_CONFIG 0
#define HAS_USB 1
#define HAS_BEEP 1
+#define BEEPER_TIMER 3
+#define BEEPER_CHANNEL 1
+#define BEEPER_PORT (&stm_gpioc)
+#define BEEPER_PIN 6
#define HAS_BATTERY_REPORT 1
#define HAS_RADIO 1
#define HAS_TELEMETRY 1
@@ -165,9 +169,6 @@
/* Number of general purpose pyro channels available */
#define AO_PYRO_NUM 4
-#define AO_IGNITER_SET_DROGUE(v) stm_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v)
-#define AO_IGNITER_SET_MAIN(v) stm_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, v)
-
/*
* ADC
*/
diff --git a/src/telemega-v2.0/ao_telemega.c b/src/telemega-v2.0/ao_telemega.c
index 7a1c46ae..623e8d1e 100644
--- a/src/telemega-v2.0/ao_telemega.c
+++ b/src/telemega-v2.0/ao_telemega.c
@@ -46,7 +46,7 @@ main(void)
ao_task_init();
ao_serial_init();
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
ao_led_on(LEDS_AVAILABLE);
ao_timer_init();
@@ -86,7 +86,7 @@ main(void)
ao_gps_report_mega_init();
ao_telemetry_init();
ao_radio_init();
- ao_packet_slave_init(FALSE);
+ ao_packet_slave_init(false);
ao_igniter_init();
ao_companion_init();
ao_pyro_init();
diff --git a/src/telemega-v3.0/Makefile b/src/telemega-v3.0/Makefile
index ae22bf01..b449b397 100644
--- a/src/telemega-v3.0/Makefile
+++ b/src/telemega-v3.0/Makefile
@@ -26,10 +26,8 @@ INC = \
ao_whiten.h \
ao_sample_profile.h \
ao_quaternion.h \
- math.h \
ao_mpu.h \
stm32l.h \
- math.h \
ao_ms5607_convert.c \
Makefile
@@ -47,21 +45,6 @@ INC = \
#STACK_GUARD=ao_mpu_stm.c
#STACK_GUARD_DEF=-DHAS_STACK_GUARD=1
-MATH_SRC=\
- ef_acos.c \
- ef_sqrt.c \
- ef_rem_pio2.c \
- kf_cos.c \
- kf_sin.c \
- kf_rem_pio2.c \
- sf_copysign.c \
- sf_cos.c \
- sf_fabs.c \
- sf_floor.c \
- sf_scalbn.c \
- sf_sin.c \
- ef_log.c
-
ALTOS_SRC = \
ao_boot_chain.c \
ao_interrupt.c \
@@ -70,7 +53,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
@@ -111,7 +94,6 @@ ALTOS_SRC = \
ao_pyro.c \
ao_aprs.c \
ao_pwm_stm.c \
- $(MATH_SRC) \
$(PROFILE) \
$(SAMPLE_PROFILE) \
$(STACK_GUARD)
diff --git a/src/telemega-v3.0/ao_pins.h b/src/telemega-v3.0/ao_pins.h
index 73278600..ce223907 100644
--- a/src/telemega-v3.0/ao_pins.h
+++ b/src/telemega-v3.0/ao_pins.h
@@ -77,6 +77,10 @@
#define USE_STORAGE_CONFIG 0
#define HAS_USB 1
#define HAS_BEEP 1
+#define BEEPER_TIMER 3
+#define BEEPER_CHANNEL 1
+#define BEEPER_PORT (&stm_gpioc)
+#define BEEPER_PIN 6
#define HAS_BATTERY_REPORT 1
#define HAS_RADIO 1
#define HAS_TELEMETRY 1
@@ -165,9 +169,6 @@
/* Number of general purpose pyro channels available */
#define AO_PYRO_NUM 4
-#define AO_IGNITER_SET_DROGUE(v) stm_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v)
-#define AO_IGNITER_SET_MAIN(v) stm_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, v)
-
/*
* ADC
*/
diff --git a/src/telemega-v3.0/ao_telemega.c b/src/telemega-v3.0/ao_telemega.c
index 2259c751..d987c1ec 100644
--- a/src/telemega-v3.0/ao_telemega.c
+++ b/src/telemega-v3.0/ao_telemega.c
@@ -45,7 +45,7 @@ main(void)
ao_task_init();
ao_serial_init();
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
ao_led_on(LEDS_AVAILABLE);
ao_timer_init();
@@ -82,7 +82,7 @@ main(void)
ao_gps_report_mega_init();
ao_telemetry_init();
ao_radio_init();
- ao_packet_slave_init(FALSE);
+ ao_packet_slave_init(false);
ao_igniter_init();
ao_companion_init();
ao_pyro_init();
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/telemetrum-v2.0/Makefile b/src/telemetrum-v2.0/Makefile
index d77e9585..e0192f61 100644
--- a/src/telemetrum-v2.0/Makefile
+++ b/src/telemetrum-v2.0/Makefile
@@ -38,9 +38,6 @@ INC = \
#STACK_GUARD=ao_mpu_stm.c
#STACK_GUARD_DEF=-DHAS_STACK_GUARD=1
-MATH_SRC=\
- ef_log.c
-
ALTOS_SRC = \
ao_boot_chain.c \
ao_interrupt.c \
@@ -49,7 +46,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
@@ -88,7 +85,6 @@ ALTOS_SRC = \
ao_packet.c \
ao_companion.c \
ao_aprs.c \
- $(MATH_SRC) \
$(PROFILE) \
$(SAMPLE_PROFILE) \
$(STACK_GUARD)
diff --git a/src/telemetrum-v2.0/ao_pins.h b/src/telemetrum-v2.0/ao_pins.h
index d26a5193..e8c97ff4 100644
--- a/src/telemetrum-v2.0/ao_pins.h
+++ b/src/telemetrum-v2.0/ao_pins.h
@@ -74,6 +74,9 @@
#define HAS_BEEP 1
#define HAS_BATTERY_REPORT 1
#define BEEPER_CHANNEL 4
+#define BEEPER_TIMER 3
+#define BEEPER_PORT (&stm_gpiob)
+#define BEEPER_PIN 1
#define HAS_RADIO 1
#define HAS_TELEMETRY 1
#define HAS_APRS 1
@@ -141,9 +144,6 @@
#define AO_IGNITER_MAIN_PORT (&stm_gpioa)
#define AO_IGNITER_MAIN_PIN 9
-#define AO_IGNITER_SET_DROGUE(v) stm_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v)
-#define AO_IGNITER_SET_MAIN(v) stm_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, v)
-
/*
* ADC
*/
diff --git a/src/telemetrum-v2.0/ao_telemetrum.c b/src/telemetrum-v2.0/ao_telemetrum.c
index 5cf42a8d..dbf6090c 100644
--- a/src/telemetrum-v2.0/ao_telemetrum.c
+++ b/src/telemetrum-v2.0/ao_telemetrum.c
@@ -43,7 +43,7 @@ main(void)
ao_task_init();
ao_serial_init();
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
ao_led_on(LEDS_AVAILABLE);
ao_timer_init();
@@ -77,7 +77,7 @@ main(void)
ao_gps_report_metrum_init();
ao_telemetry_init();
ao_radio_init();
- ao_packet_slave_init(FALSE);
+ ao_packet_slave_init(false);
ao_igniter_init();
ao_companion_init();
diff --git a/src/telemetrum-v3.0/Makefile b/src/telemetrum-v3.0/Makefile
index 002cc3f6..071fd8dd 100644
--- a/src/telemetrum-v3.0/Makefile
+++ b/src/telemetrum-v3.0/Makefile
@@ -38,9 +38,6 @@ INC = \
#STACK_GUARD=ao_mpu_stm.c
#STACK_GUARD_DEF=-DHAS_STACK_GUARD=1
-MATH_SRC=\
- ef_log.c
-
ALTOS_SRC = \
ao_boot_chain.c \
ao_interrupt.c \
@@ -49,7 +46,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
@@ -88,7 +85,6 @@ ALTOS_SRC = \
ao_packet.c \
ao_companion.c \
ao_aprs.c \
- $(MATH_SRC) \
$(PROFILE) \
$(SAMPLE_PROFILE) \
$(STACK_GUARD)
diff --git a/src/telemetrum-v3.0/ao_pins.h b/src/telemetrum-v3.0/ao_pins.h
index 6d4369c9..f4ccc9f3 100644
--- a/src/telemetrum-v3.0/ao_pins.h
+++ b/src/telemetrum-v3.0/ao_pins.h
@@ -74,6 +74,9 @@
#define HAS_BEEP 1
#define HAS_BATTERY_REPORT 1
#define BEEPER_CHANNEL 4
+#define BEEPER_TIMER 3
+#define BEEPER_PORT (&stm_gpiob)
+#define BEEPER_PIN 1
#define HAS_RADIO 1
#define HAS_TELEMETRY 1
#define HAS_APRS 1
@@ -141,9 +144,6 @@
#define AO_IGNITER_MAIN_PORT (&stm_gpioa)
#define AO_IGNITER_MAIN_PIN 9
-#define AO_IGNITER_SET_DROGUE(v) stm_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v)
-#define AO_IGNITER_SET_MAIN(v) stm_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, v)
-
/*
* ADC
*/
diff --git a/src/telemetrum-v3.0/ao_telemetrum.c b/src/telemetrum-v3.0/ao_telemetrum.c
index 6349d188..d75f339d 100644
--- a/src/telemetrum-v3.0/ao_telemetrum.c
+++ b/src/telemetrum-v3.0/ao_telemetrum.c
@@ -43,8 +43,8 @@ main(void)
ao_task_init();
ao_serial_init();
- ao_led_init(LEDS_AVAILABLE);
- ao_led_on(AO_LED_RED);
+ ao_led_init();
+ ao_led_on(LEDS_AVAILABLE);
ao_timer_init();
ao_spi_init();
@@ -77,7 +77,7 @@ main(void)
ao_gps_report_metrum_init();
ao_telemetry_init();
ao_radio_init();
- ao_packet_slave_init(FALSE);
+ ao_packet_slave_init(false);
ao_igniter_init();
ao_companion_init();
@@ -88,6 +88,7 @@ main(void)
#if HAS_SAMPLE_PROFILE
ao_sample_profile_init();
#endif
+ ao_led_off(LEDS_AVAILABLE);
ao_start_scheduler();
return 0;
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 <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.
- */
-
-#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-v3.0/ao_pins.h b/src/telemini-v3.0/ao_pins.h
index 17cff2ae..d91b1d21 100644
--- a/src/telemini-v3.0/ao_pins.h
+++ b/src/telemini-v3.0/ao_pins.h
@@ -74,9 +74,9 @@
#define AO_RECOVERY_VALUE 0
#define AO_RECOVERY_MODE AO_EXTI_MODE_PULL_UP
-/* Beeper is on Tim1 CH3 */
+/* Beeper is on Tim3 CH4 */
#define BEEPER_CHANNEL 4
-#define BEEPER_TIMER 2
+#define BEEPER_TIMER 3
#define BEEPER_PORT (&stm_gpioa)
#define BEEPER_PIN 3
@@ -165,11 +165,9 @@ struct ao_adc {
#define AO_IGNITER_DROGUE_PORT (&stm_gpiob)
#define AO_IGNITER_DROGUE_PIN 7
-#define AO_IGNITER_SET_DROGUE(v) ao_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, AO_IGNITER_DROGUE, v)
#define AO_IGNITER_MAIN_PORT (&stm_gpiob)
#define AO_IGNITER_MAIN_PIN 6
-#define AO_IGNITER_SET_MAIN(v) ao_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, AO_IGNITER_MAIN, v)
#define AO_SENSE_DROGUE(p) ((p)->adc.sense_a)
#define AO_SENSE_MAIN(p) ((p)->adc.sense_m)
diff --git a/src/telemini-v3.0/ao_telemini.c b/src/telemini-v3.0/ao_telemini.c
index a50268b9..66f75f0a 100644
--- a/src/telemini-v3.0/ao_telemini.c
+++ b/src/telemini-v3.0/ao_telemini.c
@@ -26,7 +26,7 @@ ao_check_recovery(void)
ao_enable_input(AO_RECOVERY_PORT, AO_RECOVERY_PIN, AO_RECOVERY_MODE);
for (i = 0; i < 100; i++)
ao_arch_nop();
- if (ao_gpio_get(AO_RECOVERY_PORT, AO_RECOVERY_PIN, AO_RECOVERY) == AO_RECOVERY_VALUE) {
+ if (ao_gpio_get(AO_RECOVERY_PORT, AO_RECOVERY_PIN) == AO_RECOVERY_VALUE) {
ao_flight_force_idle = 1;
ao_force_freq = 1;
}
@@ -68,7 +68,7 @@ main(void)
ao_report_init();
ao_telemetry_init();
ao_radio_init();
- ao_packet_slave_init(TRUE);
+ ao_packet_slave_init(true);
ao_igniter_init();
ao_config_init();
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/telepyro-v0.1/.gitignore b/src/telepyro-v0.1/.gitignore
deleted file mode 100644
index 5166481c..00000000
--- a/src/telepyro-v0.1/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-telepyro-v0.1*
-ao_product.h
diff --git a/src/telepyro-v0.1/Makefile b/src/telepyro-v0.1/Makefile
deleted file mode 100644
index dcac03dc..00000000
--- a/src/telepyro-v0.1/Makefile
+++ /dev/null
@@ -1,100 +0,0 @@
-#
-# AltOS build
-#
-#
-vpath % .:..:../kernel:../product:../drivers:../avr
-vpath ao-make-product.5c ../util
-
-include ../avr/Makefile.defs
-
-MCU=atmega32u4
-DUDECPUTYPE=m32u4
-#PROGRAMMER=stk500v2 -P usb
-LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w:
-
-INC = \
- ao.h \
- ao_usb.h \
- ao_pins.h \
- ao_arch.h \
- ao_arch_funcs.h \
- ao_product.h
-
-ALTOS_SRC = \
- ao_clock.c \
- ao_cmd.c \
- ao_mutex.c \
- ao_panic.c \
- ao_product.c \
- ao_stdio.c \
- ao_task.c \
- ao_timer.c \
- ao_led.c \
- ao_avr_stdio.c \
- ao_romconfig.c \
- ao_usb_avr.c \
- ao_adc_avr.c \
- ao_pyro_slave.c \
- ao_spi_slave.c \
- ao_eeprom_avr.c \
- ao_storage.c \
- ao_config.c \
- ao_pyro.c
-
-PRODUCT=TelePyro-v0.1
-MCU=atmega32u4
-PRODUCT_DEF=-DTELEPYRO
-IDPRODUCT=0x0011
-CFLAGS = $(PRODUCT_DEF) -I. -I../avr -I../kernel -I..
-CFLAGS += -mmcu=$(MCU) -Wall -Wstrict-prototypes -O3 -mcall-prologues -DAVR
-
-NICKLE=nickle
-
-PROG=telepyro-v0.1
-
-SRC=$(ALTOS_SRC) ao_telepyro.c
-OBJ=$(SRC:.c=.o)
-
-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)
-
-CHECK=sh ../util/check-avr-mem
-
-$(PROG): Makefile $(OBJ)
- $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ)
- $(call quiet,CHECK) $(PROG) || ($(RM) -f $(PROG); exit 1)
-
-$(PROG).hex: $(PROG)
- avr-size $(PROG)
- $(OBJCOPY) -R .eeprom -O ihex $(PROG) $@
-
-
-load: $(PROG).hex
- $(LOADCMD) $(LOADARG)$(PROG).hex
-
-ao_product.h: ao-make-product.5c ../Version
- $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
-
-ao_product.o: ao_product.c ao_product.h
-
-%.o : %.c
- $(call quiet,CC) -c $(CFLAGS) $<
-
-distclean: clean
-
-clean:
- rm -f $(OBJ) $(PROG) $(PROG).hex
- rm -f ao_product.h
-
-install:
-
-uninstall:
-
-$(OBJ): $(INC)
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 <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.
- */
-
-#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 <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"
-#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/telescience-pwm/.gitignore b/src/telescience-pwm/.gitignore
deleted file mode 100644
index 5d9c0970..00000000
--- a/src/telescience-pwm/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-telescience-pwm*
-ao_product.h
diff --git a/src/telescience-pwm/Makefile b/src/telescience-pwm/Makefile
deleted file mode 100644
index 493bd480..00000000
--- a/src/telescience-pwm/Makefile
+++ /dev/null
@@ -1,112 +0,0 @@
-#
-# AltOS build
-#
-#
-vpath % ..:../kernel:../product:../drivers:../avr
-vpath ao-make-product.5c ../util
-
-include ../avr/Makefile.defs
-
-MCU=atmega32u4
-DUDECPUTYPE=m32u4
-#PROGRAMMER=stk500v2 -P usb
-LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w:
-
-#LDFLAGS=-L$(LDSCRIPTS) -Tavr5.x
-
-INC = \
- ao.h \
- ao_arch.h \
- ao_usb.h \
- ao_pins.h \
- ao_product.h
-
-#
-# Common AltOS sources
-#
-TELESCIENCE_STORAGE= \
- ao_m25.c \
- ao_spi_usart.c \
- ao_storage.c
-
-TELESCIENCE_LOG= \
- ao_log_single.c \
- ao_log_telescience.c
-
-ALTOS_SRC = \
- ao_clock.c \
- ao_cmd.c \
- ao_mutex.c \
- ao_panic.c \
- ao_product.c \
- ao_stdio.c \
- ao_task.c \
- ao_timer.c \
- ao_led.c \
- ao_avr_stdio.c \
- ao_romconfig.c \
- ao_usb_avr.c \
- ao_adc_avr.c \
- ao_science_slave.c \
- ao_spi_slave.c \
- ao_pwmin.c \
- $(TELESCIENCE_STORAGE)\
- $(TELESCIENCE_LOG)
-
-PRODUCT=TeleScience-PWM
-MCU=atmega32u4
-PRODUCT_DEF=-DTELESCIENCE -DTELESCIENCE_PWM
-IDPRODUCT=0x0011
-CFLAGS = $(PRODUCT_DEF) -I. -I../avr -I../kernel -I..
-CFLAGS += -g -mmcu=$(MCU) -Wall -Wstrict-prototypes -O3 -mcall-prologues -DAVR
-
-NICKLE=nickle
-
-PROG=telescience-pwm
-
-SRC=$(ALTOS_SRC) ao_telescience.c
-OBJ=$(SRC:.c=.o)
-
-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)
-
-CHECK=sh ../util/check-avr-mem
-
-$(PROG): Makefile $(OBJ)
- $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ)
- $(call quiet,CHECK) $(PROG) || ($(RM) -f $(PROG); exit 1)
-
-$(PROG).hex: $(PROG)
- avr-size $(PROG)
- $(OBJCOPY) -R .eeprom -O ihex $(PROG) $@
-
-
-load: $(PROG).hex
- $(LOADCMD) $(LOADARG)$(PROG).hex
-
-ao_product.h: ao-make-product.5c ../Version
- $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
-
-ao_product.o: ao_product.c ao_product.h
-
-%.o : %.c $(INC)
- $(call quiet,CC) -c $(CFLAGS) $<
-
-distclean: clean
-
-clean:
- rm -f *.o $(PROG) $(PROG).hex
- rm -f ao_product.h
-
-install:
-
-uninstall:
-
-$(OBJ): ao_product.h $(INC)
diff --git a/src/telescience-v0.1/.gitignore b/src/telescience-v0.1/.gitignore
deleted file mode 100644
index dfccadf8..00000000
--- a/src/telescience-v0.1/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-telescience-v0.1*
-ao_product.h
diff --git a/src/telescience-v0.1/Makefile b/src/telescience-v0.1/Makefile
deleted file mode 100644
index c55c48e2..00000000
--- a/src/telescience-v0.1/Makefile
+++ /dev/null
@@ -1,111 +0,0 @@
-#
-# AltOS build
-#
-#
-vpath % ..:../kernel:../product:../drivers:../avr
-vpath ao-make-product.5c ../util
-
-include ../avr/Makefile.defs
-
-MCU=atmega32u4
-DUDECPUTYPE=m32u4
-#PROGRAMMER=stk500v2 -P usb
-LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w:
-
-#LDFLAGS=-L$(LDSCRIPTS) -Tavr5.x
-
-INC = \
- ao.h \
- ao_arch.h \
- ao_usb.h \
- ao_pins.h \
- ao_product.h
-
-#
-# Common AltOS sources
-#
-TELESCIENCE_STORAGE= \
- ao_m25.c \
- ao_spi_usart.c \
- ao_storage.c
-
-TELESCIENCE_LOG= \
- ao_log_single.c \
- ao_log_telescience.c
-
-ALTOS_SRC = \
- ao_clock.c \
- ao_cmd.c \
- ao_mutex.c \
- ao_panic.c \
- ao_product.c \
- ao_stdio.c \
- ao_task.c \
- ao_timer.c \
- ao_led.c \
- ao_avr_stdio.c \
- ao_romconfig.c \
- ao_usb_avr.c \
- ao_adc_avr.c \
- ao_science_slave.c \
- ao_spi_slave.c \
- $(TELESCIENCE_STORAGE)\
- $(TELESCIENCE_LOG)
-
-PRODUCT=TeleScience-v0.1
-MCU=atmega32u4
-PRODUCT_DEF=-DTELESCIENCE
-IDPRODUCT=0x0011
-CFLAGS = $(PRODUCT_DEF) -I. -I../avr -I../kernel -I..
-CFLAGS += -g -mmcu=$(MCU) -Wall -Wstrict-prototypes -O3 -mcall-prologues -DAVR
-
-NICKLE=nickle
-
-PROG=telescience-v0.1
-
-SRC=$(ALTOS_SRC) ao_telescience.c
-OBJ=$(SRC:.c=.o)
-
-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)
-
-CHECK=sh ../util/check-avr-mem
-
-$(PROG): Makefile $(OBJ)
- $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ)
- $(call quiet,CHECK) $(PROG) || ($(RM) -f $(PROG); exit 1)
-
-$(PROG).hex: $(PROG)
- avr-size $(PROG)
- $(OBJCOPY) -R .eeprom -O ihex $(PROG) $@
-
-
-load: $(PROG).hex
- $(LOADCMD) $(LOADARG)$(PROG).hex
-
-ao_product.h: ao-make-product.5c ../Version
- $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
-
-ao_product.o: ao_product.c ao_product.h
-
-%.o : %.c $(INC)
- $(call quiet,CC) -c $(CFLAGS) $<
-
-distclean: clean
-
-clean:
- rm -f *.o $(PROG) $(PROG).hex
- rm -f ao_product.h
-
-install:
-
-uninstall:
-
-$(OBJ): ao_product.h $(INC)
diff --git a/src/telescience-v0.2/.gitignore b/src/telescience-v0.2/.gitignore
deleted file mode 100644
index cc1f8b73..00000000
--- a/src/telescience-v0.2/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-ao_product.h
-telescience-*.elf
diff --git a/src/telescience-v0.2/ao_pins.h b/src/telescience-v0.2/ao_pins.h
deleted file mode 100644
index 29f16114..00000000
--- a/src/telescience-v0.2/ao_pins.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright © 2012 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.
- */
-
-#ifndef _AO_PINS_H_
-#define _AO_PINS_H_
-
-#define HAS_TASK_QUEUE 1
-
-/* 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_SERIAL_1 0
-#define USE_SERIAL_1_STDIN 0
-#define SERIAL_1_PB6_PB7 0
-#define SERIAL_1_PA9_PA10 1
-
-#define HAS_SERIAL_2 0
-#define USE_SERIAL_2_STDIN 0
-#define SERIAL_2_PA2_PA3 0
-#define SERIAL_2_PD5_PD6 0
-
-#define HAS_SERIAL_3 0
-#define USE_SERIAL_3_STDIN 0
-#define SERIAL_3_PB10_PB11 0
-#define SERIAL_3_PC10_PC11 1
-#define SERIAL_3_PD8_PD9 0
-
-#define HAS_EEPROM 1
-#define USE_INTERNAL_FLASH 0
-#define HAS_USB 1
-#define HAS_BEEP 0
-#define HAS_RADIO 0
-#define HAS_TELEMETRY 0
-#define PACKET_HAS_SLAVE 0
-
-#define HAS_SPI_1 0
-#define HAS_SPI_SLAVE_1 1
-#define SPI_1_PA5_PA6_PA7 1
-#define SPI_1_PB3_PB4_PB5 0
-#define SPI_1_PE13_PE14_PE15 0
-#define SPI_1_OSPEEDR STM_OSPEEDR_10MHz
-
-#define HAS_SPI_2 1
-#define SPI_2_PB13_PB14_PB15 1
-#define SPI_2_PD1_PD3_PD4 0
-#define SPI_2_OSPEEDR STM_OSPEEDR_10MHz
-
-#define SPI_2_PORT (&stm_gpiob)
-#define SPI_2_SCK_PIN 13
-#define SPI_2_MISO_PIN 14
-#define SPI_2_MOSI_PIN 15
-#define SPI_SLAVE_INDEX 1
-
-#define HAS_I2C_1 0
-#define I2C_1_PB8_PB9 0
-
-#define HAS_I2C_2 0
-#define I2C_2_PB10_PB11 0
-
-#define LOW_LEVEL_DEBUG 0
-
-#define LED_PORT_0_ENABLE STM_RCC_AHBENR_GPIOAEN
-
-#define LED_PORT_0 (&stm_gpioa)
-#define LED_PORT_0_MASK (0xff)
-#define LED_PORT_0_SHIFT 0
-#define LED_PIN_RED 8
-#define LED_PIN_GREEN 9
-#define AO_LED_RED (1 << LED_PIN_RED)
-#define AO_LED_GREEN (1 << LED_PIN_GREEN)
-
-#define LEDS_AVAILABLE (AO_LED_RED | AO_LED_GREEN)
-
-#define HAS_GPS 0
-#define HAS_FLIGHT 0
-#define HAS_ADC 1
-#define HAS_ADC_TEMP 1
-#define HAS_LOG 1
-#define AO_LOG_FORMAT AO_LOG_FORMAT_TELESCIENCE
-
-/*
- * SPI Flash memory
- */
-
-#define M25_MAX_CHIPS 1
-#define AO_M25_SPI_CS_PORT (&stm_gpioa)
-#define AO_M25_SPI_CS_MASK (1 << 3)
-#define AO_M25_SPI_BUS AO_SPI_2_PB13_PB14_PB15
-
-/*
- * ADC
- */
-
-#define AO_DATA_RING 32
-#define AO_ADC_NUM 1
-
-struct ao_adc {
- int16_t adc[AO_ADC_NUM];
-};
-
-#define AO_ADC_TEMP 16
-
-#define AO_ADC_RCC_AHBENR 0
-
-#define AO_NUM_ADC_PIN 0
-
-#define AO_NUM_ADC 1
-
-#define AO_ADC_SQ1 AO_ADC_TEMP
-
-
-#endif /* _AO_PINS_H_ */
diff --git a/src/telescience-v0.2/ao_telescience.c b/src/telescience-v0.2/ao_telescience.c
deleted file mode 100644
index 05bb8653..00000000
--- a/src/telescience-v0.2/ao_telescience.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright © 2012 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>
-#include <ao_exti.h>
-#include <ao_packet.h>
-#include <ao_send_packet.h>
-
-int
-main(void)
-{
- ao_clock_init();
-
-#if HAS_STACK_GUARD
- ao_mpu_init();
-#endif
-
- ao_led_init(LEDS_AVAILABLE);
- ao_led_on(AO_LED_GREEN);
-
- ao_task_init();
-
- ao_timer_init();
-
- ao_spi_init();
- ao_spi_slave_init();
- ao_dma_init();
- ao_exti_init();
-
- ao_cmd_init();
-
- ao_usb_init();
- ao_config_init();
-
- ao_storage_init();
-
- ao_start_scheduler();
- return 0;
-}
diff --git a/src/telescience-v0.2/flash-loader/Makefile b/src/telescience-v0.2/flash-loader/Makefile
deleted file mode 100644
index 7a2ceb77..00000000
--- a/src/telescience-v0.2/flash-loader/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# AltOS flash loader build
-#
-#
-
-TOPDIR=../..
-HARDWARE=telescience-v0.2
-include $(TOPDIR)/stm/Makefile-flash.defs
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 <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"
-
-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 <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.
- */
-
-#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 <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"
-
-#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.1/.gitignore b/src/teleterra-v0.1/.gitignore
deleted file mode 100644
index 447007ce..00000000
--- a/src/teleterra-v0.1/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-teleterra-v0.1*
-ao_product.h
diff --git a/src/teleterra-v0.1/ao_pins.h b/src/teleterra-v0.1/ao_pins.h
deleted file mode 100644
index d25a77b7..00000000
--- a/src/teleterra-v0.1/ao_pins.h
+++ /dev/null
@@ -1,213 +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.
- */
-
-#ifndef _AO_PINS_H_
-#define _AO_PINS_H_
-
-#ifdef TELETERRA_V_0_1
- #define HAS_FLIGHT 0
- #define HAS_USB 1
- #define HAS_BEEP 0
- #define HAS_GPS 0
- #define HAS_SERIAL_1 0
- #define HAS_ADC 0
- #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_COMPANION 1
- #define COMPANION_CS_ON_P1 1
- #define COMPANION_CS_MASK 0x4 /* CS1 is P1_2 */
- #define 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 0
- #define HAS_IGNITE 0
- #define HAS_MONITOR 1
- #define HAS_RSSI 0
- #define HAS_AES 1
-
- #define SPI_CS_ON_P1 0
- #define SPI_CS_ON_P0 1
- #define M25_CS_MASK 0xf
- #define M25_MAX_CHIPS 4
-#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)
-
-#endif /* _AO_PINS_H_ */
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 <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.
- */
-
-#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/test/ao_aes_test.c b/src/test/ao_aes_test.c
index 135c6f1a..e1ed5728 100644
--- a/src/test/ao_aes_test.c
+++ b/src/test/ao_aes_test.c
@@ -16,11 +16,7 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#define __pdata
-#define __data
-#define __xdata
-#define __code
-#define __reentrant
+#define const
#include <string.h>
#include <stdio.h>
diff --git a/src/test/ao_eeprom_read.h b/src/test/ao_eeprom_read.h
index 03c327ca..afaadb1e 100644
--- a/src/test/ao_eeprom_read.h
+++ b/src/test/ao_eeprom_read.h
@@ -15,11 +15,7 @@
#ifndef _AO_EEPROM_READ_H_
#define _AO_EEPROM_READ_H_
-#define __pdata
-#define __data
-#define __xdata
-#define __code
-#define __reentrant
+#define const
#include <stdint.h>
#include <stdio.h>
diff --git a/src/test/ao_flight_test.c b/src/test/ao_flight_test.c
index 746a6814..6d007575 100644
--- a/src/test/ao_flight_test.c
+++ b/src/test/ao_flight_test.c
@@ -119,11 +119,7 @@ struct ao_adc {
#endif
-#define __pdata
-#define __data
-#define __xdata
-#define __code
-#define __reentrant
+#define const
#define HAS_FLIGHT 1
#define HAS_IGNITE 1
@@ -231,8 +227,8 @@ ao_gps_angle(void)
extern enum ao_flight_state ao_flight_state;
-#define FALSE 0
-#define TRUE 1
+#define false 0
+#define true 1
volatile struct ao_data ao_data_ring[AO_DATA_RING];
volatile uint8_t ao_data_head;
@@ -362,7 +358,7 @@ struct ao_ms5607_prom ao_ms5607_prom;
struct ao_config ao_config;
-#define DATA_TO_XDATA(x) (x)
+#define x (x)
extern int16_t ao_ground_accel, ao_flight_accel;
diff --git a/src/test/ao_gps_test_skytraq.c b/src/test/ao_gps_test_skytraq.c
index 61e7905a..11c54601 100644
--- a/src/test/ao_gps_test_skytraq.c
+++ b/src/test/ao_gps_test_skytraq.c
@@ -83,8 +83,8 @@ struct ao_gps_tracking_orig {
#define ao_telemetry_satellite ao_gps_tracking_orig
#define ao_telemetry_satellite_info ao_gps_sat_orig
-extern __xdata struct ao_telemetry_location ao_gps_data;
-extern __xdata struct ao_telemetry_satellite ao_gps_tracking_data;
+extern struct ao_telemetry_location ao_gps_data;
+extern struct ao_telemetry_satellite ao_gps_tracking_data;
uint8_t ao_gps_mutex;
diff --git a/src/test/ao_gps_test_ublox.c b/src/test/ao_gps_test_ublox.c
index 05334bbf..0833e4f6 100644
--- a/src/test/ao_gps_test_ublox.c
+++ b/src/test/ao_gps_test_ublox.c
@@ -89,8 +89,8 @@ struct ao_telemetry_satellite {
#define ao_gps_tracking_orig ao_telemetry_satellite
#define ao_gps_sat_orig ao_telemetry_satellite_info
-extern __xdata struct ao_telemetry_location ao_gps_data;
-extern __xdata struct ao_telemetry_satellite ao_gps_tracking_data;
+extern struct ao_telemetry_location ao_gps_data;
+extern struct ao_telemetry_satellite ao_gps_tracking_data;
uint8_t ao_gps_mutex;
diff --git a/src/test/ao_int64_test.c b/src/test/ao_int64_test.c
index d329f67b..c7a4891f 100644
--- a/src/test/ao_int64_test.c
+++ b/src/test/ao_int64_test.c
@@ -16,10 +16,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#define __data
-#define __pdata
-#define __xdata
-#define __reentrant
#include <ao_int64.h>
#include <ao_int64.c>
diff --git a/src/test/ao_ms5607_convert_test.c b/src/test/ao_ms5607_convert_test.c
index 4876d21e..7708c331 100644
--- a/src/test/ao_ms5607_convert_test.c
+++ b/src/test/ao_ms5607_convert_test.c
@@ -16,10 +16,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#define __xdata
-#define __data
-#define __pdata
-#define __reentrant
#include <stdint.h>
#include <ao_ms5607.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/src/tmgps-v2.0/Makefile b/src/tmgps-v2.0/Makefile
index 9e3965c6..8a1293d2 100644
--- a/src/tmgps-v2.0/Makefile
+++ b/src/tmgps-v2.0/Makefile
@@ -46,7 +46,7 @@ ALTOS_SRC = \
ao_cmd.c \
ao_config.c \
ao_task.c \
- ao_led.c \
+ ao_led_stm.c \
ao_stdio.c \
ao_panic.c \
ao_timer.c \
diff --git a/src/usbrelay-v0.1/ao_usbrelay.c b/src/usbrelay-v0.1/ao_usbrelay.c
index d908f4db..946f4b12 100644
--- a/src/usbrelay-v0.1/ao_usbrelay.c
+++ b/src/usbrelay-v0.1/ao_usbrelay.c
@@ -45,21 +45,20 @@ ao_relay_control(uint8_t output)
}
static void
-ao_relay_select(void) __reentrant
+ao_relay_select(void)
{
uint8_t output;
- ao_cmd_decimal();
+ output = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- output = ao_cmd_lex_i;
if (output > 1)
printf ("Invalid relay position %u\n", output);
else
ao_relay_control(output);
}
-static __code struct ao_cmds ao_relay_cmds[] = {
+static const struct ao_cmds ao_relay_cmds[] = {
{ ao_relay_select, "R <output>\0Select relay output" },
{ 0, NULL }
};
diff --git a/src/usbtrng-v2.0/.gitignore b/src/usbtrng-v2.0/.gitignore
deleted file mode 100644
index 93b38d11..00000000
--- a/src/usbtrng-v2.0/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-ao_product.h
-usbtrng-*
diff --git a/src/usbtrng-v2.0/Makefile b/src/usbtrng-v2.0/Makefile
deleted file mode 100644
index 49798f1c..00000000
--- a/src/usbtrng-v2.0/Makefile
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# AltOS build
-#
-#
-
-include ../stmf0/Makefile.defs
-
-INC = \
- ao.h \
- ao_arch.h \
- ao_arch_funcs.h \
- ao_pins.h \
- ao_product.h \
- ao_task.h \
- ao_adc_fast.h \
- stm32f0.h
-
-#
-# Common AltOS sources
-#
-ALTOS_SRC = \
- ao_interrupt.c \
- ao_timer.c \
- ao_panic.c \
- ao_mutex.c \
- ao_dma_stm.c \
- ao_adc_fast.c \
- ao_crc_stm.c \
- ao_stdio.c \
- ao_led.c \
- ao_romconfig.c \
- ao_boot_chain.c \
- ao_cmd.c \
- ao_usb_stm.c \
- ao_trng.c \
- ao_task.c \
- ao_product.c
-
-PRODUCT=usbtrng-v2.0
-PRODUCT_DEF=-DUSBTRNG_V_2_0
-IDPRODUCT=0x0028
-
-CFLAGS = $(PRODUCT_DEF) $(STMF0_CFLAGS) -g -Os
-
-PROGNAME=usbtrng-v2.0
-PROG=$(PROGNAME)-$(VERSION).elf
-HEX=$(PROGNAME)-$(VERSION).ihx
-
-SRC=$(ALTOS_SRC) ao_usbtrng.c
-OBJ=$(SRC:.c=.o)
-
-all: $(PROG) $(HEX)
-
-$(PROG): Makefile $(OBJ) altos.ld
- $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS)
-
-ao_product.h: ao-make-product.5c ../Version
- $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
-
-$(OBJ): $(INC)
-
-distclean: clean
-
-clean:
- rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx
- rm -f ao_product.h
-
-install:
-
-uninstall:
diff --git a/src/usbtrng-v2.0/ao_pins.h b/src/usbtrng-v2.0/ao_pins.h
deleted file mode 100644
index 2b23f967..00000000
--- a/src/usbtrng-v2.0/ao_pins.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright © 2015 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.
- */
-
-#ifndef _AO_PINS_H_
-#define _AO_PINS_H_
-
-#define LED_PORT_ENABLE STM_RCC_AHBENR_IOPAEN
-#define LED_PORT (&stm_gpioa)
-#define LED_PIN_RED 2
-#define LED_PIN_GREEN 3
-#define AO_LED_RED (1 << LED_PIN_RED)
-#define AO_LED_GREEN (1 << LED_PIN_GREEN)
-
-#define LEDS_AVAILABLE (AO_LED_RED | AO_LED_GREEN)
-
-#define HAS_BEEP 0
-
-/* 48MHz clock based on USB */
-#define AO_HSI48 1
-
-/* HCLK = 48MHz */
-#define AO_AHB_PRESCALER 1
-#define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1
-
-/* APB = 48MHz */
-#define AO_APB_PRESCALER 1
-#define AO_RCC_CFGR_PPRE_DIV STM_RCC_CFGR_PPRE_DIV_1
-
-#define HAS_USB 1
-#define AO_USB_DIRECTIO 1
-#define AO_PA11_PA12_RMP 0
-
-#define IS_FLASH_LOADER 0
-
-/* ADC */
-
-#define AO_ADC_PIN0_PORT (&stm_gpioa)
-#define AO_ADC_PIN0_PIN 6
-#define AO_ADC_PIN0_CH 6
-
-#define AO_ADC_RCC_AHBENR ((1 << STM_RCC_AHBENR_IOPAEN))
-
-#define AO_NUM_ADC 1
-
-/* CRC */
-#define AO_CRC_WIDTH 32
-#define AO_CRC_INIT 0xffffffff
-
-/* TRNG */
-#define AO_LED_TRNG_READ AO_LED_RED
-#define AO_LED_TRNG_WRITE AO_LED_GREEN
-
-#endif /* _AO_PINS_H_ */
diff --git a/src/usbtrng-v2.0/ao_usbtrng.c b/src/usbtrng-v2.0/ao_usbtrng.c
deleted file mode 100644
index e34babec..00000000
--- a/src/usbtrng-v2.0/ao_usbtrng.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright © 2014 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>
-#include <ao_adc_fast.h>
-#include <ao_crc.h>
-#include <ao_trng.h>
-
-void main(void)
-{
- ao_led_init(LEDS_AVAILABLE);
- ao_led_on(AO_LED_RED);
- ao_clock_init();
- ao_task_init();
- ao_timer_init();
- ao_dma_init();
- ao_adc_init();
- ao_crc_init();
-
- ao_cmd_init();
-
- ao_usb_init();
-
- ao_trng_init();
-
- ao_led_off(AO_LED_RED);
-
- ao_start_scheduler();
-}
diff --git a/src/usbtrng-v2.0/flash-loader/.gitignore b/src/usbtrng-v2.0/flash-loader/.gitignore
deleted file mode 100644
index 32dbbbcf..00000000
--- a/src/usbtrng-v2.0/flash-loader/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-ao_product.h
-usbtrng*
diff --git a/src/usbtrng-v2.0/flash-loader/Makefile b/src/usbtrng-v2.0/flash-loader/Makefile
deleted file mode 100644
index a2bf199f..00000000
--- a/src/usbtrng-v2.0/flash-loader/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# AltOS flash loader build
-#
-#
-
-TOPDIR=../..
-HARDWARE=usbtrng-v2.0
-include $(TOPDIR)/stmf0/Makefile-flash.defs
diff --git a/src/usbtrng-v2.0/flash-loader/ao_pins.h b/src/usbtrng-v2.0/flash-loader/ao_pins.h
deleted file mode 100644
index 9e7c2c33..00000000
--- a/src/usbtrng-v2.0/flash-loader/ao_pins.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright © 2013 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.
- */
-
-#ifndef _AO_PINS_H_
-#define _AO_PINS_H_
-
-#include <ao_flash_stm_pins.h>
-
-/* Red LED */
-
-#define AO_BOOT_PIN 1
-#define AO_BOOT_APPLICATION_GPIO stm_gpioa
-#define AO_BOOT_APPLICATION_PIN 2
-#define AO_BOOT_APPLICATION_VALUE 0
-#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_DOWN
-
-#endif /* _AO_PINS_H_ */
diff --git a/src/usbtrng/Makefile b/src/usbtrng/Makefile
deleted file mode 100644
index 80e137e7..00000000
--- a/src/usbtrng/Makefile
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# AltOS build
-#
-#
-
-include ../lpc/Makefile.defs
-
-INC = \
- ao.h \
- ao_arch.h \
- ao_arch_funcs.h \
- ao_pins.h \
- ao_product.h \
- lpc.h
-
-#
-# Common AltOS sources
-#
-ALTOS_SRC = \
- ao_interrupt.c \
- ao_boot_chain.c \
- ao_romconfig.c \
- ao_product.c \
- ao_mutex.c \
- ao_panic.c \
- ao_stdio.c \
- ao_task.c \
- ao_cmd.c \
- ao_timer_lpc.c \
- ao_exti_lpc.c \
- ao_usb_lpc.c \
- ao_serial_lpc.c \
- ao_spi_lpc.c \
- ao_led_lpc.c
-
-PRODUCT=usbtrng-v0.1
-PRODUCT_DEF=-DUSBTRNG_V_0_1
-IDPRODUCT=0x0028
-
-CFLAGS = $(PRODUCT_DEF) $(LPC_CFLAGS) -g -Os
-
-PROGNAME=usbtrng-v0.1
-PROG=$(PROGNAME)-$(VERSION).elf
-HEX=$(PROGNAME)-$(VERSION).ihx
-
-SRC=$(ALTOS_SRC) ao_usbtrng.c
-OBJ=$(SRC:.c=.o)
-
-all: $(PROG) $(HEX)
-
-$(PROG): Makefile $(OBJ) altos.ld
- $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS)
-
-ao_product.h: ao-make-product.5c ../Version
- $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
-
-$(OBJ): $(INC)
-
-load: $(PROG)
- lpc-load $(PROG)
-
-distclean: clean
-
-clean:
- rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx
- rm -f ao_product.h
-
-install:
-
-uninstall:
diff --git a/src/usbtrng/ao_pins.h b/src/usbtrng/ao_pins.h
deleted file mode 100644
index 2fd5df33..00000000
--- a/src/usbtrng/ao_pins.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright © 2013 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.
- */
-
-#define HAS_BEEP 0
-
-#define AO_STACK_SIZE 384
-
-#define IS_FLASH_LOADER 0
-
-/* Crystal on the board */
-#define AO_LPC_CLKIN 12000000
-
-/* Main clock frequency. 48MHz for USB so we don't use the USB PLL */
-#define AO_LPC_CLKOUT 48000000
-
-/* System clock frequency */
-#define AO_LPC_SYSCLK 24000000
-
-#define HAS_USB 1
-
-#define HAS_USB_CONNECT 0
-#define HAS_USB_VBUS 0
-#define HAS_USB_PULLUP 1
-#define AO_USB_PULLUP_PORT 0
-#define AO_USB_PULLUP_PIN 6
-
-/* USART */
-
-#define HAS_SERIAL 1
-#define USE_SERIAL_0_STDIN 0
-#define SERIAL_0_18_19 1
-#define SERIAL_0_14_15 0
-#define SERIAL_0_17_18 0
-#define SERIAL_0_26_27 0
-
-/* SPI */
-
-#define HAS_SPI_0 0
-#define SPI_SCK0_P0_6 0
-#define HAS_SPI_1 1
-#define SPI_SCK1_P1_15 0
-#define SPI_MISO1_P0_22 1
-#define SPI_MOSI1_P0_21 0
-
-/* LED */
-
-#define LED_PORT 0
-#define LED_PIN_RED 3
-#define LED_PIN_GREEN 21
-#define AO_LED_RED (1 << LED_PIN_RED)
-#define AO_LED_GREEN (1 << LED_PIN_GREEN)
-
-#define LEDS_AVAILABLE (AO_LED_RED|AO_LED_GREEN)
-
-/* Kludge the SPI driver to not configure any
- * pin for SCK or MOSI
- */
-#define HAS_SCK1 0
-#define HAS_MOSI1 0
-
-#define AO_ADC_6 1
diff --git a/src/usbtrng/ao_usbtrng.c b/src/usbtrng/ao_usbtrng.c
deleted file mode 100644
index cb15a250..00000000
--- a/src/usbtrng/ao_usbtrng.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright © 2014 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>
-
-#define AO_TRNG_SPI_BUS 1
-
-static uint32_t spi_speed = AO_SPI_SPEED_4MHz;
-
-#define AO_TRNG_SPI_BUF 1024
-
-#if 0
-
-static uint8_t *spi_buf;
-static uint8_t *spi_head, *spi_tail;
-static uint8_t spi_wakeup;
-
-static void
-ao_trng_run(void)
-{
- int this_time;
- uint8_t *end;
-
- if (!spi_buf)
- spi_buf = ao_usb_alloc(AO_TRNG_SPI_BUF);
- flush();
- ao_spi_get(AO_TRNG_SPI_BUS, spi_speed);
- spi_tail = spi_buf;
- spi_head = spi_buf;
- ao_spi_recv_ring_start(spi_buf, AO_TRNG_SPI_BUF, &spi_head, &spi_tail, &spi_wakeup, AO_TRNG_SPI_BUS);
- while (!ao_usb_out_avail) {
- ao_arch_block_interrupts();
- while (spi_head == spi_tail) {
- spi_wakeup = 0;
- ao_sleep(&spi_wakeup);
- }
- ao_arch_release_interrupts();
- if (spi_tail > spi_head)
- end = spi_buf + AO_TRNG_SPI_BUF;
- else
- end = spi_head;
- this_time = end - spi_tail;
- if (this_time > 64)
- this_time = 64;
- ao_usb_write(spi_tail, this_time);
- spi_tail += this_time;
- if (spi_tail == spi_buf + AO_TRNG_SPI_BUF)
- spi_tail = spi_buf;
- }
- ao_spi_put(AO_TRNG_SPI_BUS);
- getchar();
-}
-
-
-static void
-ao_trng_test(void)
-{
- static uint8_t random[32];
- uint8_t i;
-
- ao_spi_get(AO_TRNG_SPI_BUS, spi_speed);
- ao_spi_recv(random, sizeof (random), AO_TRNG_SPI_BUS);
- ao_spi_put(AO_TRNG_SPI_BUS);
- for (i = 0; i < sizeof (random); i++)
- printf (" %02x", random[i]);
- printf ("\n");
-}
-#endif
-
-#define ADC_RING_SIZE 512
-
-static uint8_t *adc_ring;
-static uint16_t adc_head, adc_tail;
-static uint16_t adc_wake;
-
-void lpc_adc_isr(void)
-{
- uint16_t avail;
- uint16_t this, next;
-
- this = adc_head;
- next = (this + 1) & (ADC_RING_SIZE - 1);
- if (next == adc_tail) {
- lpc_adc.inten = 0;
- return;
- }
- adc_ring[this] = lpc_adc.dr[6] >> 8;
- adc_head = next;
-
- /* If there are enough entries, wake up any waiters
- */
- avail = (next - adc_tail) & (ADC_RING_SIZE - 1);
- if (avail >= adc_wake) {
- adc_wake = 0;
- ao_wakeup(&adc_wake);
- }
-}
-
-#define AO_ADC_CLKDIV (AO_LPC_SYSCLK / 450000)
-
-static void
-ao_trng_adc_init(void)
-{
- adc_ring = ao_usb_alloc(ADC_RING_SIZE);
-
- lpc_scb.sysahbclkctrl |= (1 << LPC_SCB_SYSAHBCLKCTRL_ADC);
- lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_ADC_PD);
-
- /* Enable interrupt when AO_ADC_6 is complete */
- lpc_adc.inten = 0;
-
- lpc_nvic_set_enable(LPC_ISR_ADC_POS);
- lpc_nvic_set_priority(LPC_ISR_ADC_POS, AO_LPC_NVIC_CLOCK_PRIORITY);
-
-#if AO_ADC_0
- ao_enable_analog(0, 11, 0);
-#endif
-#if AO_ADC_1
- ao_enable_analog(0, 12, 1);
-#endif
-#if AO_ADC_2
- ao_enable_analog(0, 13, 2);
-#endif
-#if AO_ADC_3
- ao_enable_analog(0, 14, 3);
-#endif
-#if AO_ADC_4
- ao_enable_analog(0, 15, 4);
-#endif
-#if AO_ADC_5
- ao_enable_analog(0, 16, 5);
-#endif
-#if AO_ADC_6
- ao_enable_analog(0, 22, 6);
-#endif
-#if AO_ADC_7
- ao_enable_analog(0, 23, 7);
-#endif
-
- lpc_adc.cr = ((1 << (LPC_ADC_CR_SEL + 6)) |
- (AO_ADC_CLKDIV << LPC_ADC_CR_CLKDIV) |
- (1 << LPC_ADC_CR_BURST) |
- (LPC_ADC_CR_CLKS_9 << LPC_ADC_CR_CLKS));
-}
-
-static void
-ao_trng_adc_dump(void)
-{
- int i;
-
- while (((adc_head - adc_tail) & (ADC_RING_SIZE - 1)) < 16) {
- lpc_adc.inten = (1 << (LPC_ADC_INTEN_ADINTEN + 6));
- adc_wake = 16;
- ao_sleep(&adc_wake);
- }
- printf("adc_head %d tail %d\n", adc_head, adc_tail);
-
- for (i = 0; i < 16; i++) {
- printf(" %4d", adc_ring[adc_tail]);
- adc_tail = (adc_tail + 1) & (ADC_RING_SIZE - 1);
- }
- printf("\n");
- lpc_adc.inten = 0;
-}
-
-static void
-ao_trng_run(void)
-{
- uint16_t this_time;
- flush();
-
- while (!ao_usb_out_avail) {
- ao_arch_block_interrupts();
- while (((adc_head - adc_tail) & (ADC_RING_SIZE - 1)) < 64) {
- lpc_adc.inten = (1 << (LPC_ADC_INTEN_ADINTEN + 6));
- adc_wake = 64;
- ao_sleep(&adc_wake);
- }
- ao_arch_release_interrupts();
-
- this_time = ADC_RING_SIZE - adc_tail;
- if (this_time > 64)
- this_time = 64;
- ao_usb_write(&adc_ring[adc_tail], this_time);
- adc_tail = (adc_tail + this_time) & (ADC_RING_SIZE - 1);
- }
- lpc_adc.inten = 0;
-}
-
-static void
-ao_trng_speed(void)
-{
- ao_cmd_decimal();
-
- if (ao_cmd_lex_u32 == 0 || ao_cmd_status != ao_cmd_success) {
- ao_cmd_status = ao_cmd_success;
- printf ("Current spi speed %d\n", spi_speed);
- } else {
- spi_speed = ao_cmd_lex_u32;
- }
-}
-
-static const struct ao_cmds ao_trng_cmds[] = {
-// { ao_trng_test, "R\0Dump some random numbers" },
- { ao_trng_run, "s\0Send random bits until char" },
- { ao_trng_speed, "S <speed>\0Set SPI speed (48MHz/speed)" },
- { ao_trng_adc_dump, "a\0Dump ADC data" },
- { 0, NULL }
-};
-
-void
-main(void)
-{
- ao_clock_init();
- ao_task_init();
- ao_timer_init();
-
-// ao_spi_init();
- ao_usb_init();
-
- ao_trng_adc_init();
-
- ao_serial_init();
-
- ao_led_init(LEDS_AVAILABLE);
-
- ao_cmd_init();
-
- ao_cmd_register(ao_trng_cmds);
-
- ao_start_scheduler();
-}
diff --git a/src/usbtrng/flash-loader/Makefile b/src/usbtrng/flash-loader/Makefile
deleted file mode 100644
index e34f1089..00000000
--- a/src/usbtrng/flash-loader/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# AltOS flash loader build
-#
-#
-
-TOPDIR=../..
-HARDWARE=usbtrng-v0.1
-include $(TOPDIR)/lpc/Makefile-flash.defs
diff --git a/src/usbtrng/flash-loader/ao_pins.h b/src/usbtrng/flash-loader/ao_pins.h
deleted file mode 100644
index cb385600..00000000
--- a/src/usbtrng/flash-loader/ao_pins.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright © 2013 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.
- */
-
-#ifndef _AO_PINS_H_
-#define _AO_PINS_H_
-
-#include <ao_flash_lpc_pins.h>
-
-#define AO_BOOT_PIN 1
-#define AO_BOOT_APPLICATION_GPIO 0
-#define AO_BOOT_APPLICATION_PIN 19
-#define AO_BOOT_APPLICATION_VALUE 1
-#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP
-
-#define HAS_USB_PULLUP 1
-#define AO_USB_PULLUP_PORT 0
-#define AO_USB_PULLUP_PIN 6
-
-#endif /* _AO_PINS_H_ */
diff --git a/src/vidtime/ao_vidtime.c b/src/vidtime/ao_vidtime.c
index 1b9b9e1c..e9f8b218 100644
--- a/src/vidtime/ao_vidtime.c
+++ b/src/vidtime/ao_vidtime.c
@@ -63,9 +63,9 @@ ao_init_vidtime(void)
static void
ao_set_vidtime(void)
{
- ao_cmd_decimal();
+ uint16_t r = ao_cmd_decimal();
if (ao_cmd_status == ao_cmd_success) {
- vidtime_monitor = ao_cmd_lex_i != 0;
+ vidtime_monitor = r != 0;
ao_wakeup(&vidtime_monitor);
}
}
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"