Contiki 3.x
Modules | Files | Enumerator | Functions
STM32W108

Compiler and Platform specific definitions and typedefs common to all platforms. More...

Modules

 Status Codes
 Many StZNet API functions return an ::StStatus value to indicate the success or failure of the call.
 
 Sample A/D converter driver.
 See adc.h for source code.
 
 Sample API funtions for controlling LEDs.
 When specifying an LED to use, always use the BOARDLEDx definitions that are defined within the BOARD_HEADER.
 
 Micro
 Many of the supplied example applications use these microcontroller functions.
 
 System_timer
 Functions that provide access to the system clock.
 
 Definition and description of public flash manipulation routines.
 
 Nvm
 Cortex-M3 Non-Volatile Memory data storage system.
 
 Gnu
 Compiler and Platform specific definitions and typedefs for the GNU C ARM compiler.
 
 Iar
 Compiler and Platform specific definitions and typedefs for the IAR ARM C compiler.
 

Files

file  stm32w-radio.c
 
                           Machine dependent STM32W radio code.

 
file  stm32w-radio.h
 
    STM32W radio driver header file

 
file  uart1.c
 
                           Machine dependent STM32W UART1 code.

 
file  uart1.h
 
    A brief description of what this file is.

 
file  platform-common.h
 See platform_common for detailed documentation.
 

Functions

void ST_RadioReceiveIsrCallback (uint8_t *packet, boolean ackFramePendingSet, uint32_t time, uint16_t errors, int8_t rssi)
 This function is called by the library when a packet has been received. More...
 
void ST_RadioTransmitCompleteIsrCallback (StStatus status, uint32_t txSyncTime, boolean framePending)
 This function is called by the library once after each ST_RadioTransmit() call that returned successfully. More...
 
boolean ST_RadioDataPendingShortIdIsrCallback (uint16_t shortId)
 This function is called by the library after the short address fields of a packet have been received. More...
 
boolean ST_RadioDataPendingLongIdIsrCallback (uint8_t *longId)
 This function is called by the library after the long address fields of a packet have been received. More...
 
void ST_RadioOverflowIsrCallback (void)
 This function is called by the library in response to a receive overflow event if this notification is enabled by a call to ST_RadioEnableOverflowNotification().
 
void ST_RadioSfdSentIsrCallback (uint32_t sfdSentTime)
 This function is called by the library in response to an SFD sent event if this notification has been enabled by a call to ST_RadioEnableSfdSentNotification(). More...
 
void ST_RadioMacTimerCompareIsrCallback (void)
 This function is called by the library in response to MAC timer comparison event.
 
void SysTick_CLKSourceConfig (uint32_t SysTick_CLKSource)
 Configures the SysTick clock source. More...
 
void SysTick_SetReload (uint32_t Reload)
 Sets SysTick Reload value. More...
 
void SysTick_CounterCmd (uint32_t SysTick_Counter)
 Enables or disables the SysTick counter. More...
 
void SysTick_ITConfig (FunctionalState NewState)
 Enables or disables the SysTick Interrupt. More...
 
uint32_t SysTick_GetCounter (void)
 Gets SysTick counter value. More...
 
FlagStatus SysTick_GetFlagStatus (uint8_t SysTick_FLAG)
 Checks whether the specified SysTick flag is set or not. More...
 
void uart1_init (unsigned long ubr)
 Initalize the RS232 port.
 

Generic Types

#define TRUE   1
 An alias for one, used for clarity.
 
#define FALSE   0
 An alias for zero, used for clarity.
 
#define NULL   ((void *)0)
 The null pointer.
 

Bit Manipulation Macros

#define BIT(x)   (1U << (x))
 Useful to reference a single bit of a byte.
 
#define BIT32(x)   (((uint32_t) 1) << (x))
 Useful to reference a single bit of an uint32_t type.
 
#define SETBIT(reg, bit)   reg |= BIT(bit)
 Sets bit in the reg register or byte. More...
 
#define SETBITS(reg, bits)   reg |= (bits)
 Sets the bits in the reg register or the byte as specified in the bitmask bits. More...
 
#define CLEARBIT(reg, bit)   reg &= ~(BIT(bit))
 Clears a bit in the reg register or byte. More...
 
#define CLEARBITS(reg, bits)   reg &= ~(bits)
 Clears the bits in the reg register or byte as specified in the bitmask bits. More...
 
