Cleanup and refactoring of the STM32w port

This is a general cleanup of things like code style issues and code structure of the STM32w port to make it more like the rest of Contiki is structured.
This commit is contained in:
Adam Dunkels 2013-03-15 16:14:09 +01:00
parent 12b3d02ba1
commit a5046e83c7
118 changed files with 4470 additions and 4281 deletions

View file

@ -1,5 +1,11 @@
/**
* \addtogroup stm32w-cpu
*
* @{
*/
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
* File Name : cortexm3_macro.h
* File Name : cortexm3-macro.h
* Author : MCD Application Team
* Version : V2.0.3
* Date : 09/22/2008
@ -13,17 +19,11 @@
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CORTEXM3_MACRO_H
#define __CORTEXM3_MACRO_H
/* Includes ------------------------------------------------------------------*/
#include "stm32w_type.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void __WFI(void);
void __WFE(void);
void __SEV(void);
@ -31,23 +31,30 @@ void __ISB(void);
void __DSB(void);
void __DMB(void);
void __SVC(void);
u32 __MRS_CONTROL(void);
void __MSR_CONTROL(u32 Control);
u32 __MRS_PSP(void);
void __MSR_PSP(u32 TopOfProcessStack);
u32 __MRS_MSP(void);
void __MSR_MSP(u32 TopOfMainStack);
void __RESETPRIMASK(void);
void __SETPRIMASK(void);
u32 __READ_PRIMASK(void);
void __RESETFAULTMASK(void);
void __SETFAULTMASK(void);
u32 __READ_FAULTMASK(void);
void __BASEPRICONFIG(u32 NewPriority);
u32 __GetBASEPRI(void);
u16 __REV_HalfWord(u16 Data);
u32 __REV_Word(u32 Data);
#endif /* __CORTEXM3_MACRO_H */
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
/** @} */

View file

@ -0,0 +1,227 @@
/**
* \addtogroup stm32w-cpu
*
* @{
*/
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
* File Name : stm32w-conf.h
* Author : MCD Application Team
* Version : V2.0.3
* Date : 09/22/2008
* Description : Library configuration file.
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef __STM32F10x_CONF_H
#define __STM32F10x_CONF_H
#include "stm32w108-type.h"
/*
* Uncomment the line below to compile the library in DEBUG mode, this will
* expand the "assert_param" macro in the firmware library code (see "Exported
* macro" section below)
*/
/*#define DEBUG 1*/
/*---------------------------------------------------------------------------*/
/* Comment any line below to disable the specific peripheral inclusion */
/*
* ADC
*/
/* #define _ADC */
/* #define _ADC1 */
/* #define _ADC2 */
/* #define _ADC3 */
/*
* BKP
*/
/* #define _BKP */
/*
* CAN
*/
/* #define _CAN */
/*
* CRC
*/
/* #define _CRC */
/*
* DAC
*/
/* #define _DAC */
/*
* DBGMCU
*/
/* #define _DBGMCU */
/*
* DMA
*/
/* #define _DMA */
/* #define _DMA1_Channel1 */
/* #define _DMA1_Channel2 */
/* #define _DMA1_Channel3 */
/* #define _DMA1_Channel4 */
/* #define _DMA1_Channel5 */
/* #define _DMA1_Channel6 */
/* #define _DMA1_Channel7 */
/* #define _DMA2_Channel1 */
/* #define _DMA2_Channel2 */
/* #define _DMA2_Channel3 */
/* #define _DMA2_Channel4 */
/* #define _DMA2_Channel5 */
/*
* EXTI
*/
/* #define _EXTI */
/*
* FLASH and Option Bytes
*/
#define _FLASH
/*
* Uncomment the line below to enable FLASH program/erase/protections functions,
* otherwise only FLASH configuration (latency, prefetch, half cycle) functions
* are enabled
*/
/* #define _FLASH_PROG */
/*
* FSMC
*/
/* #define _FSMC */
/*
* GPIO
*/
#define _GPIO
/* #define _GPIOA */
/* #define _GPIOB */
#define _GPIOC
/* #define _GPIOD */
/* #define _GPIOE */
#define _GPIOF
/* #define _GPIOG */
#define _AFIO
/*
* I2C
*/
/* #define _I2C */
/* #define _I2C1 */
/* #define _I2C2 */
/*
* IWDG
*/
/* #define _IWDG */
/*
* NVIC
*/
#define _NVIC
/*
* PWR
*/
/* #define _PWR */
/*
* RCC
*/
#define _RCC
/*
* RTC
*/
/* #define _RTC */
/*
* SDIO
*/
/* #define _SDIO */
/*
* SPI
*/
/* #define _SPI */
/* #define _SPI1 */
/* #define _SPI2 */
/* #define _SPI3 */
/*
* SysTick
*/
#define _SysTick
/*
* TIM
*/
/* #define _TIM */
/* #define _TIM1 */
/* #define _TIM2 */
/* #define _TIM3 */
/* #define _TIM4 */
/* #define _TIM5 */
/* #define _TIM6 */
/* #define _TIM7 */
/* #define _TIM8 */
/*
* USART
*/
/* #define _USART */
/* #define _USART1 */
/* #define _USART2 */
/* #define _USART3 */
/* #define _UART4 */
/* #define _UART5 */
/*
* WWDG
*/
/* #define _WWDG */
/*
* In the following line adjust the value of External High Speed oscillator
* (HSE) used in your application
*/
#define HSE_Value ((u32)8000000) /* Value of the External oscillator in Hz */
/*
* In the following line adjust the External High Speed oscillator (HSE) Startup
* Timeout value.
*/
#define HSEStartUp_TimeOut ((u16)0x0500) /* Time out for HSE start up */
#ifdef DEBUG
/**
* \brief The assert_param macro is used for function's parameters check.
* It is used only if the library is compiled in DEBUG mode.
* \param expr If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
*/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((u8 *)__FILE__, __LINE__))
void assert_failed(u8 * file, u32 line);
#else
#define assert_param(expr) ((void)0)
#endif /* DEBUG */
#endif /* __STM32F10x_CONF_H */
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
/** @} */

View file

