Commit Graph

5396 Commits (b5816d872d02a7420c05be91bea5f898b88d2e56)

Author SHA1 Message Date
Steven Cooreman 3f61aafd0a removed a line of code duplication 2016-01-12 17:24:49 +01:00
Steven Cooreman 8bec4e22bb PWM refactoring to be less confusing with all the #ifdef for routes 2016-01-12 17:24:47 +01:00
Steven Cooreman 653e91df5d Get rid of the check_usart_clock function which is unused and unnecessary. Usart-specific clocking resides in either spi or serial (or both) api files. 2016-01-12 17:24:44 +01:00
Steven Cooreman 05ce194f25 Move to CMSIS defines to check for presence of certain LF clock trees 2016-01-12 17:24:42 +01:00
Aksel Skauge Mellbye f05fd7fcea EFM32 Pearl Gecko Serial: Remove dynamic peripheral allocation. 2016-01-12 17:24:40 +01:00
Aksel Skauge Mellbye c0ec7ad8d9 EFM32 Pearl Gecko SPI: Remove dynamic resource allocation.
Allocate peripherals to specific subsets of pins. USART0 is available on port A, B and D, while USART1 is available on port C and F.
2016-01-12 17:24:37 +01:00
Aksel Skauge Mellbye 9dff016946 EFM32 Pearl Gecko test pins. 2016-01-12 17:24:35 +01:00
Aksel Skauge Mellbye d2609676ba EFM32: Fix HFRCO support for P2 devices. 2016-01-12 17:24:32 +01:00
Aksel Skauge Mellbye e44059a3c9 Add EFM32 Pearl Gecko exporters. 2016-01-12 17:24:30 +01:00
Aksel Skauge Mellbye 8634cf54d6 EFM32 Pearl Gecko IAR support. 2016-01-12 17:22:14 +01:00
Mikko Polojarvi efadf47be6 SiLabs Pearl: Support for clocking via RC oscillators
Allows clocking the device from RC oscillators (HFRCO, LFRCO).
Note that we can not use the em_cmu.h enums directly as the
preprocessor can not do comparisons on them.

Related changes in serial_api, so that LEUART clock is within
acceptable limits on Pearl.

Contains quite a bit of indentation changes to make the preprocessor
logic more readable so recommend viewing the diff in ignore whitespace
mode.
2016-01-12 17:22:12 +01:00
Mikko Polojarvi 73cf96369d SiLabs: serial_api: Allow LEUART IRQ to fire both handlers
When LEUART IRQ fires, check both RX and TX side for active interrupts
and handle both of them.
2016-01-12 17:22:09 +01:00
Mikko Polojarvi cd08228278 SiLabs: serial_api: Add missing object to sleep fix
Commit 49f63130 'SiLabs: serial_api: Keep track of sleep mode changes'
did not include the added field to struct serial_s.
2016-01-12 17:22:07 +01:00
Mikko Polojarvi 6c3418a0c0 SiLabs: serial_api: Fix memory underflow read in DMA handling
Code would index DMA irq fired array without checking the DMA handle,
which would be -1 when DMA was not used.
2016-01-12 17:22:04 +01:00
Mikko Polojarvi a6e137f188 SiLabs: serial_api: Keep track of sleep mode changes
Keep a counter of sleeps blocked for every device, and do not try
to unblock sleep modes we did not block. This fixes problems where
serial events would cause EM1/EM2 to be unblocked too early,
causing the MCU to go to EM3 and not being able to wake up.
2016-01-12 17:22:02 +01:00
Mikko Polojarvi 1c47e974ff SiLabs Zero: Fix clocking when using LEUART for USB board controller
When initializing for use with the board controller, the LEUART must
be clocked from HF clock as the baud rate is otherwise too high.

Do this by first initializing to "standard" 9600, then call serial_baud
which will handle setting up the clocks and dividers.
2016-01-12 17:21:59 +01:00
Mikko Polojarvi ff494c4000 SiLabs: serial_api: Unblock sleep correctly on TX side
Previous commit that added _intern versions of abort functions
did not change calls of TX abort, so sleep would never unblock.
2016-01-12 17:21:57 +01:00
Mikko Polojarvi 96ff20491c SiLabs Pearl: Minimize line glitches when doing LEUART-USART switch
Switch caused a phantom 0xFF frame to appear on the line when we switched
from LEUART to USART due to a baud rate was increase. This was short
enough that it was only visible at high (~115kbps) speeds.

As a fix, skip disabling the GPIO pins (as their configuration does not
change), and defer disabling the LEUART routing until at the very last
moment. Additionally, do not call serial_format, but immediately
initialize the UART to correct params.
2016-01-12 17:21:54 +01:00
jhokajar 2961d4cc33 SiLabs: analogout_api:
Analog_out fixed. Channel enabled in analogout_init.
2016-01-12 17:21:52 +01:00
Mikko Polojarvi 83401e502b SiLabs Pearl: Correct HFXO frequency
Move to the final HFXO frequency, 40MHz.
2016-01-12 17:21:50 +01:00
Mikko Polojarvi 3b3e52f0a1 SiLabs: serial_api: Fixes for sleep, transmitter disable and uart switch
- Do not attempt to disable the transmitter. Did not find a robust
   way to do so - see comment in file for more info.

 - Do not unblock sleep when abort is called externally, this leads
   to jams as EM1 block gets disabled and the next sleep call places
   the hardware to directly to EM3.

 - Retain more status when switching over from LEUART to USART in
   Pearl: keep registered IRQ handlers and other IRQ status.