#define READBIT(reg, bit)   (reg & (BIT(bit)))
 Returns the value of bit within the register or byte reg.
 
#define READBITS(reg, bits)   (reg & (bits))
 Returns the value of the bitmask bits within the register or byte reg.
 

Byte Manipulation Macros

#define LOW_BYTE(n)   ((uint8_t)((n) & 0xFF))
 Returns the low byte of the 16-bit value n as an uint8_t.
 
#define HIGH_BYTE(n)   ((uint8_t)(LOW_BYTE((n) >> 8)))
 Returns the high byte of the 16-bit value n as an uint8_t.
 
#define HIGH_LOW_TO_INT(high, low)
 Returns the value built from the two uint8_t values high and low.
 
#define BYTE_0(n)   ((uint8_t)((n) & 0xFF))
 Returns the low byte of the 32-bit value n as an uint8_t.
 
#define BYTE_1(n)   ((uint8_t)(BYTE_0((n) >> 8)))
 Returns the second byte of the 32-bit value n as an uint8_t.
 
#define BYTE_2(n)   ((uint8_t)(BYTE_0((n) >> 16)))
 Returns the third byte of the 32-bit value n as an uint8_t.
 
#define BYTE_3(n)   ((uint8_t)(BYTE_0((n) >> 24)))
 Returns the high byte of the 32-bit value n as an uint8_t.
 

Time Manipulation Macros

#define elapsedTimeInt8u(oldTime, newTime)   ((uint8_t) ((uint8_t)(newTime) - (uint8_t)(oldTime)))
 Returns the elapsed time between two 8 bit values. More...
 
#define elapsedTimeInt16u(oldTime, newTime)   ((uint16_t) ((uint16_t)(newTime) - (uint16_t)(oldTime)))
 Returns the elapsed time between two 16 bit values. More...
 
#define elapsedTimeInt32u(oldTime, newTime)   ((uint32_t) ((uint32_t)(newTime) - (uint32_t)(oldTime)))
 Returns the elapsed time between two 32 bit values. More...
 
#define MAX_INT8U_VALUE   0xFF
 Returns TRUE if t1 is greater than t2. More...
 
#define timeGTorEqualInt8u(t1, t2)   (elapsedTimeInt8u(t2, t1) <= ((MAX_INT8U_VALUE + 1) / 2))
 
#define MAX_INT16U_VALUE   0xFFFF
 Returns TRUE if t1 is greater than t2. More...
 
#define timeGTorEqualInt16u(t1, t2)   (elapsedTimeInt16u(t2, t1) <= ((MAX_INT16U_VALUE + 1) / 2))
 
#define MAX_INT32U_VALUE   0xFFFFFFFF
 Returns TRUE if t1 is greater than t2. More...
 
#define timeGTorEqualInt32u(t1, t2)   (elapsedTimeInt32u(t2, t1) <= ((MAX_INT32U_VALUE + 1) / 2))
 

Receive APIs

These APIs control the reception of packets.

void ST_RadioEnableAddressFiltering (boolean enable)
 This function enables or disables address filtering on PAN ID, node ID, and EUI 64. More...
 
boolean ST_RadioAddressFilteringEnabled (void)
 This function gets the address filtering status of the device. More...
 
void ST_RadioEnableAutoAck (boolean enable)
 This function enables or disables automatic transmission of ACKs in response to received packets which request ACKs. More...
 
boolean ST_RadioAutoAckEnabled (void)
 This function gets the automatic acknowledgement status of the device. More...
 
void ST_RadioSetNodeId (u16 nodeId)
 This function sets the short address of the node. More...
 
u16 ST_RadioGetNodeId (void)
 This function gets the short address of the node. More...
 
void ST_RadioSetPanId (u16 panId)
 This function sets the PAN id of the node. More...
 
u16 ST_RadioGetPanId (void)
 This function gets the PAN id of the node. More...
 
u8 * ST_RadioGetEui64 (void)
 This function get the EUI 64 of the node. More...
 
void ST_RadioSetCoordinator (boolean coordinator)
 This function sets or clears coordinator mode for this node. More...
 
boolean ST_RadioDeviceIsCoordinator (void)
 This function gets the coordinator status of the node. More...
 
void ST_RadioEnableOverflowNotification (boolean enable)
 This function enables or disables notification of DMA receive buffer overflow events via ST_RadioOverflowIsrCallback(). More...
 
