1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

280 Commits

Author SHA1 Message Date
Benjamin Valentin
3af4d38735 cpu/lpc2387: use TIMER_CHANNEL_NUMOF 2020-06-24 00:45:35 +02:00
Benjamin Valentin
41a961be22 cpu/lpc2387: timer: implement timer_set_periodic() 2020-05-28 17:37:41 +02:00
Benjamin Valentin
7c11ae9dcc cpu/lpc2387: use TIMER_CHANNELS for consistency 2020-05-28 13:24:06 +02:00
Benjamin Valentin
8d0e902d38 cpu/arm7_common: add inlined header only def for irq_% 2020-05-15 13:43:04 +02:00
Marian Buschsieweke
0fe24e1c8b
Merge pull request #13903 from benpicco/cpu/lpc2387/timer_pclk_scale
cpu/lpc2387: timer: use lpc2387_pclk_scale()
2020-05-07 22:04:14 +02:00
Benjamin Valentin
89a145ab0c cpu/lpc2387: clocks: minor style fix 2020-04-30 20:43:41 +02:00
Benjamin Valentin
c262c91561 cpu/lpc2387: PM: enable SLEEP & POWERDOWN mode
We have to re-init PLL (and Flash) after wake from those modes.
2020-04-30 20:43:41 +02:00
Benjamin Valentin
3b257f9a5a cpu/lpc2387: export functions to init PLL & MAM
Those functions are needed after wake from lower sleep modes.
2020-04-30 20:43:41 +02:00
Benjamin Valentin
c21b5d6f55 cpu/lpc2387: PM_NUM_MODES must only count non-idle modes
lpc23xx has 3 sleep modes and one idle mode.
`PM_NUM_MODES` must only count the idle modes.

In practise, this makes no difference since `mode 3` (IDLE) is
the `default` case in `pm_set()` anyway.
2020-04-26 19:45:43 +02:00
Benjamin Valentin
4ee8d3f4d2 cpu/lpc2387: enable full rtc_normalize() for RTC
The RTC actually makes use of the day of year / day of week fields,
so enable the calculation of those fields in rtc_normalize().
2020-04-22 10:39:33 +02:00
Benjamin Valentin
370fff90a8 cpu/lpc2387: timer: use lpc2387_pclk_scale() 2020-04-19 15:32:42 +02:00
Benjamin Valentin
cfe606b601 cpu/lpc2387: gpio: Don't discriminate between rising & falling pins
The `test_irq()` function does not discriminate between rising and
falling pins, so there is no need to handle them separately.
2020-04-12 21:31:42 +02:00
Benjamin Valentin
6233175f16 cpu/lpc2387: gpio: Fix interrupts on PORT2
The calculation of `_state_index` is broken for `port = 2`

    _gpio_isr_map[n + (port<<1)];

Will not yield the right result. As a consequence, IRQs on Port 2
are not working.
The right thing here would be

    _gpio_isr_map[n + (port ? 32 : 0)];

But we might just re-using the `_isr_map_entry()` function.
Also only iterate as many times as there are set interrupt bits.
2020-04-12 21:31:42 +02:00
Benjamin Valentin
4451765952 cpu/lpc2387: fix check for max number of timers
The CPU has 4 hardware timers.
Configuration for all 4 timers exists, but the compile-time range
check has an off-by-one error, causing the last timer to remain
inaccessible.
2020-04-05 01:56:55 +02:00
Benjamin Valentin
69551d4a74 cpu/lpc2387: define BACKUP_RAM attribute 2020-03-19 13:38:50 +01:00
14ed03074e cpu: lpc2387: make THREAD_STACKSIZE_IDLE configurable 2020-03-12 13:01:13 +01:00
Yegor Yefremov
41db161162 doxygen/I2C: don't include overridden typedefs
Add missing #ifndefs to overridden I2C typedefs for lpc2387 CPU.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2020-03-05 15:31:06 +01:00
Benjamin Valentin
937c954d92 cpu/lpc2387: implement periph/i2c
The lpc23xx MCU has up to three I2C interfaces.
This adds a driver for it.
The peripheral works in interrupt mode, each change of the state machine
will generate an interrupt.
The response to the states are laid out in the data sheet.