@ -1,3 +1,9 @@
/**
* \addtogroup stm32w-cpu
*
* @{
*/
/*
* Copyright (c) 2010, STMicroelectronics.
* All rights reserved.
@ -27,10 +33,8 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the Contiki OS
*
*/
/*---------------------------------------------------------------------------*/
/**
* \file
* Machine dependent STM32W radio code.
@ -39,7 +43,6 @@
* Chi-Anh La la@imag.fr
* Simon Duquennoy <simonduq@sics.se>
*/
/*---------------------------------------------------------------------------*/
#include PLATFORM_HEADER
#include "hal/error.h"
@ -72,39 +75,38 @@
#define LED_ACTIVITY 1
#else
#define LED_RDC 0
#endif
#endif /* RDC_CONF_DEBUG_LED */
#if DEBUG > 0
#include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...) do {} while (0)
#endif
#endif /* DEBUG > 0 */
#if LED_ACTIVITY
#define LED_TX_ON() leds_on(LEDS_GREEN)
#define LED_TX_OFF() leds_off(LEDS_GREEN)
#define LED_RX_ON() { \
#define LED_RX_ON() do { \
if(LED_RDC == 0){ \
leds_on(LEDS_RED); \
} \
}
#define LED_RX_OFF() { \
} while (0)
#define LED_RX_OFF() do { \
if(LED_RDC == 0){ \
leds_off(LEDS_RED); \
leds_off(LEDS_RED); \
} \
}
#define LED_RDC_ON() { \
} while (0)
#define LED_RDC_ON() do { \
if(LED_RDC == 1){ \
leds_on(LEDS_RED); \
} \
}
#define LED_RDC_OFF() { \
} while (0)
#define LED_RDC_OFF() do { \
if(LED_RDC == 1){ \
leds_off(LEDS_RED); \
leds_off(LEDS_RED); \
} \
}
} while (0)
#else
#define LED_TX_ON()
#define LED_TX_OFF()
@ -112,63 +114,59 @@
#define LED_RX_OFF()
#define LED_RDC_ON()
#define LED_RDC_OFF()
#endif
#endif /* LED_ACTIVITY */
#if RDC_CONF_HARDWARE_CSMA
#define MAC_RETRIES 0
#endif
#endif /* RDC_CONF_HARDWARE_CSMA */
#ifndef MAC_RETRIES
#define MAC_RETRIES 1
#endif
#endif /* MAC_RETRIES */
#if MAC_RETRIES
int8_t mac_retries_left;
#define INIT_RETRY_CNT() (mac_retries_left = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS))
#define DEC_RETRY_CNT() (mac_retries_left--)
#define RETRY_CNT_GTZ() (mac_retries_left > 0)
int8_t mac_retries_left;
#define INIT_RETRY_CNT() (mac_retries_left = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS))
#define DEC_RETRY_CNT() (mac_retries_left--)
#define RETRY_CNT_GTZ() (mac_retries_left > 0)
#else
#define INIT_RETRY_CNT()
#define DEC_RETRY_CNT()
#define RETRY_CNT_GTZ() 0
#endif
#define INIT_RETRY_CNT()
#define DEC_RETRY_CNT()
#define RETRY_CNT_GTZ() 0
#endif /* MAC_RETRIES */
/* If set to 1, a send() returns only after the packet has been transmitted.
This is necessary if you use the x-mac module, for example. */
#ifndef RADIO_WAIT_FOR_PACKET_SENT
#define RADIO_WAIT_FOR_PACKET_SENT 1
#endif
#endif /* RADIO_WAIT_FOR_PACKET_SENT */
#define TO_PREV_STATE() { \
#define TO_PREV_STATE() do { \
if(onoroff == OFF){ \
ST_RadioSleep(); \
ENERGEST_OFF(ENERGEST_TYPE_LISTEN); \
} \
}
} while(0)
#if RDC_CONF_HARDWARE_CSMA
#define ST_RADIO_CHECK_CCA FALSE
#define ST_RADIO_CCA_ATTEMPT_MAX 0
#define ST_BACKOFF_EXP_MIN 0
#define ST_BACKOFF_EXP_MAX 0
#else
#else /* RDC_CONF_HARDWARE_CSMA */
#define ST_RADIO_CHECK_CCA TRUE
#define ST_RADIO_CCA_ATTEMPT_MAX 4
#define ST_BACKOFF_EXP_MIN 2
#define ST_BACKOFF_EXP_MAX 6
#endif
#endif /* RDC_CONF_HARDWARE_CSMA */
const RadioTransmitConfig radioTransmitConfig = {
TRUE, // waitForAck;
ST_RADIO_CHECK_CCA, // checkCca; // Set to FALSE with low-power MACs.
ST_RADIO_CCA_ATTEMPT_MAX, // ccaAttemptMax;
ST_BACKOFF_EXP_MIN, // backoffExponentMin;
ST_BACKOFF_EXP_MAX, // backoffExponentMax;
TRUE // appendCrc;
TRUE, /* waitForAck; */
ST_RADIO_CHECK_CCA, /* checkCca;Set to FALSE with low-power MACs. */
ST_RADIO_CCA_ATTEMPT_MAX, /* ccaAttemptMax; */
ST_BACKOFF_EXP_MIN, /* backoffExponentMin; */
ST_BACKOFF_EXP_MAX, /* backoffExponentMax; */
TRUE /* appendCrc; */
};
#define MAC_RETRIES 0
@ -178,38 +176,38 @@ const RadioTransmitConfig radioTransmitConfig = {
*/
#ifndef RADIO_RXBUFS
#define RADIO_RXBUFS 1
#endif
#endif /* RADIO_RXBUFS */
static uint8_t stm32w_rxbufs[RADIO_RXBUFS][STM32W_MAX_PACKET_LEN+1]; // +1 because of the first byte, which will contain the length of the packet.
/* +1 because of the first byte, which will contain the length of the packet. */
static uint8_t stm32w_rxbufs[RADIO_RXBUFS][STM32W_MAX_PACKET_LEN + 1];
#if RADIO_RXBUFS > 1
static volatile int8_t first = -1, last=0;
#else
static const int8_t first=0, last=0;
#endif
static volatile int8_t first = -1, last = 0;
#else /* RADIO_RXBUFS > 1 */
static const int8_t first = 0, last = 0;
#endif /* RADIO_RXBUFS > 1 */
#if RADIO_RXBUFS > 1
#define CLEAN_RXBUFS() do{first = -1; last = 0;}while(0)
#define RXBUFS_EMPTY() (first == -1)
int RXBUFS_FULL(){
int8_t first_tmp = first;
return first_tmp == last;
#define CLEAN_RXBUFS() do{first = -1; last = 0;}while(0)
#define RXBUFS_EMPTY() (first == -1)
int
RXBUFS_FULL()
{
int8_t first_tmp = first;
return first_tmp == last;
}
#else /* RADIO_RXBUFS > 1 */
#define CLEAN_RXBUFS() (stm32w_rxbufs[0][0] = 0)
#define RXBUFS_EMPTY() (stm32w_rxbufs[0][0] == 0)
#define RXBUFS_FULL() (stm32w_rxbufs[0][0] != 0)
#define CLEAN_RXBUFS() (stm32w_rxbufs[0][0] = 0)
#define RXBUFS_EMPTY() (stm32w_rxbufs[0][0] == 0)
#define RXBUFS_FULL() (stm32w_rxbufs[0][0] != 0)
#endif /* RADIO_RXBUFS > 1 */
static uint8_t __attribute__(( aligned(2) )) stm32w_txbuf[STM32W_MAX_PACKET_LEN+1];
static uint8_t
__attribute__ ((aligned(2))) stm32w_txbuf[STM32W_MAX_PACKET_LEN + 1];
#define CLEAN_TXBUF() (stm32w_txbuf[0] = 0)
#define TXBUF_EMPTY() (stm32w_txbuf[0] == 0)
#define CHECKSUM_LEN 2
/*
@ -218,65 +216,76 @@ static uint8_t __attribute__(( aligned(2) )) stm32w_txbuf[STM32W_MAX_PACKET_LEN+
#define ON 0
#define OFF 1
#define BUSYWAIT_UNTIL(cond, max_time) \
do { \
rtimer_clock_t t0; \
t0 = RTIMER_NOW(); \
while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + (max_time))); \
} while(0)
#define GET_LOCK() locked++
static volatile uint8_t onoroff = OFF;
static uint8_t receiving_packet = 0;
static s8 last_rssi;
static int8_t last_rssi;
static volatile StStatus last_tx_status;
#define BUSYWAIT_UNTIL(cond, max_time) \
do { \
rtimer_clock_t t0; \
t0 = RTIMER_NOW(); \
while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + (max_time))); \
} while(0)
static uint8_t locked;
#define GET_LOCK() locked++
static void RELEASE_LOCK(void) {
if(locked>0)
locked--;
}
static volatile uint8_t is_transmit_ack;
/*--------------------------------------------------------------------------*/
static void
RELEASE_LOCK(void)
{
if(locked > 0)
locked--;
}
/*---------------------------------------------------------------------------*/
PROCESS(stm32w_radio_process, "STM32W radio driver");
/*---------------------------------------------------------------------------*/
static int stm32w_radio_init(void);
static int stm32w_radio_prepare(const void *payload, unsigned short payload_len);
static int stm32w_radio_prepare(const void *payload,
unsigned short payload_len);
static int stm32w_radio_transmit(unsigned short payload_len);
static int stm32w_radio_send(const void *data, unsigned short len);
static int stm32w_radio_read(void *buf, unsigned short bufsize);
static int stm32w_radio_channel_clear(void);
static int stm32w_radio_receiving_packet(void);
static int stm32w_radio_pending_packet(void);
static int stm32w_radio_on(void);
static int stm32w_radio_off(void);
static int add_to_rxbuf(uint8_t * src);
static int read_from_rxbuf(void * dest, unsigned short len);
const struct radio_driver stm32w_radio_driver =
{
stm32w_radio_init,
stm32w_radio_prepare,
stm32w_radio_transmit,
stm32w_radio_send,
stm32w_radio_read,
stm32w_radio_channel_clear,
stm32w_radio_receiving_packet,
stm32w_radio_pending_packet,
stm32w_radio_on,
stm32w_radio_off,
};
static int read_from_rxbuf(void *dest, unsigned short len);
/*--------------------------------------------------------------------------*/
const struct radio_driver stm32w_radio_driver = {
stm32w_radio_init,
stm32w_radio_prepare,
stm32w_radio_transmit,
stm32w_radio_send,
stm32w_radio_read,
stm32w_radio_channel_clear,
stm32w_radio_receiving_packet,
stm32w_radio_pending_packet,
stm32w_radio_on,
stm32w_radio_off,
};
/*---------------------------------------------------------------------------*/
static int stm32w_radio_init(void)
static int
stm32w_radio_init(void)
{
// A channel needs also to be setted.
/* A channel also needs to be set. */
ST_RadioSetChannel(RF_CHANNEL);
// Initialize radio (analog section, digital baseband and MAC).
// Leave radio powered up in non-promiscuous rx mode.
/* Initialize radio (analog section, digital baseband and MAC). */
/* Leave radio powered up in non-promiscuous rx mode. */
ST_RadioInit(ST_RADIO_POWER_MODE_OFF);
onoroff = OFF;
@ -297,172 +306,185 @@ static int stm32w_radio_init(void)
return 0;
}
/*---------------------------------------------------------------------------*/
int stm32w_radio_set_channel(uint8_t channel)
void
stm32w_radio_set_promiscous(uint8_t on)
{
if (ST_RadioSetChannel(channel) == ST_SUCCESS)
return 0;
else
return 1;
if(on) {
ST_RadioEnableAddressFiltering(0);
} else {
ST_RadioEnableAddressFiltering(ST_RADIO_AUTOACK);
}
}
/*---------------------------------------------------------------------------*/
static int wait_for_tx(void){
int
stm32w_radio_set_channel(uint8_t channel)
{
if (ST_RadioSetChannel(channel) == ST_SUCCESS) {
return 0;
} else {
return 1;
}
}
/*---------------------------------------------------------------------------*/
static int
wait_for_tx(void)
{
struct timer t;
timer_set(&t, CLOCK_SECOND/10);
while(!TXBUF_EMPTY()){
if(timer_expired(&t)){
timer_set(&t, CLOCK_SECOND / 10);
while(!TXBUF_EMPTY()) {
if(timer_expired(&t)) {
PRINTF("stm32w: tx buffer full.\r\n");
return 1;
}
/* Put CPU in sleep mode. */
halSleepWithOptions(SLEEPMODE_IDLE,0);
halSleepWithOptions(SLEEPMODE_IDLE, 0);
}
return 0;
}
/*---------------------------------------------------------------------------*/
static int stm32w_radio_prepare(const void *payload, unsigned short payload_len)
static int
stm32w_radio_prepare(const void *payload, unsigned short payload_len)
{
if(payload_len > STM32W_MAX_PACKET_LEN){
PRINTF("stm32w: payload length=%d is too long.\r\n", payload_len);
return RADIO_TX_ERR;
}
if(payload_len > STM32W_MAX_PACKET_LEN) {
PRINTF("stm32w: payload length=%d is too long.\r\n", payload_len);
return RADIO_TX_ERR;
}
#if !RADIO_WAIT_FOR_PACKET_SENT
/* Check if the txbuf is empty.
* Wait for a finite time.
* This sould not occur if we wait for the end of transmission in stm32w_radio_transmit().
*/
if(wait_for_tx()){
PRINTF("stm32w: tx buffer full.\r\n");
return RADIO_TX_ERR;
}
/*
* Check if the txbuf is empty. Wait for a finite time.
* This should not occur if we wait for the end of transmission in
* stm32w_radio_transmit().
*/
if(wait_for_tx()) {
PRINTF("stm32w: tx buffer full.\r\n");
return RADIO_TX_ERR;
}
#endif /* RADIO_WAIT_FOR_PACKET_SENT */
/* Copy to the txbuf.
* The first byte must be the packet length.
*/
CLEAN_TXBUF();
memcpy(stm32w_txbuf + 1, payload, payload_len);
return RADIO_TX_OK;
/*
* Copy to the txbuf.
* The first byte must be the packet length.
*/
CLEAN_TXBUF();
memcpy(stm32w_txbuf + 1, payload, payload_len);
return RADIO_TX_OK;
}
/*---------------------------------------------------------------------------*/
static int stm32w_radio_transmit(unsigned short payload_len)
static int
stm32w_radio_transmit(unsigned short payload_len)
{
stm32w_txbuf[0] = payload_len + CHECKSUM_LEN;
INIT_RETRY_CNT();
if(onoroff == OFF){
PRINTF("stm32w: Radio is off, turning it on.\r\n");
ST_RadioWake();
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
}
stm32w_txbuf[0] = payload_len + CHECKSUM_LEN;
INIT_RETRY_CNT();
if(onoroff == OFF) {
PRINTF("stm32w: Radio is off, turning it on.\r\n");
ST_RadioWake();
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
}
#if RADIO_WAIT_FOR_PACKET_SENT
GET_LOCK();
GET_LOCK();
#endif /* RADIO_WAIT_FOR_PACKET_SENT */
last_tx_status = -1;
LED_TX_ON();
if(ST_RadioTransmit(stm32w_txbuf)==ST_SUCCESS){
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
PRINTF("stm32w: sending %d bytes\r\n", payload_len);
last_tx_status = -1;
LED_TX_ON();
if(ST_RadioTransmit(stm32w_txbuf) == ST_SUCCESS) {
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
PRINTF("stm32w: sending %d bytes\r\n", payload_len);
#if DEBUG > 1
for(uint8_t c=1; c <= stm32w_txbuf[0]-2; c++){
PRINTF("%x:",stm32w_txbuf[c]);
}
PRINTF("\r\n");
for(uint8_t c = 1; c <= stm32w_txbuf[0] - 2; c++) {
PRINTF("%x:", stm32w_txbuf[c]);
}
PRINTF("\r\n");
#endif
#if RADIO_WAIT_FOR_PACKET_SENT
if(wait_for_tx()){
PRINTF("stm32w: unknown tx error.\r\n");
TO_PREV_STATE();
LED_TX_OFF();
RELEASE_LOCK();
return RADIO_TX_ERR;
}
if(wait_for_tx()) {
PRINTF("stm32w: unknown tx error.\r\n");
TO_PREV_STATE();
if(last_tx_status == ST_SUCCESS || last_tx_status == ST_PHY_ACK_RECEIVED || last_tx_status == ST_MAC_NO_ACK_RECEIVED){
RELEASE_LOCK();
if(last_tx_status == ST_PHY_ACK_RECEIVED){
return RADIO_TX_OK; /* ACK status */
}
else if (last_tx_status == ST_MAC_NO_ACK_RECEIVED || last_tx_status == ST_SUCCESS){
return RADIO_TX_NOACK;
}
}
LED_TX_OFF();
RELEASE_LOCK();
return RADIO_TX_ERR;
}
TO_PREV_STATE();
if(last_tx_status == ST_SUCCESS || last_tx_status == ST_PHY_ACK_RECEIVED ||
last_tx_status == ST_MAC_NO_ACK_RECEIVED) {
RELEASE_LOCK();
if(last_tx_status == ST_PHY_ACK_RECEIVED) {
return RADIO_TX_OK; /* ACK status */
} else if(last_tx_status == ST_MAC_NO_ACK_RECEIVED ||
last_tx_status == ST_SUCCESS) {
return RADIO_TX_NOACK;
}
}
LED_TX_OFF();
RELEASE_LOCK();
return RADIO_TX_ERR;
#else /* RADIO_WAIT_FOR_PACKET_SENT */
TO_PREV_STATE();
LED_TX_OFF();
return RADIO_TX_OK;
TO_PREV_STATE();
LED_TX_OFF();
return RADIO_TX_OK;
#endif /* RADIO_WAIT_FOR_PACKET_SENT */
}
}
#if RADIO_WAIT_FOR_PACKET_SENT
RELEASE_LOCK();
RELEASE_LOCK();
#endif /* RADIO_WAIT_FOR_PACKET_SENT */
TO_PREV_STATE();
TO_PREV_STATE();
PRINTF("stm32w: transmission never started.\r\n");
/* TODO: Do we have to retransmit? */
CLEAN_TXBUF();
LED_TX_OFF();
return RADIO_TX_ERR;
PRINTF("stm32w: transmission never started.\r\n");
/* TODO: Do we have to retransmit? */
CLEAN_TXBUF();
LED_TX_OFF();
return RADIO_TX_ERR;
}
/*---------------------------------------------------------------------------*/
static int stm32w_radio_send(const void *payload, unsigned short payload_len)
static int
stm32w_radio_send(const void *payload, unsigned short payload_len)
{
if(stm32w_radio_prepare(payload, payload_len) == RADIO_TX_ERR)
if (stm32w_radio_prepare(payload, payload_len) == RADIO_TX_ERR) {
return RADIO_TX_ERR;
}
return stm32w_radio_transmit(payload_len);
}
/*---------------------------------------------------------------------------*/
static int stm32w_radio_channel_clear(void)
static int
stm32w_radio_channel_clear(void)
{
return ST_RadioChannelIsClear();
}
/*---------------------------------------------------------------------------*/
static int stm32w_radio_receiving_packet(void)
static int
stm32w_radio_receiving_packet(void)
{
return receiving_packet;
}
/*---------------------------------------------------------------------------*/
static int stm32w_radio_pending_packet(void)
static int
stm32w_radio_pending_packet(void)
{
return !RXBUFS_EMPTY();
}
/*---------------------------------------------------------------------------*/
static int stm32w_radio_off(void)
static int
stm32w_radio_off(void)
{
/* Any transmit or receive packets in progress are aborted.
* Waiting for end of transmission or reception have to be done.
*/
if(locked)
{
PRINTF("stm32w: try to off while sending/receiving (lock=%u).\r\n", locked);
if(locked) {
PRINTF("stm32w: try to off while sending/receiving (lock=%u).\r\n",
locked);
return 0;
}
/* off only if there is no transmission or reception of packet. */
if(onoroff == ON && TXBUF_EMPTY() && !receiving_packet){
if(onoroff == ON && TXBUF_EMPTY() && !receiving_packet) {
LED_RDC_OFF();
ST_RadioSleep();
onoroff = OFF;
@ -475,10 +497,11 @@ static int stm32w_radio_off(void)
return 1;
}
/*---------------------------------------------------------------------------*/
static int stm32w_radio_on(void)
static int
stm32w_radio_on(void)
{
PRINTF("stm32w: turn radio on\n");
if(onoroff == OFF){
if(onoroff == OFF) {
LED_RDC_ON();
ST_RadioWake();
onoroff = ON;
@ -489,24 +512,23 @@ static int stm32w_radio_on(void)
return 1;
}
/*---------------------------------------------------------------------------*/
int stm32w_radio_is_on(void)
int
stm32w_radio_is_on(void)
{
return onoroff == ON;
}
/*---------------------------------------------------------------------------*/
void ST_RadioReceiveIsrCallback(u8 *packet,
boolean ackFramePendingSet,
u32 time,
u16 errors,
s8 rssi)
void
ST_RadioReceiveIsrCallback(uint8_t *packet,
boolean ackFramePendingSet,
uint32_t time, uint16_t errors, int8_t rssi)
{
LED_RX_ON();
PRINTF("stm32w: incomming packet received\n");
receiving_packet = 0;
/* Copy packet into the buffer. It is better to do this here. */
if(add_to_rxbuf(packet)){
if(add_to_rxbuf(packet)) {
process_poll(&stm32w_radio_process);
last_rssi = rssi;
}
@ -516,83 +538,76 @@ void ST_RadioReceiveIsrCallback(u8 *packet,
/* Wait for sending ACK */
BUSYWAIT_UNTIL(!is_transmit_ack, RTIMER_SECOND / 1500);
RELEASE_LOCK();
}
void ST_RadioTxAckIsrCallback (void)
/*--------------------------------------------------------------------------*/
void
ST_RadioTxAckIsrCallback(void)
{
/* This callback is for simplemac 1.1.0.
Till now we block (RTIMER_SECOND / 1500)
to prevent radio off during ACK transmission */
/*
* This callback is for simplemac 1.1.0.
* Till now we block (RTIMER_SECOND / 1500)
* to prevent radio off during ACK transmission.
*/
is_transmit_ack = 0;
//RELEASE_LOCK();
/* RELEASE_LOCK(); */
}
void ST_RadioTransmitCompleteIsrCallback(StStatus status,
u32 txSyncTime,
boolean framePending)
/*--------------------------------------------------------------------------*/
void
ST_RadioTransmitCompleteIsrCallback(StStatus status,
uint32_t txSyncTime, boolean framePending)
{
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
LED_TX_OFF();
last_tx_status = status;
if(status == ST_SUCCESS || status == ST_PHY_ACK_RECEIVED){
if(status == ST_SUCCESS || status == ST_PHY_ACK_RECEIVED) {
CLEAN_TXBUF();
} else {
if(RETRY_CNT_GTZ()) {
/* Retransmission */
LED_TX_ON();
if(ST_RadioTransmit(stm32w_txbuf) == ST_SUCCESS) {
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
PRINTF("stm32w: retransmission.\r\n");
DEC_RETRY_CNT();
} else {
CLEAN_TXBUF();
LED_TX_OFF();
PRINTF("stm32w: retransmission failed.\r\n");
}
} else {
CLEAN_TXBUF();
}
else {
if(RETRY_CNT_GTZ()){
// Retransmission
LED_TX_ON();
if(ST_RadioTransmit(stm32w_txbuf)==ST_SUCCESS){
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
PRINTF("stm32w: retransmission.\r\n");
DEC_RETRY_CNT();
}
else {
CLEAN_TXBUF();
LED_TX_OFF();
PRINTF("stm32w: retransmission failed.\r\n");
}
}
else {
CLEAN_TXBUF();
}
}
}
/* Debug outputs. */
if(status == ST_SUCCESS || status == ST_PHY_ACK_RECEIVED){
PRINTF("stm32w: return status TX_END\r\n");
}
else if (status == ST_MAC_NO_ACK_RECEIVED){
PRINTF("stm32w: return status TX_END_NOACK\r\n");
}
else if (status == ST_PHY_TX_CCA_FAIL){
PRINTF("stm32w: return status TX_END_CCA_FAIL\r\n");
}
else if(status == ST_PHY_TX_UNDERFLOW){
PRINTF("stm32w: return status TX_END_UNDERFLOW\r\n");
}
else {
PRINTF("stm32w: return status TX_END_INCOMPLETE\r\n");
if(status == ST_SUCCESS || status == ST_PHY_ACK_RECEIVED) {
PRINTF("stm32w: return status TX_END\r\n");
} else if(status == ST_MAC_NO_ACK_RECEIVED) {
PRINTF("stm32w: return status TX_END_NOACK\r\n");
} else if(status == ST_PHY_TX_CCA_FAIL) {
PRINTF("stm32w: return status TX_END_CCA_FAIL\r\n");
} else if(status == ST_PHY_TX_UNDERFLOW) {
PRINTF("stm32w: return status TX_END_UNDERFLOW\r\n");
} else {
PRINTF("stm32w: return status TX_END_INCOMPLETE\r\n");
}
}
boolean ST_RadioDataPendingShortIdIsrCallback(int16u shortId) {
/*--------------------------------------------------------------------------*/
boolean
ST_RadioDataPendingShortIdIsrCallback(uint16_t shortId)
{
receiving_packet = 1;
return FALSE;
}
boolean ST_RadioDataPendingLongIdIsrCallback(int8u* longId) {
/*--------------------------------------------------------------------------*/
boolean
ST_RadioDataPendingLongIdIsrCallback(uint8_t * longId)
{
receiving_packet = 1;
return FALSE;
}
@ -600,20 +615,16 @@ boolean ST_RadioDataPendingLongIdIsrCallback(int8u* longId) {
PROCESS_THREAD(stm32w_radio_process, ev, data)
{
int len;
PROCESS_BEGIN();
PRINTF("stm32w_radio_process: started\r\n");
while(1) {
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
PRINTF("stm32w_radio_process: calling receiver callback\r\n");
#if DEBUG > 1
for(uint8_t c=1; c <= RCVD_PACKET_LEN; c++){
PRINTF("%x",stm32w_rxbuf[c]);
for(uint8_t c = 1; c <= RCVD_PACKET_LEN; c++) {
PRINTF("%x", stm32w_rxbuf[c]);
}
PRINTF("\r\n");
#endif
@ -624,84 +635,88 @@ PROCESS_THREAD(stm32w_radio_process, ev, data)
packetbuf_set_datalen(len);
NETSTACK_RDC.input();
}
if(!RXBUFS_EMPTY()){
// Some data packet still in rx buffer (this happens because process_poll doesn't queue requests),
// so stm32w_radio_process need to be called again.
if(!RXBUFS_EMPTY()) {
/*
* Some data packet still in rx buffer (this happens because process_poll
* doesn't queue requests), so stm32w_radio_process needs to be called
* again.
*/
process_poll(&stm32w_radio_process);
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
static int stm32w_radio_read(void *buf, unsigned short bufsize)
static int
stm32w_radio_read(void *buf, unsigned short bufsize)
{
return read_from_rxbuf(buf,bufsize);
return read_from_rxbuf(buf, bufsize);
}
/*---------------------------------------------------------------------------*/
void ST_RadioOverflowIsrCallback(void)
void
ST_RadioOverflowIsrCallback(void)
{
PRINTF("stm32w: radio overflow\r\n");
}
/*---------------------------------------------------------------------------*/
void ST_RadioSfdSentIsrCallback(u32 sfdSentTime)
void
ST_RadioSfdSentIsrCallback(uint32_t sfdSentTime)
{
}
/*---------------------------------------------------------------------------*/
void ST_RadioMacTimerCompareIsrCallback(void)
void
ST_RadioMacTimerCompareIsrCallback(void)
{
}
/*---------------------------------------------------------------------------*/
static int add_to_rxbuf(uint8_t * src)
static int
add_to_rxbuf(uint8_t *src)
{
if(RXBUFS_FULL()){
return 0;
}
if(RXBUFS_FULL()) {
return 0;
}
memcpy(stm32w_rxbufs[last], src, src[0] + 1);
memcpy(stm32w_rxbufs[last], src, src[0] + 1);
#if RADIO_RXBUFS > 1
last = (last + 1) % RADIO_RXBUFS;
if(first == -1){
first = 0;
}
last = (last + 1) % RADIO_RXBUFS;
if(first == -1) {
first = 0;
}
#endif
return 1;
return 1;
}
/*---------------------------------------------------------------------------*/
static int read_from_rxbuf(void * dest, unsigned short len)
static int
read_from_rxbuf(void *dest, unsigned short len)
{
if(RXBUFS_EMPTY()) { /* Buffers are all empty */
return 0;
}
if(RXBUFS_EMPTY()){ // Buffers are all empty
return 0;
}
if(stm32w_rxbufs[first][0] > len){ // Too large packet for dest.
len = 0;
}
else {
len = stm32w_rxbufs[first][0];
memcpy(dest,stm32w_rxbufs[first]+1,len);
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, last_rssi);
}
if(stm32w_rxbufs[first][0] > len) { /* Too large packet for dest. */
len = 0;
} else {
len = stm32w_rxbufs[first][0];
memcpy(dest, stm32w_rxbufs[first] + 1, len);
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, last_rssi);
}
#if RADIO_RXBUFS > 1
ATOMIC(
first = (first + 1) % RADIO_RXBUFS;
int first_tmp = first;
if(first_tmp == last){
CLEAN_RXBUFS();
}
)
ATOMIC(first = (first + 1) % RADIO_RXBUFS;
int first_tmp = first; if(first_tmp == last) {
CLEAN_RXBUFS();}
)
#else
CLEAN_RXBUFS();
CLEAN_RXBUFS();
#endif
return len;
return len;
}
/*---------------------------------------------------------------------------*/
short last_packet_rssi(){
return last_rssi;
short
last_packet_rssi()
{
return last_rssi;
}
/** @} */

View file

@ -1,3 +1,9 @@
/**
* \addtogroup stm32w-cpu
*
* @{
*/
/*
* Copyright (c) 2007, Swedish Institute of Computer Science.
* All rights reserved.
@ -26,8 +32,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
/**
@ -45,14 +49,15 @@
#include "hal/hal.h"
#include "simplemac/include/phy-library.h"
int stm32w_radio_set_channel(uint8_t channel);
short last_packet_rssi();
#define STM32W_MAX_PACKET_LEN 127
extern const struct radio_driver stm32w_radio_driver;
int stm32w_radio_set_channel(uint8_t channel);
short last_packet_rssi();
int stm32w_radio_is_on(void);
#endif /* __STM32W_H__ */
/** @} */

View file

@ -0,0 +1,150 @@
/**
* \addtogroup stm32w-cpu
*
* @{
*/
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
* File Name : stm32w108_systick.c
* Author : MCD Application Team
* Version : V2.0.3
* Date : 09/22/2008
* Description : This file provides all the SysTick firmware functions.
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#include <stdint.h>
#include "stm32w-systick.h"
/* SysTick registers bit mask */
/* CTRL TICKINT Mask */
#define CTRL_TICKINT_Set ((uint32_t)0x00000002)
#define CTRL_TICKINT_Reset ((uint32_t)0xFFFFFFFD)
/*--------------------------------------------------------------------------*/
/**
* \brief Configures the SysTick clock source.
* \param SysTick_CLKSource specifies 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.
*/
void
SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
{
/* Check the parameters */
assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource));
if(SysTick_CLKSource == SysTick_CLKSource_HCLK) {
SysTick->CTRL |= SysTick_CLKSource_HCLK;
} else {
SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8;
}
}
/*--------------------------------------------------------------------------*/
/**
* \brief Sets SysTick Reload value.
* \param Reload SysTick Reload new value. Must be between 1 and 0xFFFFFF.
*/
void
SysTick_SetReload(uint32_t Reload)
{
/* Check the parameters */
assert_param(IS_SYSTICK_RELOAD(Reload));
SysTick->LOAD = Reload;
}
/*--------------------------------------------------------------------------*/
/**
* \brief Enables or disables the SysTick counter.
* \param SysTick_Counter new 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
*/
void
SysTick_CounterCmd(uint32_t SysTick_Counter)
{
/* Check the parameters */
assert_param(IS_SYSTICK_COUNTER(SysTick_Counter));
if(SysTick_Counter == SysTick_Counter_Enable) {
SysTick->CTRL |= SysTick_Counter_Enable;
} else if(SysTick_Counter == SysTick_Counter_Disable) {
SysTick->CTRL &= SysTick_Counter_Disable;
} else { /* SysTick_Counter == SysTick_Counter_Clear */
SysTick->VAL = SysTick_Counter_Clear;
}
}
/*--------------------------------------------------------------------------*/
/**
* \brief Enables or disables the SysTick Interrupt.
* \param NewState new state of the SysTick Interrupt.
* This parameter can be: ENABLE or DISABLE.
*/
void
SysTick_ITConfig(FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_FUNCTIONAL_STATE(NewState));
if(NewState != DISABLE) {
SysTick->CTRL |= CTRL_TICKINT_Set;
} else {
SysTick->CTRL &= CTRL_TICKINT_Reset;
}
}
/*--------------------------------------------------------------------------*/
/**
* \brief Gets SysTick counter value.
* \return SysTick current value
*/
uint32_t
SysTick_GetCounter(void)
{
return (SysTick->VAL);
}
/*--------------------------------------------------------------------------*/
/**
* \brief Checks whether the specified SysTick flag is set or not.
* \param SysTick_FLAG specifies the flag to check.
* This parameter can be one of the following values:
* - SysTick_FLAG_COUNT
* - SysTick_FLAG_SKEW
* - SysTick_FLAG_NOREF
*/
FlagStatus
SysTick_GetFlagStatus(uint8_t SysTick_FLAG)
{
uint32_t statusreg = 0, tmp = 0;
FlagStatus bitstatus = RESET;
/* Check the parameters */
assert_param(IS_SYSTICK_FLAG(SysTick_FLAG));
/* Get the SysTick register index */
tmp = SysTick_FLAG >> 3;
if(tmp == 2) { /* The flag to check is in CTRL register */
statusreg = SysTick->CTRL;
} else { /* The flag to check is in CALIB register */
statusreg = SysTick->CALIB;
}
if((statusreg & ((uint32_t) 1 << SysTick_FLAG)) != (uint32_t) RESET) {
bitstatus = SET;
} else {
bitstatus = RESET;
}
return bitstatus;
}
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
/** @} */

View file

@ -1,3 +1,9 @@
/**
* \addtogroup stm32w-cpu
*
* @{
*/
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
* File Name : stm32f10x_systick.h
* Author : MCD Application Team
@ -14,19 +20,17 @@
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32W_SYSTICK_H
#define __STM32W_SYSTICK_H
#include "stm32w108_type.h"
#include "stm32w_conf.h"
#include "stm32w108-type.h"
#include "stm32w-conf.h"
#ifndef EXT
#define EXT extern
#define EXT extern
#endif /* EXT */
typedef struct
{
typedef struct {
vu32 CTRL;
vu32 LOAD;
vu32 VAL;
@ -41,39 +45,47 @@ typedef struct
#define SCB_BASE (SCS_BASE + 0x0D00)
#ifdef _SysTick
#define SysTick ((SysTick_TypeDef *) SysTick_BASE)
#define SysTick ((SysTick_TypeDef *) SysTick_BASE)
#endif /*_SysTick */
/***************** Bit definition for SysTick_CTRL register *****************/
#define SysTick_CTRL_ENABLE ((u32)0x00000001) /* Counter enable */
#define SysTick_CTRL_TICKINT ((u32)0x00000002) /* Counting down to 0 pends the SysTick handler */
#define SysTick_CTRL_CLKSOURCE ((u32)0x00000004) /* Clock source */
#define SysTick_CTRL_COUNTFLAG ((u32)0x00010000) /* Count Flag */
/* Counter enable */
#define SysTick_CTRL_ENABLE ((u32)0x00000001)
/* Counting down to 0 pends the SysTick handler */
#define SysTick_CTRL_TICKINT ((u32)0x00000002)
/* Clock source */
#define SysTick_CTRL_CLKSOURCE ((u32)0x00000004)
/* Count Flag */
#define SysTick_CTRL_COUNTFLAG ((u32)0x00010000)
/***************** Bit definition for SysTick_LOAD register *****************/
#define SysTick_LOAD_RELOAD ((u32)0x00FFFFFF) /* Value to load into the SysTick Current Value Register when the counter reaches 0 */
/*
* Value to load into the SysTick Current Value Register when the
* counter reaches 0
*/
#define SysTick_LOAD_RELOAD ((u32)0x00FFFFFF)
/***************** Bit definition for SysTick_VAL register ******************/
#define SysTick_VAL_CURRENT ((u32)0x00FFFFFF) /* Current value at the time the register is accessed */
/* Current value at the time the register is accessed */
#define SysTick_VAL_CURRENT ((u32)0x00FFFFFF)
/***************** Bit definition for SysTick_CALIB register ****************/
#define SysTick_CALIB_TENMS ((u32)0x00FFFFFF) /* Reload value to use for 10ms timing */
#define SysTick_CALIB_SKEW ((u32)0x40000000) /* Calibration value is not exactly 10 ms */
#define SysTick_CALIB_NOREF ((u32)0x80000000) /* The reference clock is not provided */
/* Reload value to use for 10ms timing */
#define SysTick_CALIB_TENMS ((u32)0x00FFFFFF)
/* Calibration value is not exactly 10 ms */
#define SysTick_CALIB_SKEW ((u32)0x40000000)
/* The reference clock is not provided */
#define SysTick_CALIB_NOREF ((u32)0x80000000)
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* SysTick clock source */
#define SysTick_CLKSource_HCLK_Div8 ((u32)0xFFFFFFFB)
#define SysTick_CLKSource_HCLK ((u32)0x00000004)
#define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \
((SOURCE) == SysTick_CLKSource_HCLK_Div8))
((SOURCE) == SysTick_CLKSource_HCLK_Div8))
/* SysTick counter state */
#define SysTick_Counter_Disable ((u32)0xFFFFFFFE)
@ -95,15 +107,18 @@ typedef struct
#define IS_SYSTICK_RELOAD(RELOAD) (((RELOAD) > 0) && ((RELOAD) <= 0xFFFFFF))
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void SysTick_CLKSourceConfig(u32 SysTick_CLKSource);
void SysTick_SetReload(u32 Reload);
void SysTick_CounterCmd(u32 SysTick_Counter);
void SysTick_ITConfig(FunctionalState NewState);
u32 SysTick_GetCounter(void);
FlagStatus SysTick_GetFlagStatus(u8 SysTick_FLAG);
#endif /* __STM32F10x_SYSTICK_H */
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
/** @} */

View file

@ -1,174 +0,0 @@
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
* File Name : stm32w_conf.h
* Author : MCD Application Team
* Version : V2.0.3
* Date : 09/22/2008
* Description : Library configuration file.
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F10x_CONF_H
#define __STM32F10x_CONF_H
/* Includes ------------------------------------------------------------------*/
#include "stm32w108_type.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Uncomment the line below to compile the library in DEBUG mode, this will expanse
the "assert_param" macro in the firmware library code (see "Exported macro"
section below) */
/*#define DEBUG 1*/
/* Comment the line below to disable the specific peripheral inclusion */
/************************************* ADC ************************************/
//#define _ADC
//#define _ADC1
//#define _ADC2
//#define _ADC3
/************************************* BKP ************************************/
//#define _BKP
/************************************* CAN ************************************/
//#define _CAN
/************************************* CRC ************************************/
//#define _CRC
/************************************* DAC ************************************/
//#define _DAC
/************************************* DBGMCU *********************************/
//#define _DBGMCU
/************************************* DMA ************************************/
//#define _DMA
//#define _DMA1_Channel1
//#define _DMA1_Channel2
//#define _DMA1_Channel3
//#define _DMA1_Channel4
//#define _DMA1_Channel5
//#define _DMA1_Channel6
//#define _DMA1_Channel7
//#define _DMA2_Channel1
//#define _DMA2_Channel2
//#define _DMA2_Channel3
//#define _DMA2_Channel4
//#define _DMA2_Channel5
/************************************* EXTI ***********************************/
//#define _EXTI
/************************************* FLASH and Option Bytes *****************/
#define _FLASH
/* Uncomment the line below to enable FLASH program/erase/protections functions,
otherwise only FLASH configuration (latency, prefetch, half cycle) functions
are enabled */
/* #define _FLASH_PROG */
/************************************* FSMC ***********************************/
//#define _FSMC
/************************************* GPIO ***********************************/
#define _GPIO
//#define _GPIOA
//#define _GPIOB
#define _GPIOC
//#define _GPIOD
//#define _GPIOE
#define _GPIOF
//#define _GPIOG
#define _AFIO
/************************************* I2C ************************************/
//#define _I2C
//#define _I2C1
//#define _I2C2
/************************************* IWDG ***********************************/
//#define _IWDG
/************************************* NVIC ***********************************/
#define _NVIC
/************************************* PWR ************************************/
//#define _PWR
/************************************* RCC ************************************/
#define _RCC
/************************************* RTC ************************************/
//#define _RTC
/************************************* SDIO ***********************************/
//#define _SDIO
/************************************* SPI ************************************/
//#define _SPI
//#define _SPI1
//#define _SPI2
//#define _SPI3
/************************************* SysTick ********************************/
#define _SysTick
/************************************* TIM ************************************/
//#define _TIM
//#define _TIM1
//#define _TIM2
//#define _TIM3
//#define _TIM4
//#define _TIM5
//#define _TIM6
//#define _TIM7
//#define _TIM8
/************************************* USART **********************************/
//#define _USART
//#define _USART1
//#define _USART2
//#define _USART3
//#define _UART4
//#define _UART5
/************************************* WWDG ***********************************/
//#define _WWDG
/* In the following line adjust the value of External High Speed oscillator (HSE)
used in your application */
#define HSE_Value ((u32)8000000) /* Value of the External oscillator in Hz*/
/* In the following line adjust the External High Speed oscillator (HSE) Startup
Timeout value */
#define HSEStartUp_TimeOut ((u16)0x0500) /* Time out for HSE start up */
/* Exported macro ------------------------------------------------------------*/
#ifdef DEBUG
/*******************************************************************************
* Macro Name : assert_param
* Description : The assert_param macro is used for function's parameters check.
* It is used only if the library is compiled in DEBUG mode.
* Input : - expr: If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
* Return : None
*******************************************************************************/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((u8 *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(u8* file, u32 line);
#else
#define assert_param(expr) ((void)0)
#endif /* DEBUG */
#endif /* __STM32F10x_CONF_H */
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/

View file

@ -1,181 +0,0 @@
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
* File Name : stm32w108_systick.c
* Author : MCD Application Team
* Version : V2.0.3
* Date : 09/22/2008
* Description : This file provides all the SysTick firmware functions.
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include "stm32w_systick.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* ---------------------- SysTick registers bit mask -------------------- */
/* CTRL TICKINT Mask */
#define CTRL_TICKINT_Set ((u32)0x00000002)
#define CTRL_TICKINT_Reset ((u32)0xFFFFFFFD)
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/*******************************************************************************
* Function Name : SysTick_CLKSourceConfig
* Description : Configures the SysTick clock source.
* Input : - SysTick_CLKSource: specifies 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.
* Output : None
* Return : None
*******************************************************************************/
void SysTick_CLKSourceConfig(u32 SysTick_CLKSource)
{
/* Check the parameters */
assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource));
if (SysTick_CLKSource == SysTick_CLKSource_HCLK)
{
SysTick->CTRL |= SysTick_CLKSource_HCLK;
}
else
{
SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8;
}
}
/*******************************************************************************
* Function Name : SysTick_SetReload
* Description : Sets SysTick Reload value.
* Input : - Reload: SysTick Reload new value.
* This parameter must be a number between 1 and 0xFFFFFF.
* Output : None
* Return : None
*******************************************************************************/
void SysTick_SetReload(u32 Reload)
{
/* Check the parameters */
assert_param(IS_SYSTICK_RELOAD(Reload));
SysTick->LOAD = Reload;
}
/*******************************************************************************
* Function Name : SysTick_CounterCmd
* Description : Enables or disables the SysTick counter.
* Input : - SysTick_Counter: new 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
* Output : None
* Return : None
*******************************************************************************/
void SysTick_CounterCmd(u32 SysTick_Counter)
{
/* Check the parameters */
assert_param(IS_SYSTICK_COUNTER(SysTick_Counter));
if (SysTick_Counter == SysTick_Counter_Enable)
{
SysTick->CTRL |= SysTick_Counter_Enable;
}
else if (SysTick_Counter == SysTick_Counter_Disable)
{
SysTick->CTRL &= SysTick_Counter_Disable;
}
else /* SysTick_Counter == SysTick_Counter_Clear */
{
SysTick->VAL = SysTick_Counter_Clear;
}
}
/*******************************************************************************
* Function Name : SysTick_ITConfig
* Description : Enables or disables the SysTick Interrupt.
* Input : - NewState: new state of the SysTick Interrupt.
* This parameter can be: ENABLE or DISABLE.
* Output : None
* Return : None
*******************************************************************************/
void SysTick_ITConfig(FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
SysTick->CTRL |= CTRL_TICKINT_Set;
}
else
{
SysTick->CTRL &= CTRL_TICKINT_Reset;
}
}
/*******************************************************************************
* Function Name : SysTick_GetCounter
* Description : Gets SysTick counter value.
* Input : None
* Output : None
* Return : SysTick current value
*******************************************************************************/
u32 SysTick_GetCounter(void)
{
return(SysTick->VAL);
}
/*******************************************************************************
* Function Name : SysTick_GetFlagStatus
* Description : Checks whether the specified SysTick flag is set or not.
* Input : - SysTick_FLAG: specifies the flag to check.
* This parameter can be one of the following values:
* - SysTick_FLAG_COUNT
* - SysTick_FLAG_SKEW
* - SysTick_FLAG_NOREF
* Output : None
* Return : None
*******************************************************************************/
FlagStatus SysTick_GetFlagStatus(u8 SysTick_FLAG)
{
u32 statusreg = 0, tmp = 0 ;
FlagStatus bitstatus = RESET;
/* Check the parameters */
assert_param(IS_SYSTICK_FLAG(SysTick_FLAG));
/* Get the SysTick register index */
tmp = SysTick_FLAG >> 3;
if (tmp == 2) /* The flag to check is in CTRL register */
{
statusreg = SysTick->CTRL;
}
else /* The flag to check is in CALIB register */
{
statusreg = SysTick->CALIB;
}
if ((statusreg & ((u32)1 << SysTick_FLAG)) != (u32)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/

View file

@ -1,3 +1,39 @@
/**
* \addtogroup stm32w-cpu
*
* @{
*/
/*
* Copyright (c) 2010, STMicroelectronics.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <stdio.h>
#include "dev/uart1.h"
@ -5,7 +41,7 @@
#include PLATFORM_HEADER
#include "hal/micro/micro-common.h"
#include "hal/micro/cortexm3/micro-common.h"
//#include "uart.h"
/* #include "uart.h" */
#ifdef __GNUC__
# define _LLIO_STDIN ((int) stdin)
@ -19,38 +55,40 @@
#endif
#undef putchar
int __attribute__(( weak )) putchar(int c)
/*--------------------------------------------------------------------------*/
int
__attribute__ ((weak)) putchar(int c)
{
uart1_writeb(c);
return c;
}
void __io_putchar(char c)
/*--------------------------------------------------------------------------*/
void
__io_putchar(char c)
{
putchar(c);
}
size_t _write(int handle, const unsigned char * buffer, size_t size)
/*--------------------------------------------------------------------------*/
size_t
_write(int handle, const unsigned char *buffer, size_t size)
{
size_t nChars = 0;
if (handle != _LLIO_STDOUT && handle != _LLIO_STDERR) {
if(handle != _LLIO_STDOUT && handle != _LLIO_STDERR) {
return _LLIO_ERROR;
}
if (buffer == 0) {
// This means that we should flush internal buffers.
//spin until TX complete (TX is idle)
while ((SC1_UARTSTAT&SC_UARTTXIDLE)!=SC_UARTTXIDLE) {}
if(buffer == 0) {
/* This means that we should flush internal buffers. */
/* spin until TX complete (TX is idle) */
while((SC1_UARTSTAT & SC_UARTTXIDLE) != SC_UARTTXIDLE) {
}
return 0;
}
// ensure port is configured for UART
/* ensure port is configured for UART */
if(SC1_MODE != SC1_MODE_UART) {
return _LLIO_ERROR;
}
while(size--) {
__io_putchar(*buffer++);
++nChars;
@ -59,9 +97,10 @@ size_t _write(int handle, const unsigned char * buffer, size_t size)
return nChars;
}
size_t _read(int handle, unsigned char * buffer, size_t size)
/*--------------------------------------------------------------------------*/
size_t
_read(int handle, unsigned char *buffer, size_t size)
{
return 0;
return 0;
}
/** @} */

View file

@ -1,3 +1,9 @@
/**
* \addtogroup stm32w-cpu
*
* @{
*/
/*
* Copyright (c) 2010, STMicroelectronics.
* All rights reserved.
@ -27,10 +33,9 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the Contiki OS
*
*/
/*---------------------------------------------------------------------------*/
/**
* \file
* Machine dependent STM32W UART1 code.
@ -41,53 +46,42 @@
* \since
* 03.04.2010
*/
/*---------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
//#include <io.h>
//#include <signal.h>
#include "sys/energest.h"
#include "dev/uart1.h"
#include "dev/watchdog.h"
#include "lib/ringbuf.h"
#include "dev/leds.h"
static int (*uart1_input_handler)(unsigned char c);
static int (*uart1_input_handler) (unsigned char c);
void uart1_rx_interrupt(void);
void uart1_tx_interrupt(void);
static volatile uint8_t transmitting;
#ifdef UART1_CONF_TX_WITH_INTERRUPT
#define TX_WITH_INTERRUPT UART1_CONF_TX_WITH_INTERRUPT
#else /* UART1_CONF_TX_WITH_INTERRUPT */
#define TX_WITH_INTERRUPT 1
#define TX_WITH_INTERRUPT 1
#endif /* UART1_CONF_TX_WITH_INTERRUPT */
#if TX_WITH_INTERRUPT
#ifdef UART1_CONF_TX_BUFSIZE
#define UART1_TX_BUFSIZE UART1_CONF_TX_BUFSIZE
#else /* UART1_CONF_TX_BUFSIZE */
#define UART1_TX_BUFSIZE 64
#endif /* UART1_CONF_TX_BUFSIZE */
static struct ringbuf txbuf;
static uint8_t txbuf_data[UART1_TX_BUFSIZE];
#endif /* TX_WITH_INTERRUPT */
/*---------------------------------------------------------------------------*/
//uint8_t
//uart1_active(void)
//{
// return ((~ UTCTL1) & TXEPT) | transmitting;
//}
/*---------------------------------------------------------------------------*/
void
uart1_set_input(int (*input)(unsigned char c))
uart1_set_input(int (*input) (unsigned char c))
{
uart1_input_handler = input;
}
@ -97,21 +91,23 @@ uart1_writeb(unsigned char c)
{
watchdog_periodic();
#if TX_WITH_INTERRUPT
/* Put the outgoing byte on the transmission buffer. If the buffer
is full, we just keep on trying to put the byte into the buffer
until it is possible to put it there. */
/*
* Put the outgoing byte on the transmission buffer. If the buffer
* is full, we just keep on trying to put the byte into the buffer
* until it is possible to put it there.
*/
while(ringbuf_put(&txbuf, c) == 0);
/* If there is no transmission going, we need to start it by putting
the first byte into the UART. */
/*
* If there is no transmission going, we need to start it by putting
* the first byte into the UART.
*/
if(transmitting == 0) {
transmitting = 1;
transmitting = 1;
SC1_DATA = ringbuf_get(&txbuf);
INT_SC1FLAG = INT_SCTXFREE;
INT_SC1CFG |= INT_SCTXFREE;
}
#else /* TX_WITH_INTERRUPT */
/* Loop until the transmission buffer is available. */
@ -119,107 +115,97 @@ uart1_writeb(unsigned char c)
/* Transmit the data. */
SC1_DATA = c;
INT_SC1FLAG = INT_SCTXFREE;
#endif /* TX_WITH_INTERRUPT */
}
/*---------------------------------------------------------------------------*/
#if ! WITH_UIP /* If WITH_UIP is defined, putchar() is defined by the SLIP driver */
#if ! WITH_UIP
/* If WITH_UIP is defined, putchar() is defined by the SLIP driver */
#endif /* ! WITH_UIP */
/*---------------------------------------------------------------------------*/
/**
/*
* Initalize the RS232 port.
*
*/
void
uart1_init(unsigned long ubr)
{
GPIO_PBCFGL &= 0xF00F;
GPIO_PBCFGL |= 0x0490;
uint16_t uartper = (uint32_t)24e6/(2*ubr);
uint32_t rest = (uint32_t)24e6%(2*ubr);
SC1_UARTFRAC = 0;
if(rest > (2*ubr)/4 && rest < (3*2*ubr)/4){
SC1_UARTFRAC = 1; // + 0.5
}
else if(rest >= (3*2*ubr)/4){
uartper++; // + 1
}
SC1_UARTPER = uartper;
SC1_UARTCFG = SC_UART8BIT;
SC1_MODE = SC1_MODE_UART;
SC1_INTMODE = SC_RXVALLEVEL | SC_TXFREELEVEL; // Receive buffer has data interrupt mode and Transmit buffer free interrupt mode: Level triggered.
INT_SC1CFG = INT_SCRXVAL; // Receive buffer has data interrupt enable
uint16_t uartper;
uint32_t rest;
GPIO_PBCFGL &= 0xF00F;
GPIO_PBCFGL |= 0x0490;
uartper = (uint32_t) 24e6 / (2 * ubr);
rest = (uint32_t) 24e6 % (2 * ubr);
SC1_UARTFRAC = 0;
if(rest > (2 * ubr) / 4 && rest < (3 * 2 * ubr) / 4) {
SC1_UARTFRAC = 1; /* + 0.5 */
} else if(rest >= (3 * 2 * ubr) / 4) {
uartper++; /* + 1 */
}
SC1_UARTPER = uartper;
SC1_UARTCFG = SC_UART8BIT;
SC1_MODE = SC1_MODE_UART;
/*
* Receive buffer has data interrupt mode and Transmit buffer free interrupt
* mode: Level triggered.
*/
SC1_INTMODE = SC_RXVALLEVEL | SC_TXFREELEVEL;
INT_SC1CFG = INT_SCRXVAL; /* Receive buffer has data interrupt enable */
transmitting = 0;
#if TX_WITH_INTERRUPT
ringbuf_init(&txbuf, txbuf_data, sizeof(txbuf_data));
#endif /* TX_WITH_INTERRUPT */
ringbuf_init(&txbuf, txbuf_data, sizeof(txbuf_data));
#endif /* TX_WITH_INTERRUPT */
INT_SC1FLAG = 0xFFFF;
INT_CFGSET = INT_SC1;
}
/*---------------------------------------------------------------------------*/
void uart1_rx_interrupt(void);
void uart1_tx_interrupt(void);
void halSc1Isr(void)
void
halSc1Isr(void)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);
if(INT_SC1FLAG & INT_SCRXVAL){
if(INT_SC1FLAG & INT_SCRXVAL) {
uart1_rx_interrupt();
INT_SC1FLAG = INT_SCRXVAL;
INT_SC1FLAG = INT_SCRXVAL;
}
#if TX_WITH_INTERRUPT
else if(INT_SC1FLAG & INT_SCTXFREE){
#if TX_WITH_INTERRUPT
else if(INT_SC1FLAG & INT_SCTXFREE) {
uart1_tx_interrupt();
INT_SC1FLAG = INT_SCTXFREE;
}
#endif /* TX_WITH_INTERRUPT */
}
#endif /* TX_WITH_INTERRUPT */
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
}
void uart1_rx_interrupt(void)
/*--------------------------------------------------------------------------*/
void
uart1_rx_interrupt(void)
{
uint8_t c;
uint8_t c;
c = SC1_DATA;
if(uart1_input_handler != NULL) {
uart1_input_handler(c);
}
}
}
/*---------------------------------------------------------------------------*/
#if TX_WITH_INTERRUPT
void uart1_tx_interrupt(void)
void
uart1_tx_interrupt(void)
{
if(ringbuf_elements(&txbuf) == 0) {
transmitting = 0;
INT_SC1CFG &= ~INT_SCTXFREE;
} else {
SC1_DATA = ringbuf_get(&txbuf);
}
}
#endif /* TX_WITH_INTERRUPT */
/*---------------------------------------------------------------------------*/
/** @} */

View file

@ -1,3 +1,9 @@
/**
* \addtogroup stm32w-cpu
*
* @{
*/
/*
* Copyright (c) 2007, Swedish Institute of Computer Science.
* All rights reserved.
@ -26,8 +32,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
/**
@ -42,9 +46,13 @@
#define BAUD2UBR(baud) baud
void uart1_set_input(int (*input)(unsigned char c));
void uart1_set_input(int (*input) (unsigned char c));
void uart1_writeb(unsigned char c);
void uart1_init(unsigned long ubr);
//uint8_t uart1_active(void);
/* uint8_t uart1_active(void); */
#endif /* __UART1_H__ */
/** @} */