Commit graph

145 commits

Author SHA1 Message Date
Benoît Thébaudeau 96dd24836c cc2538: Use &vectors instead of flash/.text start address
The current CC2538 linker script in Contiki places the vector table at
the beginning of the flash memory / .text output section. However, this
location is arbitrary (the only requirement is that the vector table is
512-byte aligned), and custom linker scripts may be used with Contiki,
which means that Contiki may be used with a vector table placed
elsewhere. Thus, using the flash/.text start address in the CCA and as
the default NVIC VTABLE value was wrong.

This commit rather uses the address of the vectors[] array from
startup-gcc.c, which makes it possible to freely move around the vector
table without breaking anything or having to use a custom startup-gcc.c
and to configure the NVIC driver for that. Moreover, referencing the
vectors[] array naturally prevents it and its input section from being
garbage-collected by the linker, so this commit also removes the
now-unneeded "used" and "KEEP" keywords from the vector table.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-11-19 01:18:33 +01:00
Benoît Thébaudeau a191fcdb84 cc2538: nvic: Simplify VTABLE configuration
The only thing needed for VTABLE is the absolute address of the vector
table. Splitting it between code/SRAM base and offset complicates things
and brings nothing.

Consequently, this commit merges the NVIC VTABLE configurations into a
single one giving the vector table absolute address.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-11-19 01:18:33 +01:00
Benoît Thébaudeau efb4b858e2 cc2538: Define the flash memory organization
Define the flash memory page and word sizes. These definitions are
grouped with the flash lock bit page and CCA definitions, so flash-cca.h
is renamed to flash.h.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-11-19 01:18:33 +01:00
Benoît Thébaudeau 790c253d6d cc2538: Define and use device features
Define the available CC2538 devices and their features, and use them to
define the linker script memory regions. The .nrdata output section is
now always defined in order to trigger an error if it is used but no
memory is available for it. The CC2538 device used by Contiki is made a
configuration option, the CC2538SF53 device being the default.

This makes more sense than defining the flash memory address and size as
configuration options like previously, all the more not all values are
possible and all the features are linked by each device.

This change also makes it possible to:
 - use the correct SRAM parameters for the CC2538NF11,
 - know at build time if the AES, SHA, ECC and RSA hardware features are
   available on the selected CC2538 device.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-11-19 01:18:33 +01:00
AntiCat d631270af4 cc2538: Add PKA drivers, ECC algorithms and examples 2015-10-18 20:14:17 +02:00
Benoît Thébaudeau 0b1a0d2bd9 Merge pull request #1092 from g-oikonomou/contrib/remote_watchdog_stop
Remove CC2530 and CC2538 dummy watchdog_stop()
2015-06-18 21:56:13 +02:00
Benoît Thébaudeau 0f137e4bdd cc2538: uart: Make uart_isr() static
This function is only supposed to be used by uart.c, so it should be
static.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-06-05 21:50:49 +02:00
Benoît Thébaudeau e8a268cd15 cc2538: aes: Add support for 192- and 256-bit keys
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-06-02 21:41:56 +02:00
Benoît Thébaudeau 801315e819 cc2538: aes: Make it possible to have several keys stored at once
Several keys can be kept at the same time in the key store, and several
keys can be loaded at once. Give access to these features.

The ccm-test example is also improved to better demonstrate the use of
the key store.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-06-02 21:41:07 +02:00
Benoît Thébaudeau b92a5afcc4 cc2538: ccm: Make it possible to use the interrupt
Using the AES interrupt allows the user process not to waste time
polling for the completion of the operation. This time can be used by
the user process to do something else, or to let the system enter PM0.