boolean ST_RadioOverflowNotificationEnabled (void)
 This function indicates whether the overflow notification via ST_RadioOverflowIsrCallback() is enabled or disabled. More...
 
void ST_RadioEnableReceiveCrc (boolean enable)
 This function enables or disables discarding received packets that fail the Cyclic Redundancy Check. More...
 
boolean ST_RadioReceiveCrcEnabled (void)
 This function gets the receive CRC configuration of the node. More...
 

Detailed Description

Compiler and Platform specific definitions and typedefs common to all platforms.

platform-common.h provides PLATFORM_HEADER defaults and common definitions. This head should never be included directly, it should only be included by the specific PLATFORM_HEADER used by your platform.

See platform-common.h for source code.

Macro Definition Documentation

#define CLEARBIT (   reg,
  bit 
)    reg &= ~(BIT(bit))

Clears a bit in the reg register or byte.

Note
Assuming reg is an IO register, some platforms (such as the AVR) can implement this in a single atomic operation.

Definition at line 226 of file platform-common.h.

#define CLEARBITS (   reg,
  bits 
)    reg &= ~(bits)

Clears the bits in the reg register or byte as specified in the bitmask bits.

Note
This is never a single atomic operation.

Definition at line 233 of file platform-common.h.

#define elapsedTimeInt16u (   oldTime,
  newTime 
)    ((uint16_t) ((uint16_t)(newTime) - (uint16_t)(oldTime)))

Returns the elapsed time between two 16 bit values.

Result may not be valid if the time samples differ by more than 32767

Definition at line 314 of file platform-common.h.

#define elapsedTimeInt32u (   oldTime,
  newTime 
)    ((uint32_t) ((uint32_t)(newTime) - (uint32_t)(oldTime)))

Returns the elapsed time between two 32 bit values.

Result may not be valid if the time samples differ by more than 2147483647

Definition at line 321 of file platform-common.h.

#define elapsedTimeInt8u (   oldTime,
  newTime 
)    ((uint8_t) ((uint8_t)(newTime) - (uint8_t)(oldTime)))

Returns the elapsed time between two 8 bit values.

Result may not be valid if the time samples differ by more than 127

Definition at line 307 of file platform-common.h.

#define MAX_INT16U_VALUE   0xFFFF

Returns TRUE if t1 is greater than t2.

Can only account for 1 wrap around of the variable before it is wrong.

Definition at line 336 of file platform-common.h.

#define MAX_INT32U_VALUE   0xFFFFFFFF

Returns TRUE if t1 is greater than t2.

Can only account for 1 wrap around of the variable before it is wrong.

Definition at line 344 of file platform-common.h.

#define MAX_INT8U_VALUE   0xFF

Returns TRUE if t1 is greater than t2.

Can only account for 1 wrap around of the variable before it is wrong.

Definition at line 328 of file platform-common.h.

#define SETBIT (   reg,
  bit 
)    reg |= BIT(bit)

Sets bit in the reg register or byte.

Note
Assuming reg is an IO register, some platforms can implement this in a single atomic operation.

Definition at line 212 of file platform-common.h.

#define SETBITS (   reg,
  bits 
)    reg |= (bits)

Sets the bits in the reg register or the byte as specified in the bitmask bits.

Note
This is never a single atomic operation.

Definition at line 219 of file platform-common.h.

Function Documentation

boolean ST_RadioAddressFilteringEnabled ( void  )

This function gets the address filtering status of the device.

Returns
TRUE if address filtering is enabled, FALSE otherwise.
boolean ST_RadioAutoAckEnabled ( void  )

This function gets the automatic acknowledgement status of the device.

Returns
TRUE if automatic acknowledgement is enabled, FALSE otherwise.
boolean ST_RadioDataPendingLongIdIsrCallback ( u8 *  longId)

This function is called by the library after the long address fields of a packet have been received.

The library will set the frame pending bit in the outgoing ACK only if the return value is TRUE. The application must lookup the eui64 in its own data structures and return TRUE if there is data pending, FALSE otherwise. It is critical that this function complete as quickly as possible to ensure the frame pending bit can be set before the ACK is transmitted.

Returns
TRUE if the frame pending bit should be set in the outgoing ACK.

Definition at line 754 of file stm32w-radio.c.

References FALSE.