2016-01-12 17:21:47 +01:00
jhokajar e48994e9cf Silabs: SPI
Changed SPI implementation: #1 To avoid clearing data from buffers, during splitted DMA transfer
RX/TX buffer clear is done only when transfer is started.
USART transmit is completed instead of DMA/LDMA transfer completed.
2016-01-12 17:21:44 +01:00
jhokajar a9f0fdb200 SiLabs Pearl: SPI
When doing a large transfer over the LDMA it is required to wait TX to be completed
before transferring the next part of the data. Added a loop, to wait until TXC flag is set in function USART_STATUS_TXC.
+ minor code cleanup and EM1 sleep is allowed again.

Second, the TX interrupt was not cleared after processing, causing
it to stay in an infinite loop.
2016-01-12 17:21:42 +01:00
Mikko Polojarvi a7ef4ca830 SiLabs: serial_api: Fix LEUART interrupt dispatch
Conditional when dispatching LEUART irq would always select the RX
side due to a bitwise AND being typoed as a logical AND.

Second, the TX interrupt was not cleared after processing, causing
it to stay in an infinite loop.
2016-01-12 17:21:40 +01:00
Mikko Polojarvi b8ab9fbfed SiLabs Pearl: Use any free UART for stdio
Remove limitation that only a specific UART can be used for the
USB board controller serial line.
2016-01-12 17:21:37 +01:00
Mikko Polojarvi 86376495a6 SiLabs: port_api: Allow individual values on output pins and fix init
Previously, all pins in an mbed Port were set to the same value.
Use GPIO_PortOutSetVal to directly write the desired value to
the pins.

During port initialization the pin mode for input pins was set incorrectly.
Now, input pins are directly set to Input (gpioModeInput) and output pins to
PushPull (gpioModePushPull).
2016-01-12 17:21:35 +01:00
jhokajar 3fc661944a SiLabs Pearl: SPI fixes
Added rx/tx clear before DMA transmit begins. RX DMA descriptor
    fixed
2016-01-12 17:21:33 +01:00
Mikko Polojarvi 81a9dd9031 SiLabs: I2C: Always set master mode on initialization
If an I2C block was reused after being a slave the status would not
be cleared completely, so explicitly initialize to master mode always.
2016-01-12 17:21:30 +01:00
Mikko Polojarvi 316e8733df SiLabs Pearl: I2C: Do not try to force specific locations of pins
Pearl can freely select pins, so do not force both SDA and SCL pins
to have the same "location".
2016-01-12 17:21:27 +01:00
Mikko Polojarvi c1e5c0b907 SiLabs: GPIO interrupts disabled/enabled incorrectly
GPIO_IntEnable/Disable was called with incorrect params due
to missing parens. Operator precedence of & vs << caused the
call to be blank if the port (MSB) nibble of pin was not zero.
2016-01-12 17:21:25 +01:00
jhokajar ee329e5df7 Silabs Pearl: SPI LDMA descriptor fix
Changed correct LDMA descriptor for RX.
2016-01-12 17:21:23 +01:00
jhokajar 2160134d48 Silabs: SPI DMA fix
DMA tranfer was not working in Geckos using DMA. Changed transfer
length calculation in function spi_activate_dma.
2016-01-12 17:21:20 +01:00
jhokajar 0dfca1ad86 SiLabs Pearl: More SPI fixes for 9-16 bit frames
spi_buffer_tx_write fixed to work correctly with 9-16 bit frames,
if transfer length > 1. If frame is 9-16 bit client can use uint16_t or
uint32_t buffer for data storage, spi_api's default is to use uint16_t.

Added precompiler condition USE_UINT16_BUFFER to change assumption for
DMA and IRQ -transfers.
2016-01-12 17:21:18 +01:00
Mikko Polojarvi 6bb98769b0 SiLabs: Update emlib to 4.2.0
Emlib and HW headers updated. ADC pinmap changed to match new
definitions. Pearl linker files updated.
2016-01-12 17:21:15 +01:00
Mikko Polojarvi e865f1fe6f SiLabs Pearl: Keep UART enabled during single byte transfers
We need to explicitly enable the transmitter on Pearl when using the
serial_putc function, to match the disable in the asynch abort.
2016-01-12 17:17:24 +01:00
jhokajar 15b4341162 SiLabs Pearl: SPI fixes for 9-16 bit long frames
LDMA descriptor fixed to support 9-16 bit long frames. Prevented
sleepstate EM1, because USART requires EM0, and entering to EM1
during transfer can crash the system.
2016-01-12 17:17:22 +01:00
jhokajar 3e593439ae SiLabs Pearl: SPI support for 9-16 bit long frames
Added LDMA-transfer support for 9-16 bit long SPI-frames.
2016-01-12 17:17:19 +01:00
Mikko Polojarvi 838b0a6c56 SiLabs Pearl: Allow serial transmitter disable on Pearl
Previous comment on issuing a TXDIS command was incorrect. Actual
root cause was a non-DMA RX interrupt causing the code to run the
TXC handling code as long as the TX DMA interrupt had fired,
which was too early.