Since the system is now free to perform various operations during a
crypto operation, a protection of the crypto resource is added, and PM1+
is prohibited in order not to stall crypto operations.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-06-02 21:41:07 +02:00
Benoît Thébaudeau 117dc4e5e3 cc2538: Add crypto drivers and examples for AES-CCM and SHA-256
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-06-02 21:41:06 +02:00
George Oikonomou d28eb023ef Remove CC2530 and CC2538 dummy watchdog_stop()
The CC2538 the WDT cannot be stopped once it has been started.
The CC2530/1 WDT can be stopped if it is running in timer mode,
but it cannot be stopped once it has been started in watchdog mode.

Both platforms currently provide "dummy" implementations of `watchdog_stop()`,
one does nothing and the other one basically re-maps `_stop()` to
`_periodic()`.

This was originally done in order to provide implementations for all prototypes
declared in `core/dev/watchdog.h`. In hindsight and as per the discussion
in #1088, this is bad practice since, if the build succeeds, the caller will
expect that the WDT has in fact been stopped, when in reality it has not.

Since the feature (stopping the WDT) is unsupported by the hardware, this pull
removes those dummy implementations. Thus, we will now be able to reliably
detect - at build time - attempts at using this unsupported feature.
2015-06-01 15:24:14 +01:00
Ulf Knoblich d8efa8428c cc2538: Allow for configuration of processor speed 2015-05-19 18:55:55 +02:00
Ulf Knoblich a388a1bcd7 CC2538: added support for SSI1 2015-05-18 10:02:55 +02:00
George Oikonomou 3717522680 Re-work the CC2538 driver to be a driver for the Srf06 ALS only 2015-05-12 23:42:19 +01:00
George Oikonomou 9cc800d728 Add CC2538 VDD sensor driver 2015-05-12 23:42:19 +01:00
George Oikonomou f474514ee5 Add CC2538 tmp sensor driver 2015-05-12 23:42:19 +01:00
George Oikonomou 40716ab515 Add generic header for CC2538 sensors 2015-05-12 23:42:18 +01:00
George Oikonomou a2d6df225e Merge pull request #967 from g-oikonomou/cc2538-contrib-rf-local-vars
Use local variable to store RF on/off state
2015-05-09 22:23:31 +01:00
George Oikonomou 2059be3a43 Merge pull request #1031 from bthebaudeau/cc2538-gpio-irqs
cc2538: gpio: Improve and fix IRQ management
2015-05-03 18:42:53 +01:00
Ulf Knoblich 8e624c750d cc2538 i2c bug in clock computation 2015-04-29 11:07:59 +02:00
Benoît Thébaudeau 3d9d52de87 cc2538: gpio: Fix missed interrupts
Only the interrupt flags that have been handled must be cleared.
Otherwise, if a new interrupt occurs after the interrupt statuses are
read and before they are cleared, then it is discarded without having
been handled. This issue was particularly likely with two interrupt
trigger conditions occurring on different pins of the same port in a
short period of time.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-04-27 01:14:51 +02:00
Benoît Thébaudeau 1a5632cba0 cc2538: gpio: Fix missed power-up interrupts
Power-up interrupts do not always update the regular interrupt status.
Because of that, in order not to miss power-up interrupts, the ISR must
handle both the regular and the power-up interrupt statuses.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-04-27 01:14:51 +02:00
Benoît Thébaudeau 1e67ab3941 cc2538: gpio: Add macros to get interrupt status
Introduce new useful GPIO macros to:
 - get the raw interrupt status of a port,
 - get the masked interrupt status of a port,
 - get the power-up interrupt status of a port.

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.dev@gmail.com>
2015-04-27 01:14:51 +02:00
Benoît Thébaudeau 41d9078ed4 cc2538: gpio: Factor out duplicated ISR code
This makes the code easier to maintain, and this reduces the binary
image size.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-04-27 01:14:50 +02:00
George Oikonomou 48e987baac Merge pull request #1005 from alignan/i2c_cc2538
CC2538 I2C driver
2015-03-28 23:23:06 +00:00
Benoît Thébaudeau 19fd7a3551 Use additive offsets
OR-ing an offset to a base address instead of adding it is dangerous
because it can only work if the base address is aligned enough for the
offset.

