Commit graph

1029 commits

Author SHA1 Message Date
Benoît Thébaudeau 5261bb861d cc2538: lpm: Fix RTIMER_NOW() upon wake-up
When returning from PM1/2, the sleep timer value (used by RTIMER_NOW()) is not
up-to-date until a positive edge on the 32-kHz clock has been detected after the
system clock restarted. To ensure an updated value is read, wait for a positive
transition on the 32-kHz clock by polling the SYS_CTRL_CLOCK_STA.SYNC_32K bit,
before reading the sleep timer value.

Because of this RTIMER_NOW() fixup, lpm_exit() has to be called at the very
beginning of ISRs waking up the SoC. This also ensures that all clocks and
timers are enabled at the correct frequency and updated before using them
following wake-up.

Without this fix, etimers could sometimes (randomly, depending on timings)
become ultra slow (observed from 10x to 40x slower than normal) if the system
exited PM1/2 very often. This issue occurred more often with PM1.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-12-05 20:23:29 +01:00
Benoît Thébaudeau f149197aa8 cc2538: lpm: Speed up the transition to the 32-MHz XOSC after wake-up
As recommended by the CC2538 User's Guide, set SYS_CTRL_CLOCK_CTRL.OSC_PD to 0
before asserting WFI, and set it to 1 after the system clock is sourced from the
32-MHz XOSC following wake-up. This allows to automatically start both
oscillators upon wake-up in order to partially hide the 32-MHz XOSC startup time
by the 16-MHz RCOSC startup time.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-12-05 20:23:29 +01:00
Benoît Thébaudeau 13006e1c73 cc2538: lpm: Let system clock transitions complete before further changes
As a matter of precaution, always make sure that pending system clock
transitions are complete before requesting a new change of the system clock
source.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-12-05 20:23:29 +01:00
Benoît Thébaudeau 8514a91ea9 cc2538: lpm: Fix energest context when aborting lpm_enter()
In one of the abort cases in lpm_enter(), the energest context has previously
been set to LPM, so the abort code needs to set it back to CPU.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-12-05 20:23:29 +01:00
George Oikonomou f2c552bb55 Merge pull request #478 from ADVANSEE/cc2538-startup-cleanup
cc2538: Startup cleanup
2013-12-05 11:07:19 -08:00
George Oikonomou 17b2150081 Merge pull request #463 from ADVANSEE/cc2538-ports-pins
cc2538: Clean up and improve port and pin definitions
2013-12-05 10:31:29 -08:00
Benoît Thébaudeau a2686e581e cc2538: Add header file for flash CCA page and use it
Create a dedicated header file with all the definitions for the flash lock bit
page and customer configuration area. This avoids duplicating those definitions
in the startup-gcc.c files of all CC2538-based platforms, and this also allows
to easily manipulate the CCA from outside startup-gcc.c (e.g. for on-the-air
firmware update).

The definitions are now complete contrary to what was in startup-gcc.c:
 - Definitions have been added to select the bootloader backdoor pin and active
   level if enabled.
 - Definitions have been added to access the page and debug lock bits. The debug
   lock bit can be used to prevent someone from reading back a programmed
   firmware through JTAG if the firmware binary image has to be confidential,
   which should be combined with a disabled bootloader backdoor.
 - The application entry point is now tied to the beginning of the .text section
   instead of to the beginning of the flash. This allows projects using custom
   linker scripts to place the application entry point anywhere in the flash,
   which can be useful e.g. for on-the-air firmware update.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-12-05 18:45:51 +01:00
George Oikonomou 8b003c30c7 Merge pull request #471 from ADVANSEE/cc2538-gpio-power-up
cc2538: gpio: Add support for power up
2013-12-05 09:25:05 -08:00
George Oikonomou 97cdf39b95 Merge pull request #464 from ADVANSEE/cc2538-pm2-sram
cc2538: lpm: Give access to the SRAM non-retention area for PM2
2013-12-05 09:19:22 -08:00
Oliver Schmidt 9a48bcf941 Merge pull request #488 from oliverschmidt/master
Avoid access to the address register during auto-increment.
2013-12-03 12:59:45 -08:00
Oliver Schmidt 9cdc6da040 Avoid access to the address register during auto-increment.
It cannot be ruled out that access to the address register triggers
an address auto-increment. Therefore a temporary address register
shadow is introduced to replace the access to the address regsiter.

Additionally there are several minor beautifications.
2013-12-03 21:31:43 +01:00
Ian Martin 0dafba4f6d Add a rule for generating assembly listings on mc1322x targets, for example: "make webserver6.lst". 2013-12-01 16:22:37 -05:00
Mariano Alvira 5fbefbd87b Merge pull request #459 from adamdunkels/push/mc1322x-stuff
MC1322x additions
2013-11-29 11:59:04 -08:00
Benoît Thébaudeau 1a696eb123 cc2538: gpio: Clear the power-up interrupts in the port ISRs
The pending GPIO power-up interrupts have to be cleared in the ISRs in order not
to re-trigger the interrupts and the wake-up events.