Reenable usage of TXDIS on Pearl.
2016-01-12 17:17:17 +01:00
Mikko Polojarvi f6b0c37982 SiLabs Pearl: Support for ARM compiler toolchain
Startup files and linker scripts added for standard and
micro variants of the ARM compiler toochain.
2016-01-12 17:17:14 +01:00
jhokajar 73db782a73 SiLabs: spi implementation
Added implementation for spi_irq_handler_asynch
2016-01-12 17:17:12 +01:00
Mikko Polojarvi 6067de0428 SiLabs Pearl: Rename files and dirs to correct STK code
Pearl STK is offically known as SLSTK3401A, but we well go
with the same naming convention as with Happy so Pearl's
name in Mbed will be STK3401.

Renames all files and directories that previously had the
placeholder STKXXXX. Build, target and export scripts
modified accordingly.
2016-01-12 17:17:10 +01:00
Mikko Polojarvi 20a5bc2ab6 SiLabs: Fix compiler warnings and other cleanup
- Compiler warnings fixed
 - Some private functions marked static
 - Removed unneeded comments
 - Some trailing whitespace stripped
2016-01-12 17:01:41 +01:00
Mikko Polojarvi 9149e88dd1 SiLabs Pearl: Serial support for LEUART-USART switch
Serial HAL now allocates the LEUART first, and will switch
to using a standard UART only if the parameters require it.

Note that this switch can currently only happen one way, from
LEUART to USART. So once a higher baudrate or invalid frame
bit amount has been used, that instance of Serial object
will be locked to using an USART.

TODO: Parts of the UART (re)initialization code are now spread
between three places. They should be combined into single,
generic function.
2016-01-12 17:01:38 +01:00
Mikko Polojarvi 09c94d3091 SiLabs: Fix incorrect TX active conditional in serial_api
Part of condition to detect active TX was not only incorrect
but also not needed in the first place. TX active state is
now always detected only via active TXBL/TXC interrupt.
2016-01-12 17:01:36 +01:00
Mikko Polojarvi 763ce3dbbc SiLabs Pearl: Free(er), dynamic allocation of UARTs
UARTs are no longer fixed to certain pins on Pearl, so
we need to allocate them as needed, and allow for free
pin selection.

TX and RX pin locations in the main serial struct have been
separated, and pin routing modified accordingly.

serial_api_HAL.h interface keeps track of which UARTS are
currently in use, and provides alloc/free functions. Serial
and SPI components modified to use the new API.

TODO: Magic to support LEUART. This code will also need to
be able to dynamically switch from LEUART to standard USART
if the user later sets params (baud rate or format) that can
not be supported on LEUART.
2016-01-12 17:01:34 +01:00
jhokajar 87aee51f52 Silabs Pearl: Added a part number
Added a correct part number for Pearl Gecko Kit Board
2016-01-12 17:01:32 +01:00
Mikko Polojarvi 0e75dd3257 SiLabs: Fix infinite interrupt loop when using LEUART with DMA
Issuing a CLEARTX to LEUART command together or after TXEN caused
the DMA transfer to jam or cause repeated interrupts.

Also cleanup duplicated interrupt clears and add correct LEUART
branches when disabling RX/TX.
2016-01-12 17:01:30 +01:00
Mikko Polojarvi e30c1e1468 SiLabs: Compilation fix for incorrect LFE clock flagging
cmuClock_LFE conditional compliation was using the incorrect flag.
2016-01-12 17:01:28 +01:00
Mikko Polojarvi 97e5eabffa SiLabs: Multiple fixes for serial_api
- Allow emlib to read the HFPER clock when initializing
   USART. This corrects the baud rate on the serial line.

 - Always use the TXC interrupt to signal when a transmission
   is over when using (L)DMA. Removes a race condition
   between flipping from TXBL to TXC, and TXC activating.

 - With the previous change, serial_tx_active can now poll
   the TXBL/TXC interrupts to see if a transmission is active.
   previous code would fail in cases that the DMA transfer
   had ended, but TX was still active, occasionally leading
   to partial transfers when CLEARTX command was issued on
   the next transfer.

 - Add some sync points (SYNCBUSY poll) when twiddling around
   LEUART registers.

Known issue: Using LEUART and DMA transfer on (at least) Leopard
causes the device to enter an infinite DMA interrupt loop.
2016-01-12 17:01:26 +01:00
jhokajar f6a66ff7e2 SiLabs: Correct low power timer setup
When the requested timeout was not a integer multiple of the
LF clock tick the timestamp was set too short due to rounding,
sometimes causing the ticker event to be missed.
2016-01-12 17:01:24 +01:00