summaryrefslogtreecommitdiff
path: root/src/stm
Commit message (Collapse)AuthorAge
* altos/stm: Align 'data' to 8 bytes, just like textramKeith Packard2017-12-12
| | | | | | | | | | | | | | The textram section must be aligned to 8 bytes to keep the linker happy. However, if that section contains no data, the declaration will set the __data_start__ value to that alignment, but the data section itself would start on a 4-byte alignment, potentially 4 bytes lower than the value indicated by __data_start__. This completely scrambles initialized memory as the startup code will copy the data segment to __data_start__, 4 bytes off of the actual data segment start. Fix this by forcing the data segment to also be aligned to 8 bytes. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: Actually store current MPU9250 data in data ringKeith Packard2017-12-11
| | | | | | | The ring is updated when the ADC finishes; all of the other sensor data needs to be copied in at that point. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: Allow building with newlib + avr stdio on ARMKeith Packard2017-12-11
| | | | | | | Redefines some stdio bits so that we can build with either pdclib or newlib + avr stdio. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/cortexelf-v1: Adapt to lisp->scheme name changeKeith Packard2017-12-05
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Add AO_EXTI_MODE_PULL_NONEKeith Packard2017-11-11
| | | | | | This is clearer than using '0'. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: whitespace cleanup in ao_adc_stm.cKeith Packard2017-11-11
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stmf0: Initialize UART RTS/CTS before turning it onKeith Packard2017-06-27
| | | | | | If you try this after the UART is running, it won't work. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: Make CDC ACM 'line coding' publicKeith Packard2017-05-04
| | | | | | This allows other systems to see what baud rate the host has requested. Signed-off-by: Keith Packard <keithp@keithp.com>
* stm: Add more mask-based GPIO controlsKeith Packard2017-04-04
| | | | | | | Lets cortexelf do more things with groups of pins, rather than one pin at a time. Signed-off-by: Keith Packard <keithp@keithp.com>
* stm: Add a few more GPIO functions to make dealing with the 1802 easierKeith Packard2017-04-03
| | | | | | ao_gpio_set_mask and ao_gpio_get_all Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: add button matrix driverKeith Packard2017-04-02
| | | | | | Scans the matrix once per clock tick queuing events for changed keys. Signed-off-by: Keith Packard <keithp@keithp.com>
* stm: Use common flash wait loop instead of inliningKeith Packard2017-04-02
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* cortexelf-v1: Use new memory map to access all flash and ram. Add fat.Keith Packard2017-04-02
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Add draw and lisp to make search paths.Keith Packard2017-02-20
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Add nvic priority register fields. Add more TIM234 defines.Keith Packard2017-02-20
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Make i2c code handle PCLK1 of 24MHzKeith Packard2017-02-20
| | | | | | Just adds the necessary defines to the code. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Allow DMA channels to be hijacked by other codeKeith Packard2017-02-20
| | | | | | | This lets code which needs finer control over DMA to use the channel without interference, and leaves the DMA engine running so that it can. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Allow use basepri instead of primask for masking interruptsKeith Packard2017-02-20
| | | | | | | | | | | | This allows for high priority interrupts (priority 0) to run, even when other interrupts are blocked. Code executing in such interrupt handlers must not attempt to control task execution as that will race with the scheduler. Select this by defining AO_NONMASK_INTERRUPT in ao_pins.h. non-maskable interrupt priority is AO_STM_NVIC_NONMASK_PRIORITY Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Interrupt priority is in the upper bits of the priority maskKeith Packard2017-02-20
| | | | | | | | | | Because the STM32L only offers 16 priority levels, the bottom four bits of each priority mask are not used. All of the interrupt priority settings in the system were using values < 16, making them all effectively the same. Fix that by moving them into the upper 4 bits and using symbolic constants everywhere. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/arm: Align data so that gcc 5.4 doesn't do byte-accesses. Add -Wcast-alignKeith Packard2016-12-17
| | | | | | | | | | | | | | | | | | | | | | Gcc 5.4.1 tracks alignment of data through assignments, so that a uint32_t pointer which comes from byte-aligned uint8_t data: extern uint8_t foo[]; uint32_t *q = (void *) foo; Fetches and stores through this pointer are done bytewise. This is slow (meh), but if q references a device register, things to bad very quickly. This patch works around this bug in the compiler by adding __attribute__((aligned(4))) tags to some variables, or changing them from uint8_t to uint32_t. Places doing this will now be caught as I've added -Wcast-align to the compiler flags. That required adding (void *) casts, after the relevant code was checked to make sure the compiler could tell that the addresses were aligned. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Make ao_usb_set_address static. Saves a bunch of text spaceKeith Packard2016-12-12
| | | | | | | I'm sure this makes the function end up in-lined, which saves enough text space to fit the flash loader in ROM again. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Set SPI slave DMA priority to HIGH/VERY_HIGHKeith Packard2016-09-03
| | | | | | | | | Set spi slave DMA priority MOSI to HIGH and MISO to VERY_HIGH. Slave SPI doesn't have the luxury of slowing down when the system is busy, so provide it maximum memory bandwidth to try and keep up with the master. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Set i2c recv DMA to HIGHKeith Packard2016-09-03
| | | | | | | Make sure receive DMA is higher than any TX dma so that it always runs in preference. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Set MISO DMA priority to HIGH to avoid OVRKeith Packard2016-09-03
| | | | | | | | | When the MISO DMA priority is too low, and the processor gets busy, it's possible for SPI input to overrun the processor, which causes the MISO DMA to get out of sync and never finish. Set the MISO DMA priority to HIGH to avoid this. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Create funcs to set SPI DMA parametersKeith Packard2016-09-03
| | | | | | | | Instead of having nearly duplicate versions of the SPI DMA configuration calls, create helper funcs that do most of the work so that the SPI API funcs are shorter and clearer. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Make ao_spi_duplex out pointer constKeith Packard2016-09-03
| | | | | | Provides a bit better typechecking opportunities for this function. Signed-off-by: Keith Packard <keithp@keithp.com>
* Switch from GPLv2 to GPLv2+Keith Packard2016-07-12
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: clean up ao_exti_enableKeith Packard2016-06-29
| | | | | | Was computing (1 << pin) twice for no good reason. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Add better byte-level SPI apiKeith Packard2016-06-29
| | | | | | | | This provides inline functions for sending and receiving individual bytes, and setup/finish functions to wrap them in. This make the byte sending respect the SPI hardware interface requirements. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Clean up spi_enable/disable_index functionsKeith Packard2016-06-29
| | | | | | These had an extra level of switch nesting for no good reason. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: move spi execution to common ao_spi_runKeith Packard2016-06-29
| | | | | | | | This regularizes SPI hardware use and ensures that the device is turned off after it has been used and that the status register is back to 'normal' the next time through. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: Add STM SPI debuggingKeith Packard2016-06-29
| | | | | | | This dumps out the SPI hardware state and history of SPI operations when compiled with -DDEBUG=1. Without that, this patch does nothing. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: Add STM DMA debuggingKeith Packard2016-06-29
| | | | | | | This provides a command that shows current DMA operations when compiled with -DDEBUG=1. Without that, this patch has no effect. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Change ao_spi_send_sync definition to take const sourceKeith Packard2016-06-29
| | | | | | Provides for a bit better error checking. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Add more SPI status register bitsKeith Packard2016-06-29
| | | | | | These weren't the original version of the docs that we had. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: use 0xff for dma mutex value for allocated mutexesKeith Packard2016-06-29
| | | | | | | DMA channels which are 'allocated' can't be shared. Instead of using the value '1' in the related 'mutex', use 0xff which won't match any task. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: remove ao_dma_abortKeith Packard2016-06-29
| | | | | | This function isn't used anywhere. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: Block interrupts while waking tasks sleeping on timers.Keith Packard2016-06-29
| | | | | | | | Interrupts may not be blocked in the timer ISR, but they need to be while walking the pending timer list and moving tasks back to the run queue. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Handle USB reset in STM32L usb driverKeith Packard2016-06-10
| | | | | | | Just like lpc and stmf0, deal with the host resetting the bus while rebooting by restoring all usb-related data to the initial values. Signed-off-by: Keith Packard <keithp@keithp.com>
* Revert "altos/stm: Run scheduler code on interrupt stack"Keith Packard2016-04-30
| | | | | | This reverts commit 6a9546413d6a236c010e806b50506d870961d074. This causes the device to stop reliably handling interrupts.
* altos/stm32l: Add support for software-driven HW flow controlKeith Packard2016-04-25
| | | | | | | | This allows applications to request that the flow control bits be driven from software rather than hardware, permitting more flexible pin configuration. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: Use TXE instead of TC for serial on STM32lKeith Packard2016-04-25
| | | | | | | Using TXE allows for full-speed communication, rather than waiting for each byte to be transmitted before inserting the next into the queue. Signed-off-by: Keith Packard <keithp@keithp.com>
* Debug bits for telebtKeith Packard2016-04-25
|
* altos: Add ao_gpi_set/clr_bits functionsKeith Packard2016-04-13
| | | | | | These set or clear a group of bits in a single GPIO register all together. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: Add one-byte SPI output routine for LPC and STM coresKeith Packard2016-03-26
| | | | | | This allows for SPI output at interrupt time, one byte at a time. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Allow apps to define different stack sizeKeith Packard2016-03-26
| | | | | | | While 512 bytes is a reasonable size, sometimes apps don't have that much stack space. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Validate current task SP in interrupt by looking at PSPKeith Packard2016-03-26
| | | | | | | | | We use a separate stack pointer for task code, which means we can verify that it is in range in any interrupt handler. This adds checks for the task stack (under #ifdef DEBUG) that run in ao_wakeup as well as at every timer interrupt. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/stm: Run scheduler code on interrupt stackKeith Packard2016-03-26
| | | | | | This provides a bit more room for tasks on their stack Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: Expose fast timer API from kernel/Keith Packard2016-03-18
| | | | | | This allows multiple SoCs to provide the same driver interface Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: Get stm32l pwm driver workingKeith Packard2015-12-25
| | | | | | | | | | | | | Fix the CCMR1_OC1PE and CCMR2_OC3PE values. Disable clock when no PWM outputs are running. Fix the apb1enr value for the timer. Set ARR value to PWM_MAX - 1 -- ARR is off by one. Sets the GPIO pins to 40MHz bandwidth for sharper edges. Tested on EasyMega, but that code is not included as it breaks the companion protocol. Signed-off-by: Keith Packard <keithp@keithp.com>