The power-up interrupts of all pins are cleared for each port in the
corresponding port ISR. This is done after calling the registered callbacks so
that the callbacks can know which pin woke up the SoC. This is done after
clearing the regular interrupt in order to avoid getting a new wake-up interrupt
without the regular interrupt in the case of a new wake-up edge occurring
between the two clears.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-26 22:20:05 +01:00
Benoît Thébaudeau 44a5c76884 cc2538: gpio: Add macros to use GPIO power-up interrupts
The GPIO power-up interrupts have to be configured and enabled in order to be
able to wake-up the SoC from PM1+ upon a signal edge occurring on a GPIO input
pin.

This set of macros allows to:
 - configure the signal edge triggering a power-up interrupt,
 - enable and disable a power-up interrupt,
 - clear a power-up interrupt flag.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-26 22:10:47 +01:00
Benoît Thébaudeau 621f4f7339 cc2538: lpm: Give access to the SRAM non-retention area for PM2
If PM2 is enabled with LPM_CONF_MAX_PM, but not active, the non-retention area
of the SRAM can be useful to place temporary data that does not fit in the
low-leakage SRAM, typically after having called lpm_set_max_pm(LPM_PM1). Hence,
give access to this non-retention area thanks to .nrdata* sections.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-25 15:43:37 +01:00
Benoît Thébaudeau 270ed237fd cc2538: usb: Make the GPIO driving the pull-up optional
The data sheet recommends that the USB pull-up resistor be driven by a GPIO so
that it can be controlled by software, but this is not mandatory. Hence, leave
the choice so that CC253-based boards not using this option can build and work
fine.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-25 15:15:35 +01:00
Benoît Thébaudeau d2f3795a30 cc2538: Clean up port and pin definitions
Homogenize port and pin definitions naming:
 - PERIPHERAL_FUNCTION_PORT for the port ID,
 - PERIPHERAL_FUNCTION_PIN for the pin ID,
 - PERIPHERAL_FUNCTION_PORT_BASE for the port base,
 - PERIPHERAL_FUNCTION_PIN_MASK for the pin mask.

Define only PERIPHERAL_FUNCTION_PORT and PERIPHERAL_FUNCTION_PIN in board.h, and
deduce PERIPHERAL_FUNCTION_PORT_BASE and PERIPHERAL_FUNCTION_PIN_MASK in the
driver from the former definitions.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-25 15:00:41 +01:00
Adam Dunkels bb2dcaa057 A massive all-tree automated update of all double inclusion guard #defines that changes from using two underscores as a prefix, which are reserved, to not using two underscores as a prefix 2013-11-24 20:20:11 +01:00
Adam Dunkels e09ff3ff1e Merge pull request #438 from adamdunkels/push/cleanup-platforms
Massive platform cleanup
2013-11-24 01:59:53 -08:00
Adam Dunkels 1ab28e4668 Added missing argument declaration 2013-11-23 15:05:16 +01:00
Adam Dunkels e95236b642 Added header declarations for cc2538_rf_read_rssi() and cc2538_rf_set_promiscous_mode() 2013-11-23 15:05:16 +01:00
Adam Dunkels 76f2a10c9a Added a function for setting promiscous mode on the CC2538 RF core 2013-11-23 15:05:15 +01:00
Adam Dunkels 473d519926 Added a way to obtain the RSSI from the CC2538 RF core 2013-11-23 15:05:15 +01:00
Adam Dunkels 27433244a9 The pc-6001 platform was the last z80 platform in the tree, so we'll remove the cpu/z80 directory too 2013-11-22 16:33:46 +01:00
Adam Dunkels 7a310935d8 An implementation of the mc1322x watchdog 2013-11-22 15:54:06 +01:00
Adam Dunkels 88f9d79053 Enable the silent compilation mode from the latest Contiki 2013-11-22 15:53:30 +01:00
Oliver Schmidt 737d5fd6dc Replaced web configurator with target-based ethconfig. 2013-11-21 21:57:42 +01:00
Oliver Schmidt 3abd5d3d8d Show current IP config on startup. 2013-11-20 22:33:11 +01:00
George Oikonomou f13af20f12 Merge pull request #409 from ADVANSEE/cc2538-spi
cc2538: spi: Bug fix and various improvements
2013-11-20 06:51:26 -08:00
Benoît Thébaudeau e8a8870d1d cc2538: spi: Add enable and disable functions
This makes it possible to reduce the power consumption when the SPI is unused.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-20 14:20:50 +01:00
Benoît Thébaudeau b134e35450 cc2538: spi: Add format configuration options
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-20 14:20:43 +01:00
Nicolas Tsiftes 263e212427 Merge pull request #431 from adamdunkels/push/ipv6-const
Make IP addresses const
2013-11-20 04:26:05 -08:00
Nicolas Tsiftes d183b87f4b Merge pull request #434 from adamdunkels/push/cleanup-sys
Remove old unused code from the core/sys/ directory
2013-11-19 09:53:57 -08:00
George Oikonomou dc05eea3f5 Merge pull request #426 from ADVANSEE/cc2538-rom
cc2538: Add driver for the rom utility function library
2013-11-19 03:09:16 -08:00
Adam Dunkels 30c0c5eaf6 Removed old unused timetable code 2013-11-19 08:29:23 +01:00
Adam Dunkels 469884171a Added the const keyword to functions that use the tcpip_set_outputfunc(), which now takes a const argument 2013-11-18 23:26:37 +01:00
Benoît Thébaudeau 1f1b940cb9 cc2538: Add driver for the rom utility function library
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-18 12:38:06 +01:00
Benoît Thébaudeau 035a30602b cc2538: lpm: Make periph_permit_pm1_funcs static
periph_permit_pm1_funcs[] is a private member of lpm.c, so define it as static.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-18 11:57:59 +01:00
George Oikonomou b10c78f854 Merge pull request #425 from ADVANSEE/cc2538-gpio
cc2538: gpio: Bug fix and various improvements
2013-11-15 13:04:09 -08:00
George Oikonomou 98a1f2dfa9 Merge pull request #408 from ADVANSEE/cc2538-uart
cc2538: lpm: Add registration mechanism for peripherals and use it
2013-11-15 12:57:03 -08:00
Benoît Thébaudeau 680050861c cc2538: gpio: Use accessor macros
Use the GPIO accessor macros instead of copying raw register access code all
over the place. This is cleaner and less error prone.