This replaces the old driver that was removed in c560e28eb6
2020-02-26 23:41:38 +01:00
benpicco
99f3f67e67
Merge pull request #13317 from benpicco/arm7-event_thread
tests/event_threads: remove arch_arm7 from blacklist
2020-02-26 08:39:00 +01:00
Gunar Schorcht
f688f84a15
Merge pull request #12928 from benpicco/newlib-multiheap
sys/newlib: enable multiple heaps in _sbrk_r()
2020-02-25 19:16:42 +01:00
Benjamin Valentin
24ed1bbb70 cpu/lpc2387: hook up extra memory sections as heap
This enables the USB, Ethernet and Backup memory regions to be used
as heap memory.
2020-02-20 17:11:25 +01:00
Benjamin Valentin
ceee5b1809 cpu/lpc2387: don't define interrupt stack size in linkerscript
Define the interrupt stacks in C code like it is done for Cortex-M.
2020-02-11 15:39:34 +01:00
Benjamin Valentin
9f4920329b cpu/lpc2387: clear BODR if POR is set
From the data sheet:

> **Note:** Only in case when a reset occurs and the POR = 0, the BODR bit
indicates if the V DD(DCDC)(3V3) voltage was below 2.6 V or not.

So the value of BODR is undefined if POR is set.
Clear it to bring it to a defined state.
2020-02-10 23:04:47 +01:00
Benjamin Valentin
76e19602a2 cpu/lpc2387: rename cpu_woke_from_backup()
The function would always return `true` after early boot, so it
is not very useful for applications.

Now it will only (but always) return true when we woke from Deep Sleep
*after* early boot. This makes it behave the same ways as the function
of the same name on SAME54.

Rename the existing function to cpu_backup_ram_is_initialized() to better
match it's semantics.
2020-02-10 23:04:47 +01:00
Benjamin Valentin
64107dd3a9 cpu/lpc2387: rtc: only initialize RTC after cold boot or external reset
On the MCB2388 plugging the power will result in both the POR and EXTR
bit being set.
Not sure if this is a property of the board, but it means RTC is also
reset after programming, so it behaves just like Backup RAM.

If we woke from Deep Sleep the POR bit will be cleared, so the RTC is not
reset.
2020-02-10 23:04:47 +01:00
Benjamin Valentin
80dde82c86 cpu/lpc2387: clear POR bit if we woke from Deep Sleep
RSIR is 0x1 (POR) if we woke from Deep Sleep.
This makes it hard to distinguish between real power-on and waking from
Deep Sleep, which is why the Backup RAM signature was introduced.

However, calling cpu_woke_from_backup() a second time will always return
true, as the signature will have been set up by early boot then.

Thus, clear the POR bit if the signature was already in place.
The result is:

	RSIR == 0 -> woke from sleep
	RSIR == 1 -> cold boot
2020-02-10 23:04:46 +01:00
Benjamin Valentin
6dbbc8f33a cpu/lpc2387: rtc: remove _rtc_set()
Calling localtime() adds considerable overhead.
There are easier ways to set the date to 1970.

For tests/periph_rtc this results in this ROM change:

master:

   text    data     bss     dec     hex
  31328     240   98064  129632   1fa60

with this patch:

   text    data     bss     dec     hex
  20036     140   98168  118344   1ce48
2020-02-10 23:04:46 +01:00
benpicco
b44cf48a87
Merge pull request #13246 from benpicco/lpc23xx-spi
cpu/lpc2387: make SPI configurable
2020-02-10 17:01:41 +01:00
Benjamin Valentin
13e578bc84 cpu/lpc2387: implement periph/adc
lpc23xx has a 10 bit ADC with up to 8 channels.

The ADC should be clocked at 4.5 MHz or less, so it uses
(72MHz CCLK / 8) / 2.
2020-02-10 13:25:26 +01:00
Benjamin Valentin
3f01f4b183 cpu/lpc2387: make periph/spi configurable 2020-01-31 12:01:09 +01:00
Benjamin Valentin
a0d188fd6b cpu/lpc2387: convert periph/spi to struct based operation 2020-01-31 08:55:29 +01:00
Benjamin Valentin
c24fb242ef cpu/lpc2387: rtc: set rtc callback arg
`_cb_arg` was never set, it was simply ignored in `rtc_set_alarm()`.
The fix is trivial: just set `_cb_arg` to the assigned argument.
2020-01-29 19:49:18 +01:00
98780ea023
cpu/armv7: move dependencies to Makefile.dep 2020-01-28 13:20:52 +01:00
benpicco
b35ef08094
Merge pull request #12901 from benpicco/lpc2387-stacks
cpu/lpc2387: use the same default stack sizes as cortexm_common
2019-12-18 14:12:58 +01:00
Benjamin Valentin
a90663c9e7 cpu/lpc2387: provide ISR_STACKSIZE & thread_isr_stack_start()
Those are needed by MicroPython
2019-12-17 13:37:32 +01:00
Benjamin Valentin
b1808800ed cpu/lpc2387: align lpc2387.ld with cortexm_base.ld
For better compatibility copy most of cortexm_base.ld
and use the same section names.

