Commit Graph

5571 Commits (dcda8ec0e34897d5a547f0172d34d65aa6d42729)

Author SHA1 Message Date
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
jhokajar ab26722b01 SiLabs: Low power timer / RTC initialization fix
Read as not returning correct values, because RTCC (or RTC in other
Gecko's) was not initiated. This was a problem in every Gecko.

If RTCC is initiated for lptimer it is done without binding it to
irqhandler (since irq not needed). Also implementation for geckos
using RTC added.

Tested with pearl and happy geckos
2016-01-12 17:01:22 +01:00
jhokajar 22879f972d SiLabs Pearl: lpticker wakeup 2016-01-12 17:01:20 +01:00
Mikko Polojarvi a31071275a SiLabs: Fix interrupt amount configurations
Number of interrupt slots reported by different files before this commit:

            giant  happy  leopard  pearl  wonder  zero
spec        39     21     39       34     39      17
nvic        39     21     39       34     40      19
startup.s   39     21     40       34     40      19
gcc link    40     21     41       34     40      19
arm link    40     22     40       -      40      16
reserved    0      0      1        0      0       2

  spec - reference manual
  nvic.h - cmsis_nvic.h
  startup.s - assembler startup files
  gcc link - efm32*.ld linker script for GCC
  arm link - efm32*.sct linker script for ARM (RVCT)
  reserved - number of 'reserved' slots at the end of irq table in startup.s files

Fixed amounts to reflect those in the startup files, including reserved
slots:

Giant
    Reduce amount in GCC and ARM linker files to 39

Happy
    Fix comment in GCC linker file
    Reduce amount in ARM linker file to 21

Leopard
    Increase amount to 40 in cmsis_nvic.h
    Reduce amount to 40 in GCC linker file (this bug caused by
    emlib 4.1.0 port commit 1923e8b4)

Wonder
    No changes, but note that ref. manual does not list FPUEH
    interrupt that is included in startup files at index 39

Zero
    Increase amount to 19 in ARM linker file
2016-01-12 17:01:17 +01:00
jhokajar 7f051e9a22 SiLabs Pearl: SPI LDMA support
SPI dma forced to compile. Continuing improvements...
2016-01-12 17:01:15 +01:00
jhokajar 745d72aeea SiLabs Pearl: SPI pinmappings
Correct routing for SPI pins on Pearl
2016-01-12 17:01:13 +01:00
jhokajar 97a1674a94 SiLabs Pearl: I2C GPIO fix
GPIO pins were uninitialized. Fixed and tested.
2016-01-12 17:01:11 +01:00
Mikko Polojarvi 6095a67b95 SiLabs Pearl: LDMA fixes for serial
LDMA now functional for both RX/TX.

One hack remains - need to check if TXC interrupt check can be
removed from older platforms, or if flagging is necessary.
2016-01-12 17:01:09 +01:00
jhokajar fc49b0e2ac SiLabs Pearl: PWM output functionality
Any channel can be used. It is possible to have 4 pwm outputs
active at a same time, if PinMap_PWM configuration is done properly.

Future improvement proposal: dynamic channel selection!
2016-01-12 17:01:07 +01:00
jhokajar 973141e2e7 SiLabs Pearl: ADC fixes
Channel selection shifted to right place. Now It seems to work
at least with channel PC11. Weird thing is, that floating pin gives
result 0.4. Should be 0.0.
2016-01-12 17:01:04 +01:00
Mikko Polojarvi 7be6799638 SiLabs Pearl: LDMA support for serial_api
LDMA support for serial HAL. Adds callback support for emlib LDMA
code so that most of the old serial code can be reused.

Note: Serial shows some signs of life on the bus, but DMA mode
is completely untested.
2016-01-12 17:01:03 +01:00
Mikko Polojarvi e3e385e16d SiLabs Pearl: Serial HAL USART/LEUART pin routing
Serial pin routing for Pearl. Note that this currently requires
the pins to be in the same "location", even though this is not
needed by the Pearl HW.
2016-01-12 17:01:00 +01:00
jhokajar d238a83042 SiLabs Pearl: AnalogIn support
analogin_api.c changed to make it compile.

Compilation error will be generated if _ADC_SINGLECTRL_POSSEL_MASK ||
_ADC_SINGLECTRL_INPUTSEL_MASK is not defined. This is because NEGATIVE
voltage measurement is not supported by MBED API.
2016-01-12 17:00:58 +01:00
Mikko Polojarvi bafd8e28b8 SiLabs Pearl: LDMA initialization
LDMA support for the dma_api module
2016-01-12 17:00:56 +01:00
Mikko Polojarvi c4018e4ea8 SiLabs Pearl: Correct includes and interrupt names in RTC
Conditionals for including em_rtc.h and em_rtcc.h.
Use the correct interrupt name in RTCC code.
2016-01-12 17:00:54 +01:00
Mikko Polojarvi 21a242049f SiLabs Pearl: Fix I2C pin routing
Use new ROUTEPEN/ROUTELOC0 registers for selecting I2C pins.
2016-01-12 17:00:52 +01:00
Mikko Polojarvi 4990751ace SiLabs Pearl: Correct STDIO_UART definition
Normal UARTs not present, use USART.
2016-01-12 17:00:50 +01:00
Mikko Polojarvi 2cb2ada9b6 SiLabs Pearl: Mbed support for linker script
Mbed needs to have interrupt vectors in RAM so reserve space at
the beginning of memory, and export the relevant symbols.
2016-01-12 17:00:48 +01:00
jhokajar c89d5cae9d SiLabs Pearl: Update pinmap for ADC and DAC
ADC pinmap updated, PinMap_DAC removed, since DEVICE_ANALOGOUT not supported
2016-01-12 17:00:46 +01:00
Mikko Polojarvi 6e7589c5b8 SiLabs Pearl: Remove configuration for HW not present in Pearl
Removed DAC/AnalogOut, I2C1, UART0/1, LEUART1, USART2,
GPIO Drive support and GPIO port E.
2016-01-12 17:00:44 +01:00
Mikko Polojarvi dcc6b61ed5 SiLabs Pearl: lp_ticker HAL adaptation
Use RTCC API for lp_ticker on Pearl. Basic adaptation, but more
work is required.

Now frees RTC when ticker is not used (detected through interrupt
disable), so that sleep modes below EM2 do not remain
permanently blocked.
2016-01-12 17:00:42 +01:00
Mikko Polojarvi bf4cf1a5ec SiLabs Pearl: RTCC support 2016-01-12 17:00:40 +01:00
Mikko Polojarvi e2c33dd166 SiLabs Pearl: GPIO HAL fixes
Pearl GPIO block does not support DOUTSET/DOUTCLR,
so use read+DOUTTGL instead.
2016-01-12 17:00:38 +01:00
Mikko Polojarvi 15ed788fe7 SiLabs Pearl: Pin mappings for PWM
PWM pin mappings. Since the pins can be freely chosen (unlike
in previous HW), there should be no need to use the other channels.

Also corrected frequency for HFXO in ref devices.
2016-01-12 17:00:35 +01:00
Mikko Polojarvi 199f5fa402 SiLabs: Emlib 4.1.0 headers update for Zero Gecko 2016-01-12 17:00:33 +01:00
Mikko Polojarvi 0c066f5c1a SiLabs: Emlib 4.1.0 headers update for Wonder Gecko 2016-01-12 17:00:30 +01:00
Mikko Polojarvi 19a060791c SiLabs: Emlib 4.1.0 headers update for Leopard Gecko 2016-01-12 17:00:27 +01:00
Mikko Polojarvi 567afac8ea SiLabs: Emlib 4.1.0 headers update for Happy Gecko 2016-01-12 17:00:25 +01:00
Mikko Polojarvi 485a08db77 SiLabs: Emlib 4.1.0 headers update for Giant Gecko 2016-01-12 17:00:22 +01:00
Mikko Polojarvi 9234010fb8 SiLabs: Update emlib to 4.1.0
New version with support for Pearl & co.
2016-01-12 17:00:19 +01:00
Mikko Polojarvi e5e896b68d SiLabs Pearl: Initial commit
Leopard Gecko used as baseline.

TODO

 - Peripheral/GPIO pin mappings etc for Pearl are marked "Pearl ok",
   rest are wrong

 - Missing new (4.1.0+) emlib
2016-01-12 17:00:16 +01:00