This fixes the setting of the USB pull-up resistor that worked only by chance on
the CC2538DK because it is controlled by the pin 0 of the used GPIO port.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-15 19:57:44 +01:00
Benoît Thébaudeau 923f161b7b cc2538: gpio: Add pin read / write and interrupt clear macros
Introduce new useful GPIO macros to:
 - read the levels of some port pins,
 - write the levels of some port pins (pass bit-field value to be set),
 - clear the interrupt flags for some port pins.

These macros are cleaner and less error prone than raw register access code
copied all over the place.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-15 19:48:24 +01:00
Benoît Thébaudeau 300d2d79ae cc2538: gpio: Fix usage of parameters in macros
The parameters in the GPIO macros were used without being parenthesized. This
could generate wrong values for register assignments in the case of expressions
passed as arguments to these macros.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-15 19:43:06 +01:00
Benoît Thébaudeau b8b54a033c cc2538: uart: Fix crippled output occurring upon lpm_enter()
lpm_enter() must not enter PM1+ if the UART TX FIFO is not empty. Otherwise, the
UART clock gets disabled, and its TX is broken.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-15 17:24:26 +01:00
Benoît Thébaudeau 0692ee251d cc2538: usb: Use the new LPM peripheral registration
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-15 17:14:45 +01:00
Benoît Thébaudeau d35732505b cc2538: lpm: Add registration mechanism for peripherals
Some peripherals have their clocks automatically gated in PM1+ modes, so they
cannot operate. This new mechanism gives peripherals a way to prohibit PM1+
modes so that they can properly complete their current operations before
entering PM1+.

This mechanism is implemented with peripheral functions registered to the LPM
module. These functions return whether the associated peripheral permits or not
PM1+ modes. They are called by the LPM module each time PM1+ might be possible.
If any of the peripherals wants to block PM1+, then the system is only dropped
to PM0.

Partly from: George Oikonomou
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-15 17:09:22 +01:00
George Oikonomou d08a87880c Merge pull request #410 from ADVANSEE/cc2538-sys_ctrl
cc2538: sys_ctrl: Make it possible to use the 32-kHz crystal
2013-11-15 07:42:45 -08:00
Benoît Thébaudeau f1ca1b742c cc2538: spi: Include spi-arch.h before dev/spi.h
spi-arch.h configures dev/spi.h, so it must be #included first. Luckily, this
mistake did not have any consequence here, but fix it in order to avoid possible
future issues.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-15 15:56:40 +01:00
Benoît Thébaudeau f34731c1a9 cc2538: spi: Do not call SPI_WAITFOREORx() at end of init
If the SSI has never been used and spi_init() is called, then the SSI receive
FIFO is empty and remains so, so calling SPI_WAITFOREORx() at the end of
spi_init() waits endlessly for SSI_SR.RNE to be set. Hence, this call must be
removed in order to avoid a deadlock.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-15 15:56:40 +01:00