altos/stm: Add casts to reduce -Wconversion warnings No bugs identified Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Mark local functions 'static' Working towards supporting -Wmissing-prototypes Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Remove 8051 address space specifiers Signed-off-by: Keith Packard <keithp@keithp.com>
altos/flash-loader: On STM, don't include ao_usb_disable This saves a bit of space, keeping the flash loader under 4k on fox Signed-off-by: Keith Packard <keithp@keithp.com>
altos/stm: Simplify ao_usb_write a bit Remove unnecessary 'offset' param (was always passed zero). This also makes some code conditional on that value no longer necessary. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Make CDC ACM 'line coding' public This allows other systems to see what baud rate the host has requested. Signed-off-by: Keith Packard <keithp@keithp.com>
altos/stm: Allow use basepri instead of primask for masking interrupts 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 mask 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-align 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 space 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>
Switch from GPLv2 to GPLv2+ Signed-off-by: Keith Packard <keithp@keithp.com>
altos/stm: Handle USB reset in STM32L usb driver 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>
altos: Expose ao_usb_running globally This lets other bits of the code know when USB has been connected. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Clean up some minor warnings from -Wall Unused variables, functions and labels, missing enums in switch. Signed-off-by: Keith Packard <keithp@keithp.com>
altos/stm: Semantic error in STM usb disable caused it to not work The USB enable register wasn't actually getting rewritten with the enable bit turned off, so the USB device was still powered on in flight. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Use all 16 bits of setup packet len when limiting reply len We were only using the low 8 bits of the setup packet reply max len, which meant that if the other side sent a weird max len (as Windows 7 does), then we'd truncate our setup reply to whatever was in the low 8 bits of that value. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Allow STM usb driver to be used without stdio This lets the self flashing loader be linked without any of the stdio code, which saves a bunch of memory. Signed-off-by: Keith Packard <keithp@keithp.com>
altos/stm: Remove USB EP0 task Handl EP0 actions from interrupt handler. This allows USB to be used in a taskless environment, like the STM flash loader Signed-off-by: Keith Packard <keithp@keithp.com>
altos/stm: Always check for idle IN buffer before sending Unlike the AVR and CC1111 USB drivers, the STM usb driver queues IN bytes in a local buffer instead of in the driver; this means that the driver is queuing bytes while the previous IN packet is queued for the host, which allows for overlapping execution. It also means that when the local buffer is full, we must check to see if the host has picked up the previous IN packet before trying to queue another IN packet for transmission. This is done by always waiting for the IN buffer to be ready before sending data. Signed-off-by: Keith Packard <keithp@keithp.com>
altos/stm: Add debugging mechanism to STM USB driver This adds a pile of debugging hooks to the USB driver to try and isolate various lockup-related issues. It's all disabled by default, of course. Signed-off-by: Keith Packard <keithp@keithp.com>