Moreover, if the base address or the offset has a value unknown at
compile time, then the assembly instructions dedicated to 'base +
offset' addressing on most CPUs can't be emitted by the compiler because
this would require the alignment of the base address against the offset
to be known in order to optimize 'base | offset' into 'base + offset'.
In that case, the compiler has to emit more instructions in order to
compute 'base | offset' on most CPUs, e.g. on ARM, which means larger
binary size and slower execution.

Hence, replace all occurrences of 'base | offset' with 'base + offset'.
This must become a coding rule.

Here are the results for the cc2538-demo example:
 - Compilation of uart_init():
    * before:
        REG(regs->base | UART_CC) = 0;
        200b78:	f446 637c 	orr.w	r3, r6, #4032	; 0xfc0
        200b7c:	f043 0308 	orr.w	r3, r3, #8
        200b80:	2200      	movs	r2, #0
        200b82:	601a      	str	r2, [r3, #0]

    * now:
        REG(regs->base + UART_CC) = 0;
        200b7a:	2300      	movs	r3, #0
        200b7c:	f8c4 3fc8 	str.w	r3, [r4, #4040]	; 0xfc8

 - Size of the .text section:
    * before:	0x4c7c
    * now:	0x4c28
    * saved:	84 bytes

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-03-28 17:28:15 +01:00
Antonio Lignan 22be9fd8b7 I2C driver taken from PR #677, uncrustified, made functions static and added burst modes 2015-03-25 16:44:12 +01:00
George Oikonomou 5288725af7 Use local variable to store RF on/off state
Fixes #823
2015-02-18 09:05:02 +01:00
George Oikonomou 6bd8bb05f6 Improve wording 2015-02-16 10:17:58 +01:00
George Oikonomou 8751e55c94 Improve wording, fix warnigs in the SSI/SPI docs 2015-02-16 10:17:58 +01:00
George Oikonomou a93a8912c2 Clarify GPIO read and write macros 2015-02-16 10:17:57 +01:00
George Oikonomou 4100cbc9c0 Fix doxygen warning in the CC2538 uDMA driver's header 2015-02-16 10:17:57 +01:00
George Oikonomou 88e190103c Fix doxygen warning in the CC2538 SPI driver 2015-02-16 10:17:57 +01:00
Michael Karlsson 62fc6f2f07 corrected code style error 2015-02-13 13:46:57 +01:00
Michael Karlsson be9879cf18 fixed error in saving status 2015-01-21 22:35:30 +01:00
Michael Karlsson 37def294ce fixed bug that made radio die after error when not using default channel and/or not using a RDC protocol 2015-01-21 22:28:31 +01:00
Jelmer Tiete b088326b5e Corrected the register offset value of ANA_REGS_IVCTRL. TI was using the address offset instead of the physical address in their header file. 2014-12-19 04:14:34 -05:00
George Oikonomou 2e166a83c7 Merge pull request #691 from hexluthor/rts-cts
CC2538: Add hardware flow control (RTS/CTS) support on UART1.
2014-06-04 09:22:58 +01:00
George Oikonomou ba9c2d40eb Merge pull request #682 from g-oikonomou/watchdog-cc2538
Confine CC2538 WDT on/off conf inside the driver
2014-06-03 22:05:08 +01:00
Adam Dunkels 64f65b4e45 Merge pull request #617 from nfi/extended-radio-api
Extended radio API with support for setting channel, pan id, addressing modes, etc
2014-06-03 21:32:53 +02:00
Ian Martin 274b3dcd0b CC2538: Add hardware flow control (RTS/CTS) support on UART1. 2014-06-03 12:38:24 -04:00
George Oikonomou 807ee624e4 Confine CC2538 WDT on/off conf inside the driver
Instead of requiring all calls to `watchdog_start` to be
wrapped inside `#if WATCHDOG_CONF_ENABLE` guards, we control
things from within the WDT driver itself.

This commit also includes some minor documentation and
indentation cleanups
2014-05-18 14:12:16 +02:00
Ian Martin 7081440eff CC2538: Add WATCHDOG_CONF_ENABLE to optionally disable the watchdog timer. 2014-05-02 10:28:30 -04:00
George Oikonomou 08c884afa0 Improve the CC2538 extended RF API implementation
* Decouple 64-bit address from LINKADDR_SIZE
* get and set object from/to the start/end of the src/dest buffer
* We expect size == 8 (rather than size < 8) for both get_ and set_object. Error otherwise
* The RF no longer sets parameters by itself. We let the platform do this, using the extended API.
2014-04-23 12:20:16 +01:00
George Oikonomou 6028c0765f Don't hardcode min and max TX power values 2014-04-23 12:16:50 +01:00
George Oikonomou b0f1199202 Merge pull request #636 from g-oikonomou/fix-random-init-lockup
Fix CC2538 random_init lockup
2014-04-18 13:28:40 +01:00
Benoît Thébaudeau d93d129da6 cc2538: uart: Make it possible to use several UARTs simultaneously
This avoids the limitation of having a single UART available at runtime, without
duplicating code.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2014-04-17 18:53:44 +02:00
Brad Campbell af27d2d252 [CC2538-SPI] Implement SPI_FLUSH, spi mode, !CS
Because the CC2538 has a multi-byte SPI RX FIFO, flushing the buffer
requires more than just a single read. This adds a loop that empties the
entire RX buffer on a FLUSH().

Different SPI chips needs different SPI settings. This commit adds a
function that allows chip drivers to configure the SPI peripheral before
using it.

The frame pin the driver was using as a chip select does not work as
most devices expect it to. It toggles after every byte, and most chips
interpret that as end of message. To make drivers more reliable, each
chip driver should setup a GPIO and assert it as needed.
2014-04-15 14:07:10 -04:00
George Oikonomou 0ec1eda75e Implement extended RF API for the CC2538 2014-04-14 15:25:30 +02:00
George Oikonomou eed1352282 Fix CC2538 random_init lockup
Contiki sometimes fails to boot correctly and locks up in
random_init()

This problem only manifests itself for specific versions
of the arm-gcc toolchain and then again only for specific
levels of optimisation (-Os vs -O2, depending on the
value of the SMALL make variable)

The lockup is caused when we write an RFCORE XREG before
the RF clock ungating has taken effect, which in turn
only occurs depending on the assembly generated for those
two instructions:

  REG(SYS_CTRL_RCGCRFC) = 1;

  REG(RFCORE_XREG_FRMCTRL0) = 0x00000008;

This commit makes the RNG wait for the ungating to take
effect before attempting to write the register
2014-04-13 14:38:00 +01:00
George Oikonomou 33abe26ec8 Merge pull request #411 from ADVANSEE/cc2538-adc
cc2538: Add adc driver and example
2014-04-13 03:05:12 +01:00
Niclas Finne a98e153e23 Added stub for extended radio API for cc2538 2014-04-03 13:38:23 +02:00
Ian Martin 336224633a Eliminate UART_CONF_IBRD and UART_CONF_FBRD. 2014-03-22 10:26:03 -04:00
Ian Martin ee45fc7533 Change uart_set_baudrate() to a do-while statement. 2014-03-22 10:22:11 -04:00
Ian Martin 1ceb8ae358 Fix rounding error in baudrate calculation. 2014-03-22 10:21:54 -04:00
Ian Martin e3c19714d4 cc2538: Support any UART baudrate. 2014-03-14 16:06:24 -04:00
LudovicW d979e5b096 CC2538: add support for UART baudrate 9600, 38400 and 57600 2014-02-11 16:01:36 +01:00
George Oikonomou c8fbf8ca6e Merge pull request #503 from ADVANSEE/cc2538-nrdata-noload
cc2538: Clean up link stage
2014-01-30 07:58:55 -08:00
Adam Dunkels 45265249fc Changed the name of the rimeaddr module to linkaddr 2014-01-29 20:12:24 +01:00
Adam Dunkels 0fe08205e1 Moved the rimeaddr.[ch] code from the core/net/rime module to the core/net module, as it is used not only by rime code 2014-01-26 23:20:36 +01:00
Benoît Thébaudeau 37e73894f1 cc2538: Move SoC data to a dedicated section to save space
Some SoC data requires huge alignments. E.g., the µDMA channel control table has
to be 1024-byte aligned. This table was simply aligned to 1024 bytes in the C
code, which had the following consequences, wasting a lot of RAM:
 - As this table could be placed anywhere in .bss, there could be an alignment
   gap of up to 1023 bytes between the preceding data and this table.
 - The size of this table was also aligned to 1024 bytes, regardless of
   UDMA_CONF_MAX_CHANNEL, making this configuration option supposed to save RAM
   just useless.
 - .bss was also aligned to at least 1024 bytes, creating a huge alignment gap
   between .data and .bss.

Instead of relying on the compiler to force this alignment, and on the linker to
automatically place data, this change places carefully such SoC data in RAM
using the linker script. A dedicated section is created to place such SoC data
requiring huge alignments, and it is put at the beginning of the SRAM in order
to ensure a maximal alignment without any gap. In this way, the alignment of
.bss also remains normal, and the size of this table is not constrained by its
alignment, but only by its contents (i.e. by UDMA_CONF_MAX_CHANNEL).

In the case of the µDMA channel control table, the data is still zeroed by
udma_init() (instead of also being zeroed as part of .bss).

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-12-23 15:06:13 +01:00
Benoît Thébaudeau dbba311270 cc2538: Add adc driver and example
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-12-06 22:07:45 +01:00
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
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
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 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 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
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
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
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
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 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
Benoît Thébaudeau 47d570343e cc2538: sys_ctrl: Make it possible to use the 32-kHz crystal
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
2013-11-15 15:52:10 +01:00
George Oikonomou e4a454b284 Set peripheral mode for the correct UART TX/RX pins 2013-09-30 14:50:39 +01:00
George Oikonomou 2957d44ff8 Merge pull request #352 from lab11/cc2538-spi-driver
Added SPI driver for CC2538
2013-09-28 13:25:17 -07:00
Brad Campbell e2af903d05 Added SPI driver for CC2538
This uses the core/dev/spi.h header and implements the spi_init()
function and the various macros for SPI operation. ssi.h contains all of
the register locations and information.

This implementation is not very versatile, mostly because I don't how to
make it flexible in the contiki system. It supports pin muxing for the
four spi pins, but other than that picks sensible defaults.

The SPI macros (like SPI_READ()) are defined in
cpu/cc2538/spi-arch.h. In order to use the SPI driver, add the following
includes to your project:

    #include "spi-arch.h
    #include "dev/spi.h"
2013-09-27 17:46:15 -04:00
Brad Campbell 982ca0fb46 Updates CC2538 GPIO
1. Fixes two of the comments to GPIO macros. They were copied but not
updated.
2. Adds SET and CLR macros for controlling GPIO pins.
2013-09-11 21:39:56 -04:00
George Oikonomou 6c6013b898 Make the CC2538 UART driver more configurable
* We can now very easily switch between UART0 and UART1 through a define
* We can also configure the UART RX and TX port/pin through defines
2013-08-09 12:20:25 +01:00
George Oikonomou 8b5b2bd4d8 CC2538 Documentation typo and grammar fixes 2013-04-17 15:41:41 +01:00
George Oikonomou 40f49948e6 New Platform: TI CC2538 Development Kit
This commit adds cpu, platform and example files,
providing support for running Contiki on TI's cc2538 DK
2013-04-06 21:07:31 +01:00