boolean ST_RadioDataPendingShortIdIsrCallback ( u16  shortId)

This function is called by the library after the short address fields of a packet have been received.

The library will set the frame pending bit in the outgoing ACK only if the return value is TRUE. The application must lookup shortId in its own data structures and return TRUE if there is data pending, FALSE otherwise. It is critical that this function complete as quickly as possible to ensure the frame pending bit can be set before the ACK is transmitted.

Returns
TRUE if the frame pending bit should be set in the outgoing ACK.

Definition at line 747 of file stm32w-radio.c.

References FALSE.

boolean ST_RadioDeviceIsCoordinator ( void  )

This function gets the coordinator status of the node.

Returns
TRUE if the node is configured as a coordinator, FALSE otherwise.
void ST_RadioEnableAddressFiltering ( boolean  enable)

This function enables or disables address filtering on PAN ID, node ID, and EUI 64.

NOTE: Address filtering is enabled by default.

Parameters
enableTRUE to enable address filtering, FALSE otherwise.
void ST_RadioEnableAutoAck ( boolean  enable)

This function enables or disables automatic transmission of ACKs in response to received packets which request ACKs.

NOTE: Address filtering must be enabled for automatic transmission of ACKs to occur.

NOTE: Automatic acknowledgement is enabled by default.

Parameters
enableTRUE to enable automatic acknowledgement transmission, FALSE otherwise.
void ST_RadioEnableOverflowNotification ( boolean  enable)

This function enables or disables notification of DMA receive buffer overflow events via ST_RadioOverflowIsrCallback().

Parameters
enableTRUE to enable overflow notification, FALSE otherwise.
void ST_RadioEnableReceiveCrc ( boolean  enable)

This function enables or disables discarding received packets that fail the Cyclic Redundancy Check.

NOTE: When this option is enabled the library automatically strips the CRC bytes off of packets that pass CRC check.

NOTE: Discarding packets that fail CRC is enabled by default.

Parameters
enableTRUE to enable discarding packets that fail CRC, FALSE otherwise.
u8* ST_RadioGetEui64 ( void  )

This function get the EUI 64 of the node.

NOTE: The EUI 64 is set via manufacturing tokens (See the Programming and Serialization Specification for details).

Returns
the memory address of the 64-bit EUI address to use for filtering long-addressed packets when address filtering is enabled.
u16 ST_RadioGetNodeId ( void  )

This function gets the short address of the node.

Returns
nodeId the 16-bit address to use for filtering short-addressed packets.
u16 ST_RadioGetPanId ( void  )

This function gets the PAN id of the node.

Returns
16-bit PAN id to use for filtering packets when address filtering is enabled.
boolean ST_RadioOverflowNotificationEnabled ( void  )

This function indicates whether the overflow notification via ST_RadioOverflowIsrCallback() is enabled or disabled.

Returns
TRUE if overflow notification is enabled, FALSE otherwise.
boolean ST_RadioReceiveCrcEnabled ( void  )

This function gets the receive CRC configuration of the node.

Returns
TRUE if received packets that fail CRC will be discarded, FALSE otherwise.
void ST_RadioReceiveIsrCallback ( u8 *  packet,
boolean  ackFramePendingSet,
u32  time,
u16  errors,
s8  rssi 
)

This function is called by the library when a packet has been received.

Parameters
*packetpoints to the packet data beginning with the length byte. The CRC bytes will have been removed from the packet.
ackFramePendingSetTRUE if the library set the Frame Pending bit in the hardware-generated MAC ACK to this packet, FALSE otherwise.
timeThe value of the MAC timer when the SFD was received for this packet.
errorsThe number of correlator errors in the packet.
rssiThe energy detected over the last 8 symbols of the packet in units of dBm.

Definition at line 667 of file stm32w-radio.c.

References process_poll().

void ST_RadioSetCoordinator ( boolean  coordinator)

This function sets or clears coordinator mode for this node.

A coordinator is able to receive 802.15.4. DATA frames that have no destination address. A node that is not a coordinator will not receive these packets.

NOTE: The source PAN id of the DATA frame with no destination address must still match the node PAN id in order for it to be received by the coordinator node.

NOTE: A node is not a coordinator by default.

Parameters
coordinatorTRUE to enable coordinator mode, FALSE to disable coordinator mode.
void ST_RadioSetNodeId ( u16  nodeId)