Only interrupt stacks and the two additional (currently unused)
heap sections are different between the two now.
2019-12-09 15:13:53 +01:00
Benjamin Valentin
d57e03c94c cpu/lpc2387: use the same default stack sizes as cortexm_common
Both architectures are variants of the ARM architecture and use the same
toolchain.
There is no reason to have such wildly different defaults.

This results in some tests passing that would crash before:

 - [x] `tests/pkg_libcose`
 - [x] `tests/pkg_qdsa`
 - [x] `tests/pkg_relic`
 - [x] `tests/pkg_tweetnacl`
 - [x] `tests/pthread_tls`

`THREAD_EXTRA_STACKSIZE_PRINTF_FLOAT` is not used anywhere in RIOT
anymore, so just drop it.
2019-12-08 22:07:57 +01:00
Benjamin Valentin
f89b852c1d cpu/lpc2387: clean up lpc2387.ld
Clean up the linkerfile and bring it more in line with cortexm_base.ld
(so far only for the ROM part)

As a bonus, tests/cpp_ctors works now.
2019-11-29 12:13:21 +01:00
Benjamin Valentin
ed0f72c856 cpu/lpc2387: startup.s: remove dead code
Setting up the .data and .bss section happens in arm7_init.c now.
The code was commented out anyway, so just remove it.
Also remove leftover variable declarations that were only used in
the dead code.
2019-11-29 12:00:52 +01:00
Benjamin Valentin
32bbba2fc5 cpu/lpc2387: add support for backup RAM
lpc23xx has 2k of battery RAM that is retained in Deep Power Down mode.

To not overwrite that data it must only be initialized on Power On Reset.
However, RSIR looks the same when waking up from Deep Power Down as it does
on the power-on case.

So use 4 bytes of the backup RAM to keep a signature that is only valid if
memory was retained (no power-on Reset).

A small change to the linker script is required so two sections can be
placed into flash.
2019-11-28 11:33:03 +01:00
Benjamin Valentin
15fcbe837a cpu/lpc2387: add definition of RSIR bits
Add the bits of the Reset Source Identification Register
2019-11-28 11:30:38 +01:00
Benjamin Valentin
964725259a cpu/lpc2387: implement periph/dac
The 10 bit DAC on the lpc23xx is very simple.
It only has one channel and can only be mapped to a single pin (P0.26).

After setting the pin mode to DAC no further configuration in needed.
2019-11-26 01:49:45 +01:00
Benjamin Valentin
8337ab111e cpu/arm7_common: hook up puf_sram
puf_sram only relies on an uninitialized chunk of memory.
This means to enable it we just have to hook up puf_sram_init().

All memory after __bss_end should be uninitialized at startup, so
just use that.
2019-11-25 02:04:34 +01:00
c6a80b4f4b cpu/lpc2387: fix typos 2019-11-23 22:39:36 +01:00
Francois Berder
4a31f94cfc many typo fixes
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
2019-11-23 22:39:07 +01:00
Benjamin Valentin
8424d1845b cpu/lpc2387: fix doxygen errors
Document macros and remove an unused function.
2019-11-22 09:11:39 +01:00
Benjamin Valentin
a9d1825e2e cpu/lpc2387: implement periph/pm
Enable IDLE and Deep Powerdown mode.

IDLE is pretty straightforward - insteady of busy waiting, the CPU will
enter an idle state from which it will resume on any event.

Deep Power Down shuts off the entite system except for the battery backup
power domain.
That means the CPU will reset on resume and can be woken by e.g. RTC.

SLEEP and POWERDOWN disable the PLL and the PLL and Flash respectively.
This requires some proper wake-up handling.

Since this turned out to be a major time sink and those modes are never
currently never used in RIOT outside of tests, I left this as an exercise
for a future reader.
2019-11-22 09:11:39 +01:00
Yegor Yefremov
fa3b0ff04b doxygen/SPI: don't include overridden typedefs
Add missing #ifndefs to overridden SPI typedefs.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2019-11-15 10:35:32 +01:00
Marian Buschsieweke
72714aefea
cpu/lpc2387: Added MCU provided features
Added features provided by the LPC2387 MCU to cpu/lpc2387/Makefile.features
2019-11-08 14:02:35 +01:00
Benjamin Valentin
9e68556393 boards/msba2: configure remaining UARTs
All UARTs on the MSBA2 are exposed through pin headers on the board.
Configure them according to the data sheet.
2019-11-07 21:55:25 +01:00