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

75 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
Benjamin Valentin
d6a94d4e18 cpu/lpc2387: uart driver overhaul
This converts the hard-coded UART driver to the new ways.

 - allow the board to configure the RX & TX pins
 - allow for more than one UART
 - allow setting the baudrate
 - implement poweron()/poweroff() functions
2019-11-07 21:55:24 +01:00
Benjamin Valentin
985fb53c9f cpu/lpc2387: enable RTC on init
All other CPU implementations have the RTC running after
rtc_init() was called.

Fix this for lpc2387.
2019-10-27 01:33:13 +02:00
Benjamin Valentin
b1724a7d1b periph/rtc: normalize struct tm before usage
A naive implementation may set a RTC alarm in 30s by calling

	struct tm now;
	rtc_get_time(&now);
	now.tm_sec += 30;
	rtc_set_alarm(&now, _cb, NULL);

This works for RTC implementations that use a RTT internally and call
mktime() to convert the struct tm to a unix timestamp, as mktime() will
normalize the struct in the process.

Call rtc_tm_normalize() when the RTC uses separate registers for time / date
components to ensure it is normalized.

This also modifies tests/periph_rtc to exercise this case.
2019-09-12 11:32:31 +02:00
Martine Lenders
0ed57df4b5 lpc2387: mark closing #endif for MODULE_PERIPH_GPIO_IRQ 2018-10-09 15:11:00 +02:00
Hauke Petersen
72986ecb9b cpu/lpc2387/gpio: use gpio_irq feature 2018-09-21 08:19:15 +02:00
Andreas "Paul" Pauli
1aaeecf5b1
Merge pull request #9296 from maribu/lpc2387
cpu/lpc2387: Various fixes for GPIO driver
2018-06-21 19:28:53 +02:00
Peter Kietzmann
6fd4009b89
Merge pull request #8957 from aabadie/pr/cpu/guard_lpc2387
cpu/lpc2387: remove useless periph file guard
2018-06-20 09:06:31 +02:00
Marian Buschsieweke
1d0f90dcdf
cpu/lpc2387: Various fixes for GPIO driver
- Fixed documentation
- Use bitwise operation instead of multiplication and addition in `GPIO_PIN()`
- Allow GPIOs to be configured as input via `gpio_init()`
- Fixed bugs in `gpio_init_mux`:
    - `0x01 << ((pin & 31) * 2)` was used before to generate the bitmask, but
      this would shift by 62 to the left. Correct is `0x01 << ((pin & 15) * 2)`
      (See [datasheet](https://www.nxp.com/docs/en/user-guide/UM10211.pdf) at
      pages 156ff)
    - Only one of the two bits was cleared previously
- Changed strategy to access GPIO pins:
    - Previous strategy:
        - Set all bits in FIOMASK except the one for the pin to control to
          disable access to them
        - Set/clear/read all pins in the target GPIO port (but access to all but
          the target pin is ignored because of the applied FIOMASK)
    - New strategy:
        - Set/clear/read only the target pin
    - Advantages:
        - Only one access to a GPIO register instead of two
        - Proven approach: Access to GPIOs on lpc2387 is mostly done by
          accessing the GPIO registers directy (e.g. see the sht11 driver).
          Those accesses never touch the FIOMASK register
        - No unwanted side effects: Disabling all but one pin in a GPIO port
          without undoing that seems not to be a good idea
2018-06-18 09:10:25 +02:00
Marian Buschsieweke
17a5101b40
cpu/lpc2387: Fixed broken SPI driver
In commit 513b20ffd3 the SPI API was changed to
power up an configure the SPI bus on spi_acquire(). Sadly, the lpc2387 SPI
apparently needs to be reconfigured after each power up. This commit moves
the initialization code required after each power up from spi_init() to
spi_acquire().
2018-05-19 18:12:25 +02:00
bcab6bd1ba cpu/lpc2387: remove useless periph file guard 2018-04-16 10:11:47 +02:00
Hauke Petersen
2fc724db7e cpu/lpc2487: add empty uart/power_x functions 2018-03-02 10:53:55 +01:00
smlng
7309171303 build: fix unused parameter errors
cpu, sam0_common: fix unused parameter in periph/spi
        cpu, kinetis_common: fix unused parameter in periph/spi
        cpu, cc2538: fix unused param in periph/i2c
        cpu, cc2538: fix unused param in periph/spi
        cpu, sam3: fix unused param in periph/spi
        cpu, stm32_common: fix unused param in periph/pm
        cpu, stm32f3: fix unused params in periph/i2c
        cpu, nrf5x_common: fix unused param in periph/gpio
        cpu, nrf5x_common: fix unused param in periph/spi
        cpu, lpc2387: fix unused params in periph/spi
        cpu, cc2538: fix unused params in radio/netdev
        cpu, cc2650: fix unused params in periph/uart
        cpu, lm4f120: fix unused param in periph/spi
        cpu, lm4f120: fix unused params in periph/timer
        cpu, lm4f120: fix unused params in periph/uart
        cpu, stm32_common: fix unused params in periph/dac
        cpu, stm32l0: fix unused params in periph/i2c
        cpu, msp430fxyz: fix unused params in periph/uart
        cpu, mips: fix unused params
        cpu, cc430: fix unused-params in periph/timer
        cpu, msp430fxyz: fix unused params in periph/spi
        drivers, cc2420: fix unused param
        cpu, mips32r2_common: fix unused params in periph/timer
        cpu, cc2538: fix unused-param in periph/i2c
        cpu, mips32r2_common: fix unused-param in periph/timer
        cpu, msp430fxyz: fix unused params in periph/timer
        cpu, atmega_common: fix unused params in periph/spi
        driver, nrfmin: fix unused params
        cpu, cc2538_rf: fix unused params
        driver, netdev_ieee802514: fix unused param
        cpu, mip_pic32m: fix unused params
        cpu, lpc2387: fix unused params in periph/pwm
        tests/driver_sdcard_spi: fix unused params
        cpu, sam3: fix unused param in periph/pwm
        tests/driver_dynamixel: fix unused params, and style issues
        cpu, cc430: fix unused param in periph/rtc
        cpu, atmega_common: fix unused params in periph/i2c
2017-11-28 14:36:01 +01:00
a20745b6c5 cpu: make use of Makefile.periph 2017-11-06 12:01:19 +01:00
Francisco Acosta
f2efd88f98 Merge pull request #7129 from haukepetersen/opt_periph_sharetimerset
cpu: add and use shared code for timer_set()
2017-08-01 15:09:48 +02:00
smlng
01af6d94c4 cpu, periph: retain constness in spi_transfer_bytes 2017-06-29 15:47:13 +02:00
smlng
692cf96297 doc: fix doxygen grouping of cpu periph drivers 2017-06-26 14:42:11 +02:00
Hauke Petersen
a1499f4190 cpu: add and use shared code for timer_set() 2017-06-02 12:21:56 +02:00
Hauke Petersen
37d4f44379 cpus: mv vendor headers to include/vendor/. 2017-03-07 08:55:15 +01:00
Hauke Petersen
8064bd9fa9 periph/pwm: remove pwm_(start|stop) + doc
- joined start/stop and poweron/poweroff
- added general documentation
2017-02-13 09:37:31 +01:00
Hauke Petersen
10b0013315 cpu/lpc2387+boards: adapted to new SPI API
- adapted the SPI driver
- adapted all boards using the CPU
2017-01-25 16:46:05 +01:00
Hauke Petersen
a35709b4f8 Merge pull request #6360 from OlegHahm/periph_timer_remove_irq
periph timer: remove timer_irq_(en|dis)able
2017-01-18 22:58:21 +01:00
Hauke Petersen
7b5d26340a cpu/lpc2387: cleanup for the PWM driver 2017-01-17 10:50:02 +01:00
Oleg Hahm
d0316fa7ae periph timer: remove timer_irq_(en|dis)able 2017-01-14 15:34:53 +01:00
0194091673 remove obsolete lpm code 2017-01-12 11:24:15 +01:00
Hauke Petersen
2eebf36eb2 cpu/uart: make use of named return values 2016-10-28 10:32:00 +02:00
DipSwitch
0bb4748a94 core: Fix/refactor function naming in core/incude/irq.h 2016-03-20 16:47:34 +01:00
Hauke Petersen
877d06bda8 cpu/lpc2387: adapted GPIO driver 2016-03-17 14:39:11 +01:00
Hauke Petersen
b23cde98cf cpus: adapted UART implementations to cb type change 2016-03-15 11:02:06 +01:00
Joakim Nohlgård
6a52296a35 cpu/lpc2387: Use {} notation for empty while loops 2016-03-03 16:30:06 +01:00
Peter Kietzmann
c8829a49b8 Merge pull request #4838 from haukepetersen/fix_periph_timerarg
drivers/timer: added callback argument
2016-03-01 08:55:54 +01:00