This function sets the short address of the node.

Parameters
nodeIdthe 16-bit address to use for filtering short-addressed packets when address filtering is enabled.
void ST_RadioSetPanId ( u16  panId)

This function sets the PAN id of the node.

Parameters
panIdthe 16-bit PAN id to use for filtering packets when address filtering is enabled.
void ST_RadioSfdSentIsrCallback ( u32  sfdSentTime)

This function is called by the library in response to an SFD sent event if this notification has been enabled by a call to ST_RadioEnableSfdSentNotification().

NOTE: This callback is called for ACKs as well as normal packets.

NOTE: In cases of extreme interrupt latency it is possible that sfdSentTime may contain the SFD time of the last received packet instead of the time of the last transmitted packet.

Parameters
sfdSentTimethe value of the MAC timer when the SFD was sent in the last transmitted packet.

Definition at line 808 of file stm32w-radio.c.

void ST_RadioTransmitCompleteIsrCallback ( StStatus  status,
u32  sfdSentTime,
boolean  framePending 
)

This function is called by the library once after each ST_RadioTransmit() call that returned successfully.

If the ST_RadioTransmit() call returned an error ST_RadioTransmitCompleteIsrCallback() will not be called.

NOTE: ST_RadioTransmit() can be called again within the context of this callback.

Parameters
statusparameter indicates one of the following conditions: ::ST_SUCCESS - the last byte of the non-ACK-request packet has been transmitted. ::ST_PHY_ACK_RECEIVED - the requested ACK was received. ::ST_MAC_NO_ACK_RECEIVED - the requested ACK was not received in time. ::ST_PHY_TX_CCA_FAIL - unable to transmit due to lack of clear channel on all attempts. ::ST_PHY_TX_UNDERFLOW - DMA underflow occurred while transmitting. Should never happen. ::ST_PHY_TX_INCOMPLETE - The PLL synthesizer failed to lock while transmitting. Should never happen.
sfdSentTimethe value of the MAC timer captured when the SFD was sent.
framePendingTRUE if the received ACK indicates that data is pending for this node, FALSE otherwise.

Definition at line 701 of file stm32w-radio.c.

void SysTick_CLKSourceConfig ( uint32_t  SysTick_CLKSource)

Configures the SysTick clock source.

Parameters
SysTick_CLKSourcespecifies the SysTick clock source. This parameter can be one of the following values: SysTick_CLKSource_HCLK_Div8: AHB clock divided by 8 selected as SysTick clock source. SysTick_CLKSource_HCLK: AHB clock selected as SysTick clock source.

Definition at line 40 of file stm32w-systick.c.

References SysTick.

Referenced by clock_init().

void SysTick_CounterCmd ( uint32_t  SysTick_Counter)

Enables or disables the SysTick counter.

Parameters
SysTick_Counternew state of the SysTick counter. This parameter can be one of the following values:
  • SysTick_Counter_Disable: Disable counter
  • SysTick_Counter_Enable: Enable counter
  • SysTick_Counter_Clear: Clear counter value to 0

Definition at line 73 of file stm32w-systick.c.

References SysTick.

Referenced by clock_init().

u32 SysTick_GetCounter ( void  )

Gets SysTick counter value.

Returns
SysTick current value

Definition at line 110 of file stm32w-systick.c.

References SysTick.

FlagStatus SysTick_GetFlagStatus ( uint8_t  SysTick_FLAG)

Checks whether the specified SysTick flag is set or not.

Parameters
SysTick_FLAGspecifies the flag to check. This parameter can be one of the following values:
  • SysTick_FLAG_COUNT
  • SysTick_FLAG_SKEW
  • SysTick_FLAG_NOREF

Definition at line 124 of file stm32w-systick.c.

References SysTick.

void SysTick_ITConfig ( FunctionalState  NewState)

Enables or disables the SysTick Interrupt.

Parameters
NewStatenew state of the SysTick Interrupt. This parameter can be: ENABLE or DISABLE.

Definition at line 93 of file stm32w-systick.c.

References SysTick.

Referenced by clock_init().

void SysTick_SetReload ( uint32_t  Reload)

Sets SysTick Reload value.

Parameters
ReloadSysTick Reload new value. Must be between 1 and 0xFFFFFF.

Definition at line 57 of file stm32w-systick.c.

References SysTick.

Referenced by clock_init().