License headers and code style fixes.
This commit is contained in:
parent
875bfd0a1a
commit
fc65757114
|
@ -25,7 +25,7 @@ CONTIKI_CPU_ARCH= watchdog.c \
|
||||||
clock.c
|
clock.c
|
||||||
|
|
||||||
ifdef GCC
|
ifdef GCC
|
||||||
CONTIKI_CPU_PORT= sysmem.c \
|
CONTIKI_CPU_PORT= syscalls.c \
|
||||||
console.c \
|
console.c \
|
||||||
crt.c \
|
crt.c \
|
||||||
uart.c
|
uart.c
|
||||||
|
|
|
@ -1,102 +1,109 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, STMicroelectronics.
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#include "platform-conf.h"
|
#include "platform-conf.h"
|
||||||
#include "contiki-conf.h"
|
#include "contiki-conf.h"
|
||||||
#include "dev/leds.h"
|
#include "dev/leds.h"
|
||||||
#include "stm32l1xx.h"
|
#include "stm32l1xx.h"
|
||||||
#include "stm32l1xx_hal_rcc.h"
|
#include "stm32l1xx_hal_rcc.h"
|
||||||
#include "stm32l1xx_hal_cortex.h"
|
#include "stm32l1xx_hal_cortex.h"
|
||||||
#include "stm32l1xx_hal.h"
|
#include "stm32l1xx_hal.h"
|
||||||
#include "st-lib.h"
|
#include "st-lib.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#define RELOAD_VALUE ((F_CPU/CLOCK_CONF_SECOND) - 1)
|
#define RELOAD_VALUE ((F_CPU / CLOCK_CONF_SECOND) - 1)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static volatile unsigned long seconds = 0;
|
static volatile unsigned long seconds = 0;
|
||||||
static volatile clock_time_t ticks;
|
static volatile clock_time_t ticks;
|
||||||
void st_lib_sys_tick_handler(void);
|
void st_lib_sys_tick_handler(void);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void st_lib_sys_tick_handler(void)
|
void
|
||||||
{
|
st_lib_sys_tick_handler(void)
|
||||||
ticks++;
|
{
|
||||||
if((ticks % CLOCK_SECOND) == 0) {
|
ticks++;
|
||||||
seconds++;
|
if((ticks % CLOCK_SECOND) == 0) {
|
||||||
energest_flush();
|
seconds++;
|
||||||
}
|
energest_flush();
|
||||||
HAL_IncTick();
|
}
|
||||||
|
HAL_IncTick();
|
||||||
if(etimer_pending()) {
|
|
||||||
etimer_request_poll();
|
if(etimer_pending()) {
|
||||||
}
|
etimer_request_poll();
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
}
|
||||||
void clock_init(void)
|
/*---------------------------------------------------------------------------*/
|
||||||
{
|
void
|
||||||
ticks = 0;
|
clock_init(void)
|
||||||
st_lib_hal_systick_clk_source_config(SYSTICK_CLKSOURCE_HCLK);
|
{
|
||||||
st_lib_hal_systick_config(RELOAD_VALUE);
|
ticks = 0;
|
||||||
}
|
st_lib_hal_systick_clk_source_config(SYSTICK_CLKSOURCE_HCLK);
|
||||||
/*---------------------------------------------------------------------------*/
|
st_lib_hal_systick_config(RELOAD_VALUE);
|
||||||
unsigned long clock_seconds(void)
|
}
|
||||||
{
|
/*---------------------------------------------------------------------------*/
|
||||||
return seconds;
|
unsigned long
|
||||||
}
|
clock_seconds(void)
|
||||||
/*---------------------------------------------------------------------------*/
|
{
|
||||||
void clock_set_seconds(unsigned long sec)
|
return seconds;
|
||||||
{
|
}
|
||||||
seconds = sec;
|
/*---------------------------------------------------------------------------*/
|
||||||
}
|
void
|
||||||
/*---------------------------------------------------------------------------*/
|
clock_set_seconds(unsigned long sec)
|
||||||
clock_time_t clock_time(void)
|
{
|
||||||
{
|
seconds = sec;
|
||||||
return ticks;
|
}
|
||||||
}
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
clock_time_t
|
||||||
void clock_delay(unsigned int i)
|
clock_time(void)
|
||||||
{
|
{
|
||||||
for(; i > 0; i--) {
|
return ticks;
|
||||||
unsigned int j;
|
}
|
||||||
for(j = 50; j > 0; j--) {
|
/*---------------------------------------------------------------------------*/
|
||||||
asm ("nop");
|
void
|
||||||
}
|
clock_delay(unsigned int i)
|
||||||
}
|
{
|
||||||
}
|
for(; i > 0; i--) {
|
||||||
/*---------------------------------------------------------------------------*/
|
unsigned int j;
|
||||||
/* Wait for a multiple of clock ticks (7.8 ms at 128 Hz). */
|
for(j = 50; j > 0; j--) {
|
||||||
void clock_wait(clock_time_t t)
|
asm ("nop");
|
||||||
{
|
}
|
||||||
clock_time_t start;
|
}
|
||||||
start = clock_time();
|
}
|
||||||
while(clock_time() - start < (clock_time_t)t);
|
/*---------------------------------------------------------------------------*/
|
||||||
}
|
/* Wait for a multiple of clock ticks (7.8 ms at 128 Hz). */
|
||||||
/*---------------------------------------------------------------------------*/
|
void
|
||||||
|
clock_wait(clock_time_t t)
|
||||||
|
{
|
||||||
|
clock_time_t start;
|
||||||
|
start = clock_time();
|
||||||
|
while(clock_time() - start < (clock_time_t)t) ;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,189 +1,189 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file console.c
|
* All rights reserved.
|
||||||
* @author AST
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 26-Aug-2014
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief This file provides implementation of standard input/output
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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
|
#include <stdio.h>
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
#include <stdlib.h>
|
||||||
*
|
#include "console.h"
|
||||||
******************************************************************************
|
#include "stm32l1xx.h"
|
||||||
*/
|
#include "stm32l1xx_hal_dma.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
#include "stm32l1xx_hal_uart.h"
|
||||||
#include <stdio.h>
|
#include "st-lib.h"
|
||||||
#include <stdlib.h>
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "console.h"
|
extern st_lib_uart_handle_typedef st_lib_uart_handle;
|
||||||
#include "stm32l1xx.h"
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "stm32l1xx_hal_dma.h"
|
/**
|
||||||
#include "stm32l1xx_hal_uart.h"
|
* @brief Initialises Nucleo UART port for user IO
|
||||||
#include "st-lib.h"
|
* @retval 0
|
||||||
/*---------------------------------------------------------------------------*/
|
*/
|
||||||
extern st_lib_uart_handle_typedef st_lib_uart_handle;
|
int
|
||||||
/*---------------------------------------------------------------------------*/
|
console_init(void)
|
||||||
/**
|
{
|
||||||
* @brief Initialises Nucleo UART port for user IO
|
st_lib_uart_handle.Instance = USART2;
|
||||||
* @retval 0
|
|
||||||
*/
|
st_lib_uart_handle.Init.BaudRate = 115200;
|
||||||
int console_init(void)
|
st_lib_uart_handle.Init.WordLength = UART_WORDLENGTH_8B;
|
||||||
{
|
st_lib_uart_handle.Init.StopBits = UART_STOPBITS_1;
|
||||||
st_lib_uart_handle.Instance = USART2;
|
st_lib_uart_handle.Init.Parity = UART_PARITY_NONE;
|
||||||
|
st_lib_uart_handle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||||
st_lib_uart_handle.Init.BaudRate = 115200;
|
st_lib_uart_handle.Init.Mode = UART_MODE_TX_RX;
|
||||||
st_lib_uart_handle.Init.WordLength = UART_WORDLENGTH_8B;
|
|
||||||
st_lib_uart_handle.Init.StopBits = UART_STOPBITS_1;
|
st_lib_hal_uart_init(&st_lib_uart_handle);
|
||||||
st_lib_uart_handle.Init.Parity = UART_PARITY_NONE;
|
|
||||||
st_lib_uart_handle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
return 0;
|
||||||
st_lib_uart_handle.Init.Mode = UART_MODE_TX_RX;
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
st_lib_hal_uart_init(&st_lib_uart_handle);
|
/** @brief Sends a character to serial port
|
||||||
|
* @param ch Character to send
|
||||||
return 0;
|
* @retval Character sent
|
||||||
}
|
*/
|
||||||
/*---------------------------------------------------------------------------*/
|
int
|
||||||
/** @brief Sends a character to serial port
|
uart_send_char(int ch)
|
||||||
* @param ch Character to send
|
{
|
||||||
* @retval Character sent
|
st_lib_hal_uart_transmit(&st_lib_uart_handle, (uint8_t *)&ch, 1, HAL_MAX_DELAY);
|
||||||
*/
|
return ch;
|
||||||
int uart_send_char(int ch)
|
}
|
||||||
{
|
/*---------------------------------------------------------------------------*/
|
||||||
st_lib_hal_uart_transmit(&st_lib_uart_handle, (uint8_t *)&ch, 1, HAL_MAX_DELAY);
|
/** @brief Receives a character from serial port
|
||||||
return ch;
|
* @retval Character received
|
||||||
}
|
*/
|
||||||
/*---------------------------------------------------------------------------*/
|
int
|
||||||
/** @brief Receives a character from serial port
|
uart_receive_char(void)
|
||||||
* @retval Character received
|
{
|
||||||
*/
|
uint8_t ch;
|
||||||
int uart_receive_char(void)
|
st_lib_hal_uart_receive(&st_lib_uart_handle, &ch, 1, HAL_MAX_DELAY);
|
||||||
{
|
|
||||||
uint8_t ch;
|
/* Echo character back to console */
|
||||||
st_lib_hal_uart_receive(&st_lib_uart_handle, &ch, 1, HAL_MAX_DELAY);
|
st_lib_hal_uart_transmit(&st_lib_uart_handle, &ch, 1, HAL_MAX_DELAY);
|
||||||
|
|
||||||
/* Echo character back to console */
|
/* And cope with Windows */
|
||||||
st_lib_hal_uart_transmit(&st_lib_uart_handle, &ch, 1, HAL_MAX_DELAY);
|
if(ch == '\r') {
|
||||||
|
uint8_t ret = '\n';
|
||||||
/* And cope with Windows */
|
st_lib_hal_uart_transmit(&st_lib_uart_handle, &ret, 1, HAL_MAX_DELAY);
|
||||||
if(ch == '\r'){
|
}
|
||||||
uint8_t ret = '\n';
|
|
||||||
st_lib_hal_uart_transmit(&st_lib_uart_handle, &ret, 1, HAL_MAX_DELAY);
|
return ch;
|
||||||
}
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
return ch;
|
#if defined(__IAR_SYSTEMS_ICC__)
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
size_t __write(int Handle, const unsigned char *Buf, size_t Bufsize);
|
||||||
#if defined (__IAR_SYSTEMS_ICC__)
|
size_t __read(int Handle, unsigned char *Buf, size_t Bufsize);
|
||||||
|
|
||||||
size_t __write(int Handle, const unsigned char * Buf, size_t Bufsize);
|
/** @brief IAR specific low level standard input
|
||||||
size_t __read(int Handle, unsigned char *Buf, size_t Bufsize);
|
* @param handle IAR internal handle
|
||||||
|
* @param buf Buffer where to store characters read from stdin
|
||||||
/** @brief IAR specific low level standard input
|
* @param bufsize Number of characters to read
|
||||||
* @param handle IAR internal handle
|
* @retval Number of characters read
|
||||||
* @param buf Buffer where to store characters read from stdin
|
*/
|
||||||
* @param bufsize Number of characters to read
|
size_t
|
||||||
* @retval Number of characters read
|
__read(int handle, unsigned char *buf, size_t bufsize)
|
||||||
*/
|
{
|
||||||
size_t __read(int handle, unsigned char *buf, size_t bufsize)
|
int i;
|
||||||
{
|
|
||||||
int i;
|
if(handle != 0) {
|
||||||
|
return -1;
|
||||||
if (handle != 0){
|
}
|
||||||
return -1;
|
|
||||||
}
|
for(i = 0; i < bufsize; i++) {
|
||||||
|
buf[i] = uart_receive_char();
|
||||||
for(i=0; i<bufsize; i++) {
|
}
|
||||||
buf[i] = uart_receive_char();
|
|
||||||
}
|
return bufsize;
|
||||||
|
}
|
||||||
return bufsize;
|
/** @brief IAR specific low level standard output
|
||||||
}
|
* @param handle IAR internal handle
|
||||||
|
* @param buf Buffer containing characters to be written to stdout
|
||||||
/** @brief IAR specific low level standard output
|
* @param bufsize Number of characters to write
|
||||||
* @param handle IAR internal handle
|
* @retval Number of characters read
|
||||||
* @param buf Buffer containing characters to be written to stdout
|
*/
|
||||||
* @param bufsize Number of characters to write
|
size_t
|
||||||
* @retval Number of characters read
|
__write(int handle, const unsigned char *buf, size_t bufsize)
|
||||||
*/
|
{
|
||||||
size_t __write(int handle, const unsigned char * buf, size_t bufsize)
|
int i;
|
||||||
{
|
|
||||||
int i;
|
if(handle != 1 && handle != 2) {
|
||||||
|
return -1;
|
||||||
if (handle != 1 && handle != 2) {
|
}
|
||||||
return -1;
|
|
||||||
}
|
for(i = 0; i < bufsize; i++) {
|
||||||
|
uart_send_char(buf[i]);
|
||||||
for(i=0; i< bufsize; i++) {
|
}
|
||||||
uart_send_char(buf[i]);
|
|
||||||
}
|
return bufsize;
|
||||||
|
}
|
||||||
return bufsize;
|
/*---------------------------------------------------------------------------*/
|
||||||
}
|
#elif defined(__CC_ARM)
|
||||||
/*---------------------------------------------------------------------------*/
|
/**
|
||||||
#elif defined (__CC_ARM)
|
* @brief fputc call for standard output implementation
|
||||||
/**
|
* @param ch Character to print
|
||||||
* @brief fputc call for standard output implementation
|
* @param f File pointer
|
||||||
* @param ch Character to print
|
* @retval Character printed
|
||||||
* @param f File pointer
|
*/
|
||||||
* @retval Character printed
|
int
|
||||||
*/
|
fputc(int ch, FILE *f)
|
||||||
int fputc(int ch, FILE *f)
|
{
|
||||||
{
|
return uart_send_char(ch);
|
||||||
return uart_send_char(ch);
|
}
|
||||||
}
|
/** @brief fgetc call for standard input implementation
|
||||||
|
* @param f File pointer
|
||||||
/** @brief fgetc call for standard input implementation
|
* @retval Character acquired from standard input
|
||||||
* @param f File pointer
|
*/
|
||||||
* @retval Character acquired from standard input
|
int
|
||||||
*/
|
fgetc(FILE *f)
|
||||||
int fgetc(FILE *f)
|
{
|
||||||
{
|
return uart_receive_char();
|
||||||
return uart_receive_char();
|
}
|
||||||
}
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
#elif defined(__GNUC__)
|
||||||
#elif defined (__GNUC__)
|
|
||||||
|
/** @brief putchar call for standard output implementation
|
||||||
/** @brief putchar call for standard output implementation
|
* @param ch Character to print
|
||||||
* @param ch Character to print
|
* @retval Character printed
|
||||||
* @retval Character printed
|
*/
|
||||||
*/
|
int
|
||||||
int __io_putchar(int ch)
|
__io_putchar(int ch)
|
||||||
{
|
{
|
||||||
return uart_send_char(ch);
|
return uart_send_char(ch);
|
||||||
}
|
}
|
||||||
|
/** @brief getchar call for standard input implementation
|
||||||
/** @brief getchar call for standard input implementation
|
* @param None
|
||||||
* @param None
|
* @retval Character acquired from standard input
|
||||||
* @retval Character acquired from standard input
|
*/
|
||||||
*/
|
int
|
||||||
int __io_getchar(void)
|
__io_getchar(void)
|
||||||
{
|
{
|
||||||
return uart_receive_char();
|
return uart_receive_char();
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#else
|
#else
|
||||||
#error "Toolchain not supported"
|
#error "Toolchain not supported"
|
||||||
#endif
|
#endif
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,45 +1,39 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file console.h
|
* All rights reserved.
|
||||||
* @author AST
|
|
||||||
* @version V1.0.0
|
|
||||||
* @date 26-Aug-2014
|
|
||||||
* @brief This file provides implementation of standard input/output
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
*
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* 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.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* are permitted provided that the following conditions are met:
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* this list of conditions and the following disclaimer.
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* 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 STMicroelectronics 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
*
|
*
|
||||||
******************************************************************************
|
|
||||||
*/
|
*/
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#if defined (__IAR_SYSTEMS_ICC__)
|
#if defined(__IAR_SYSTEMS_ICC__)
|
||||||
size_t __write(int handle, const unsigned char * buf, size_t bufsize);
|
size_t __write(int handle, const unsigned char *buf, size_t bufsize);
|
||||||
size_t __read(int handle, unsigned char *buf, size_t bufsize);
|
size_t __read(int handle, unsigned char *buf, size_t bufsize);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#elif defined (__CC_ARM)
|
#elif defined(__CC_ARM)
|
||||||
/**
|
/**
|
||||||
* @brief fputc call for standard output implementation
|
* @brief fputc call for standard output implementation
|
||||||
* @param ch Character to print
|
* @param ch Character to print
|
||||||
|
@ -54,7 +48,7 @@ int fputc(int ch, FILE *f);
|
||||||
*/
|
*/
|
||||||
int fgetc(FILE *f);
|
int fgetc(FILE *f);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#elif defined (__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
/** @brief putchar call for standard output implementation
|
/** @brief putchar call for standard output implementation
|
||||||
* @param ch Character to print
|
* @param ch Character to print
|
||||||
* @retval Character printed
|
* @retval Character printed
|
||||||
|
|
|
@ -1,84 +1,86 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file main.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief source file
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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 <stdio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int _lseek (int file,
|
int
|
||||||
int ptr,
|
_lseek(int file,
|
||||||
int dir)
|
int ptr,
|
||||||
|
int dir)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int _close (int file)
|
int
|
||||||
|
_close(int file)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void _exit (int n)
|
void
|
||||||
|
_exit(int n)
|
||||||
{
|
{
|
||||||
/* FIXME: return code is thrown away. */
|
/* FIXME: return code is thrown away. */
|
||||||
while(1);
|
while(1) ;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int _kill (int n, int m)
|
int
|
||||||
|
_kill(int n, int m)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int _fstat(int file, struct stat *st)
|
int
|
||||||
|
_fstat(int file, struct stat *st)
|
||||||
{
|
{
|
||||||
st->st_mode = S_IFCHR;
|
st->st_mode = S_IFCHR;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int _isatty (int fd)
|
int
|
||||||
|
_isatty(int fd)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
fd = fd;
|
fd = fd;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int _getpid (int n)
|
int
|
||||||
{
|
_getpid(int n)
|
||||||
return -1;
|
{
|
||||||
}
|
return -1;
|
||||||
/*---------------------------------------------------------------------------*/
|
}
|
||||||
int _open (const char * path, int flags, ...)
|
/*---------------------------------------------------------------------------*/
|
||||||
|
int
|
||||||
|
_open(const char *path, int flags, ...)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,47 +1,42 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file console.c
|
* All rights reserved.
|
||||||
* @author AST
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 26-Aug-2014
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief This file provides implementation of standard input/output
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
* Implementation of multithreading in ARM Cortex-M3. To be done.
|
||||||
*
|
*/
|
||||||
******************************************************************************
|
#ifndef __MTARCH_H__
|
||||||
*/
|
#define __MTARCH_H__
|
||||||
/*
|
/*---------------------------------------------------------------------------*/
|
||||||
* Implementation of multithreading in ARM Cortex-M3. To be done.
|
struct mtarch_thread {
|
||||||
*/
|
short mt_thread;
|
||||||
#ifndef __MTARCH_H__
|
};
|
||||||
#define __MTARCH_H__
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
#endif /* __MTARCH_H__ */
|
||||||
struct mtarch_thread {
|
|
||||||
short mt_thread;
|
|
||||||
};
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
#endif /* __MTARCH_H__ */
|
|
||||||
|
|
17160
cpu/arm/stm32l152/regs.h
17160
cpu/arm/stm32l152/regs.h
File diff suppressed because it is too large
Load diff
|
@ -1,104 +1,105 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, STMicroelectronics.
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#include "platform-conf.h"
|
#include "platform-conf.h"
|
||||||
|
|
||||||
#include "sys/rtimer.h"
|
#include "sys/rtimer.h"
|
||||||
#include "sys/process.h"
|
#include "sys/process.h"
|
||||||
#include "dev/watchdog.h"
|
#include "dev/watchdog.h"
|
||||||
|
|
||||||
#include "stm32l1xx.h"
|
#include "stm32l1xx.h"
|
||||||
#include "stm32l1xx_hal_gpio.h"
|
#include "stm32l1xx_hal_gpio.h"
|
||||||
#include "stm32l1xx_hal_rcc.h"
|
#include "stm32l1xx_hal_rcc.h"
|
||||||
#include "stm32l1xx_hal_tim.h"
|
#include "stm32l1xx_hal_tim.h"
|
||||||
#include "stm32l1xx_hal_cortex.h"
|
#include "stm32l1xx_hal_cortex.h"
|
||||||
#include "st-lib.h"
|
#include "st-lib.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
volatile uint32_t rtimer_clock = 0uL;
|
volatile uint32_t rtimer_clock = 0uL;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
st_lib_tim_handle_typedef htim2;
|
st_lib_tim_handle_typedef htim2;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void st_lib_tim2_irq_handler(void)
|
void
|
||||||
{
|
st_lib_tim2_irq_handler(void)
|
||||||
/* clear interrupt pending flag */
|
{
|
||||||
st_lib_hal_tim_clear_it(&htim2, TIM_IT_UPDATE);
|
/* clear interrupt pending flag */
|
||||||
|
st_lib_hal_tim_clear_it(&htim2, TIM_IT_UPDATE);
|
||||||
rtimer_clock++;
|
|
||||||
}
|
rtimer_clock++;
|
||||||
/*---------------------------------------------------------------------------*/
|
}
|
||||||
void rtimer_arch_init(void)
|
/*---------------------------------------------------------------------------*/
|
||||||
{
|
void
|
||||||
st_lib_tim_clock_config_typedef s_clock_source_config;
|
rtimer_arch_init(void)
|
||||||
st_lib_tim_oc_init_typedef s_config_oc;
|
{
|
||||||
|
st_lib_tim_clock_config_typedef s_clock_source_config;
|
||||||
st_lib_tim2_clk_enable();
|
st_lib_tim_oc_init_typedef s_config_oc;
|
||||||
htim2.Instance = TIM2;
|
|
||||||
htim2.Init.Prescaler = PRESCALER;
|
st_lib_tim2_clk_enable();
|
||||||
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
|
htim2.Instance = TIM2;
|
||||||
htim2.Init.Period = 1;
|
htim2.Init.Prescaler = PRESCALER;
|
||||||
|
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
st_lib_hal_tim_base_init(&htim2);
|
htim2.Init.Period = 1;
|
||||||
st_lib_hal_tim_base_start_it(&htim2);
|
|
||||||
|
st_lib_hal_tim_base_init(&htim2);
|
||||||
s_clock_source_config.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
st_lib_hal_tim_base_start_it(&htim2);
|
||||||
st_lib_hal_tim_config_clock_source(&htim2, &s_clock_source_config);
|
|
||||||
|
s_clock_source_config.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||||
st_lib_hal_tim_oc_init(&htim2);
|
st_lib_hal_tim_config_clock_source(&htim2, &s_clock_source_config);
|
||||||
|
|
||||||
s_config_oc.OCMode = TIM_OCMODE_TIMING;
|
st_lib_hal_tim_oc_init(&htim2);
|
||||||
s_config_oc.Pulse = 0;
|
|
||||||
s_config_oc.OCPolarity = TIM_OCPOLARITY_HIGH;
|
s_config_oc.OCMode = TIM_OCMODE_TIMING;
|
||||||
st_lib_hal_tim_oc_config_channel(&htim2, &s_config_oc, TIM_CHANNEL_1);
|
s_config_oc.Pulse = 0;
|
||||||
|
s_config_oc.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||||
|
st_lib_hal_tim_oc_config_channel(&htim2, &s_config_oc, TIM_CHANNEL_1);
|
||||||
st_lib_hal_tim_clear_flag(&htim2, TIM_FLAG_UPDATE);
|
|
||||||
|
st_lib_hal_tim_clear_flag(&htim2, TIM_FLAG_UPDATE);
|
||||||
/* Enable TIM2 Update interrupt */
|
|
||||||
st_lib_hal_tim_enable_it(&htim2, TIM_IT_UPDATE);
|
/* Enable TIM2 Update interrupt */
|
||||||
|
st_lib_hal_tim_enable_it(&htim2, TIM_IT_UPDATE);
|
||||||
st_lib_hal_tim_enable(&htim2);
|
|
||||||
|
st_lib_hal_tim_enable(&htim2);
|
||||||
st_lib_hal_nvic_set_priority((st_lib_irq_n_type) TIM2_IRQn, 0, 0);
|
|
||||||
st_lib_hal_nvic_enable_irq((st_lib_irq_n_type)(TIM2_IRQn));
|
st_lib_hal_nvic_set_priority((st_lib_irq_n_type)TIM2_IRQn, 0, 0);
|
||||||
|
st_lib_hal_nvic_enable_irq((st_lib_irq_n_type)(TIM2_IRQn));
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
rtimer_clock_t rtimer_arch_now(void)
|
rtimer_clock_t
|
||||||
{
|
rtimer_arch_now(void)
|
||||||
return rtimer_clock;
|
{
|
||||||
}
|
return rtimer_clock;
|
||||||
/*---------------------------------------------------------------------------*/
|
}
|
||||||
void rtimer_arch_schedule(rtimer_clock_t t)
|
/*---------------------------------------------------------------------------*/
|
||||||
{
|
void
|
||||||
|
rtimer_arch_schedule(rtimer_clock_t t)
|
||||||
}
|
{
|
||||||
/*---------------------------------------------------------------------------*/
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,45 +1,45 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, STMicroelectronics.
|
* Copyright (c) 2010, STMicroelectronics.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above
|
* 2. Redistributions in binary form must reproduce the above
|
||||||
* copyright notice, this list of conditions and the following
|
* copyright notice, this list of conditions and the following
|
||||||
* disclaimer in the documentation and/or other materials provided
|
* disclaimer in the documentation and/or other materials provided
|
||||||
* with the distribution.
|
* with the distribution.
|
||||||
* 3. The name of the author may not be used to endorse or promote
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
* products derived from this software without specific prior
|
* products derived from this software without specific prior
|
||||||
* written permission.
|
* written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki OS
|
* This file is part of the Contiki OS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#ifndef __RTIMER_ARCH_H__
|
#ifndef __RTIMER_ARCH_H__
|
||||||
#define __RTIMER_ARCH_H__
|
#define __RTIMER_ARCH_H__
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "contiki-conf.h"
|
#include "contiki-conf.h"
|
||||||
#include "sys/clock.h"
|
#include "sys/clock.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
rtimer_clock_t rtimer_arch_now(void);
|
rtimer_clock_t rtimer_arch_now(void);
|
||||||
void rtimer_arch_disable_irq(void);
|
void rtimer_arch_disable_irq(void);
|
||||||
void rtimer_arch_enable_irq(void);
|
void rtimer_arch_enable_irq(void);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#endif /* __RTIMER_ARCH_H__ */
|
#endif /* __RTIMER_ARCH_H__ */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
66
cpu/arm/stm32l152/syscalls.c
Normal file
66
cpu/arm/stm32l152/syscalls.c
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2012, 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.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/*
|
||||||
|
* Function implementation taken and adapted from:
|
||||||
|
* cpu/stm32w108/e_stdio/src/syscalls.c
|
||||||
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
extern int errno;
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Register name faking - works in collusion with the linker. */
|
||||||
|
register char *stack_ptr asm ("sp");
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
caddr_t
|
||||||
|
_sbrk(int incr)
|
||||||
|
{
|
||||||
|
extern char end; /* Defined by the linker */
|
||||||
|
static char *heap_end;
|
||||||
|
char *prev_heap_end;
|
||||||
|
|
||||||
|
if(heap_end == 0) {
|
||||||
|
heap_end = &end;
|
||||||
|
}
|
||||||
|
prev_heap_end = heap_end;
|
||||||
|
if(heap_end + incr > stack_ptr) {
|
||||||
|
_write(1, "Heap and stack collision\n", 25);
|
||||||
|
/*abort ();*/
|
||||||
|
errno = ENOMEM;
|
||||||
|
return (caddr_t)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
heap_end += incr;
|
||||||
|
return (caddr_t)prev_heap_end;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
|
@ -1,67 +0,0 @@
|
||||||
/**
|
|
||||||
*****************************************************************************
|
|
||||||
**
|
|
||||||
** File : sysmem.c
|
|
||||||
**
|
|
||||||
** Author : Ac6
|
|
||||||
**
|
|
||||||
** Abstract : System Workbench Minimal System Memory calls file
|
|
||||||
**
|
|
||||||
** For more information about which c-functions
|
|
||||||
** need which of these lowlevel functions
|
|
||||||
** please consult the Newlib libc-manual
|
|
||||||
**
|
|
||||||
** Environment : System Workbench for MCU
|
|
||||||
**
|
|
||||||
** Distribution: The file is distributed as is, without any warranty
|
|
||||||
** of any kind.
|
|
||||||
**
|
|
||||||
** (c)Copyright System Workbench for MCU.
|
|
||||||
** You may use this file as-is or modify it according to the needs of your
|
|
||||||
** project. Distribution of this file (unmodified or modified) is not
|
|
||||||
** permitted. System Workbench for MCU permit registered System Workbench(R) users the
|
|
||||||
** rights to distribute the assembled, compiled & linked contents of this
|
|
||||||
** file as part of an application binary file, provided that it is built
|
|
||||||
** using the System Workbench for MCU toolchain.
|
|
||||||
**
|
|
||||||
*****************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes */
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* Variables */
|
|
||||||
extern int errno;
|
|
||||||
register char * stack_ptr asm("sp");
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* Functions */
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
_sbrk
|
|
||||||
Increase program data space. Malloc and related functions depend on this
|
|
||||||
**/
|
|
||||||
caddr_t _sbrk(int incr)
|
|
||||||
{
|
|
||||||
extern char end asm("end");
|
|
||||||
static char *heap_end;
|
|
||||||
char *prev_heap_end;
|
|
||||||
|
|
||||||
if (heap_end == 0) {
|
|
||||||
heap_end = &end;
|
|
||||||
}
|
|
||||||
|
|
||||||
prev_heap_end = heap_end;
|
|
||||||
if (heap_end + incr > stack_ptr) {
|
|
||||||
errno = ENOMEM;
|
|
||||||
return (caddr_t) -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
heap_end += incr;
|
|
||||||
|
|
||||||
return (caddr_t) prev_heap_end;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
|
|
|
@ -1,39 +1,33 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file cpu/arm/stm32l152/uart.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Source file for UART read/write
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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 "console.h"
|
#include "console.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -43,8 +37,8 @@ _write(int handle, const unsigned char *buffer, size_t size)
|
||||||
{
|
{
|
||||||
int data_idx;
|
int data_idx;
|
||||||
|
|
||||||
for (data_idx = 0; data_idx < size; data_idx++) {
|
for(data_idx = 0; data_idx < size; data_idx++) {
|
||||||
__io_putchar( *buffer++ );
|
__io_putchar(*buffer++);
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,66 +1,61 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, STMicroelectronics.
|
* Copyright (c) 2010, STMicroelectronics.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above
|
* 2. Redistributions in binary form must reproduce the above
|
||||||
* copyright notice, this list of conditions and the following
|
* copyright notice, this list of conditions and the following
|
||||||
* disclaimer in the documentation and/or other materials provided
|
* disclaimer in the documentation and/or other materials provided
|
||||||
* with the distribution.
|
* with the distribution.
|
||||||
* 3. The name of the author may not be used to endorse or promote
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
* products derived from this software without specific prior
|
* products derived from this software without specific prior
|
||||||
* written permission.
|
* written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki OS
|
* This file is part of the Contiki OS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "dev/watchdog.h"
|
#include "dev/watchdog.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
watchdog_init(void)
|
watchdog_init(void)
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
void
|
||||||
void
|
watchdog_start(void)
|
||||||
watchdog_start(void)
|
{
|
||||||
{
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
}
|
void
|
||||||
/*---------------------------------------------------------------------------*/
|
watchdog_periodic(void)
|
||||||
void
|
{
|
||||||
watchdog_periodic(void)
|
}
|
||||||
{
|
/*---------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
}
|
watchdog_stop(void)
|
||||||
/*---------------------------------------------------------------------------*/
|
{
|
||||||
void
|
}
|
||||||
watchdog_stop(void)
|
/*---------------------------------------------------------------------------*/
|
||||||
{
|
void
|
||||||
|
watchdog_reboot(void)
|
||||||
}
|
{
|
||||||
/*---------------------------------------------------------------------------*/
|
}
|
||||||
void
|
/*---------------------------------------------------------------------------*/
|
||||||
watchdog_reboot(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
|
|
|
@ -1,39 +1,39 @@
|
||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @file contiki-spirit1-main.c
|
* @file contiki-spirit1-main.c
|
||||||
* @author System LAB
|
* @author System LAB
|
||||||
* @version V1.0.0
|
* @version V1.0.0
|
||||||
* @date 17-June-2015
|
* @date 17-June-2015
|
||||||
* @brief Contiki main file for SPIRIT1 platform
|
* @brief Contiki main file for SPIRIT1 platform
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @attention
|
* @attention
|
||||||
*
|
*
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* 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
|
* 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.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* A very simple Contiki application showing sensor values for ST Nucleo
|
* A very simple Contiki application showing sensor values for ST Nucleo
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
#define DEBUG DEBUG_PRINT
|
#define DEBUG DEBUG_PRINT
|
||||||
#include "net/ip/uip-debug.h"
|
#include "net/ip/uip-debug.h"
|
||||||
|
|
||||||
#define PRINT_INTERVAL 5*CLOCK_SECOND
|
#define PRINT_INTERVAL 5 * CLOCK_SECOND
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
PROCESS(sensor_demo_process, "Sensor demo process");
|
PROCESS(sensor_demo_process, "Sensor demo process");
|
||||||
|
@ -76,7 +76,7 @@ PROCESS_THREAD(sensor_demo_process, ev, data)
|
||||||
{
|
{
|
||||||
static struct etimer etimer;
|
static struct etimer etimer;
|
||||||
static unsigned long _button_pressed;
|
static unsigned long _button_pressed;
|
||||||
static int sensor_value = 0;
|
static int sensor_value = 0;
|
||||||
|
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
PROCESS_PAUSE();
|
PROCESS_PAUSE();
|
||||||
|
@ -94,64 +94,61 @@ PROCESS_THREAD(sensor_demo_process, ev, data)
|
||||||
SENSORS_ACTIVATE(gyroscope_sensor);
|
SENSORS_ACTIVATE(gyroscope_sensor);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while(1)
|
while(1) {
|
||||||
{
|
|
||||||
etimer_set(&etimer, PRINT_INTERVAL);
|
etimer_set(&etimer, PRINT_INTERVAL);
|
||||||
|
|
||||||
PROCESS_WAIT_EVENT();
|
PROCESS_WAIT_EVENT();
|
||||||
if (ev == sensors_event && data == &button_sensor)
|
if(ev == sensors_event && data == &button_sensor) {
|
||||||
{
|
|
||||||
printf("Sensor event detected: Button Pressed.\n\n");
|
printf("Sensor event detected: Button Pressed.\n\n");
|
||||||
printf("Toggling Leds\n");
|
printf("Toggling Leds\n");
|
||||||
_button_pressed++;
|
_button_pressed++;
|
||||||
leds_toggle(LEDS_ALL);
|
leds_toggle(LEDS_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("Button state:\t%s (pressed %lu times)\n", button_sensor.value(0) ? "Released" : "Pressed",
|
||||||
printf("Button state:\t%s (pressed %lu times)\n", button_sensor.value(0)?"Released":"Pressed",
|
_button_pressed);
|
||||||
_button_pressed);
|
|
||||||
|
|
||||||
#ifdef COMPILE_SENSORS
|
#ifdef COMPILE_SENSORS
|
||||||
printf("LEDs status:\tRED:n/a GREEN:%s\n", leds_get()&LEDS_GREEN?"on":"off");
|
printf("LEDs status:\tRED:n/a GREEN:%s\n", leds_get() & LEDS_GREEN ? "on" : "off");
|
||||||
#else
|
#else
|
||||||
printf("LEDs status:\tRED:%s GREEN:%s\n", leds_get()&LEDS_RED?"on":"off",
|
printf("LEDs status:\tRED:%s GREEN:%s\n", leds_get() & LEDS_RED ? "on" : "off",
|
||||||
leds_get()&LEDS_GREEN?"on":"off");
|
leds_get() & LEDS_GREEN ? "on" : "off");
|
||||||
#endif /*COMPILE_SENSORS*/
|
#endif /*COMPILE_SENSORS*/
|
||||||
sensor_value = radio_sensor.value(RADIO_SENSOR_LAST_PACKET);
|
sensor_value = radio_sensor.value(RADIO_SENSOR_LAST_PACKET);
|
||||||
printf("Radio (RSSI):\t%d.%d dBm\n", sensor_value/10, ABS_VALUE(sensor_value)%10);
|
printf("Radio (RSSI):\t%d.%d dBm\n", sensor_value / 10, ABS_VALUE(sensor_value) % 10);
|
||||||
printf("Radio (LQI):\t%d\n", radio_sensor.value(RADIO_SENSOR_LAST_VALUE));
|
printf("Radio (LQI):\t%d\n", radio_sensor.value(RADIO_SENSOR_LAST_VALUE));
|
||||||
|
|
||||||
#ifdef COMPILE_SENSORS
|
#ifdef COMPILE_SENSORS
|
||||||
sensor_value = temperature_sensor.value(0);
|
sensor_value = temperature_sensor.value(0);
|
||||||
printf("Temperature:\t%d.%d C\n", sensor_value/10, ABS_VALUE(sensor_value)%10);
|
printf("Temperature:\t%d.%d C\n", sensor_value / 10, ABS_VALUE(sensor_value) % 10);
|
||||||
|
|
||||||
sensor_value = humidity_sensor.value(0);
|
sensor_value = humidity_sensor.value(0);
|
||||||
printf("Humidity:\t%d.%d rH\n", sensor_value/10, ABS_VALUE(sensor_value)%10);
|
printf("Humidity:\t%d.%d rH\n", sensor_value / 10, ABS_VALUE(sensor_value) % 10);
|
||||||
|
|
||||||
sensor_value = pressure_sensor.value(0);
|
sensor_value = pressure_sensor.value(0);
|
||||||
printf("Pressure:\t%d.%d mbar\n", sensor_value/10, ABS_VALUE(sensor_value)%10);
|
printf("Pressure:\t%d.%d mbar\n", sensor_value / 10, ABS_VALUE(sensor_value) % 10);
|
||||||
|
|
||||||
/* NOTE: this demo uses the mapping of ST Nucleo sensors on Contiki sensor API.
|
/* NOTE: this demo uses the mapping of ST Nucleo sensors on Contiki sensor API.
|
||||||
* For a real use case of sensors like acceleration, magneto and gyroscope,
|
* For a real use case of sensors like acceleration, magneto and gyroscope,
|
||||||
* it is better to directly call the ST lib to get the three value (X/Y/Z)
|
* it is better to directly call the ST lib to get the three value (X/Y/Z)
|
||||||
* at once.
|
* at once.
|
||||||
*/
|
*/
|
||||||
printf("Magneto:\t%d/%d/%d (X/Y/Z) mgauss\n", magneto_sensor.value(X_AXIS),
|
printf("Magneto:\t%d/%d/%d (X/Y/Z) mgauss\n", magneto_sensor.value(X_AXIS),
|
||||||
magneto_sensor.value(Y_AXIS),
|
magneto_sensor.value(Y_AXIS),
|
||||||
magneto_sensor.value(Z_AXIS));
|
magneto_sensor.value(Z_AXIS));
|
||||||
|
|
||||||
printf("Acceleration:\t%d/%d/%d (X/Y/Z) mg\n", acceleration_sensor.value(X_AXIS),
|
printf("Acceleration:\t%d/%d/%d (X/Y/Z) mg\n", acceleration_sensor.value(X_AXIS),
|
||||||
acceleration_sensor.value(Y_AXIS),
|
acceleration_sensor.value(Y_AXIS),
|
||||||
acceleration_sensor.value(Z_AXIS));
|
acceleration_sensor.value(Z_AXIS));
|
||||||
|
|
||||||
printf("Gyroscope:\t%d/%d/%d (X/Y/Z) mdps\n", gyroscope_sensor.value(X_AXIS),
|
printf("Gyroscope:\t%d/%d/%d (X/Y/Z) mdps\n", gyroscope_sensor.value(X_AXIS),
|
||||||
gyroscope_sensor.value(Y_AXIS),
|
gyroscope_sensor.value(Y_AXIS),
|
||||||
gyroscope_sensor.value(Z_AXIS));
|
gyroscope_sensor.value(Z_AXIS));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf ("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
PROCESS_END();
|
PROCESS_END();
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,152 +1,140 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file platform/stm32nucleo-spirit1/contiki-conf.h
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-May-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Contiki configuration parameters
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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
|
#ifndef __CONTIKI_CONF_H__
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
#define __CONTIKI_CONF_H__
|
||||||
*
|
/*---------------------------------------------------------------------------*/
|
||||||
******************************************************************************
|
#include "platform-conf.h"
|
||||||
*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
#define SLIP_BRIDGE_CONF_NO_PUTCHAR 1
|
||||||
#ifndef __CONTIKI_CONF_H__
|
|
||||||
#define __CONTIKI_CONF_H__
|
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
|
||||||
/*---------------------------------------------------------------------------*/
|
#define NULLRDC_CONF_802154_AUTOACK 0
|
||||||
#include "platform-conf.h"
|
#define NETSTACK_CONF_FRAMER framer_802154
|
||||||
/*---------------------------------------------------------------------------*/
|
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||||
#define SLIP_BRIDGE_CONF_NO_PUTCHAR 1
|
|
||||||
|
#undef NETSTACK_CONF_RDC
|
||||||
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
|
#define NETSTACK_CONF_RDC nullrdc_driver
|
||||||
#define NULLRDC_CONF_802154_AUTOACK 0
|
#define NETSTACK_RDC_HEADER_LEN 0
|
||||||
#define NETSTACK_CONF_FRAMER framer_802154
|
|
||||||
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
#undef NETSTACK_CONF_MAC
|
||||||
|
#define NETSTACK_CONF_MAC csma_driver
|
||||||
#undef NETSTACK_CONF_RDC
|
#define NETSTACK_MAC_HEADER_LEN 0
|
||||||
#define NETSTACK_CONF_RDC nullrdc_driver
|
|
||||||
#define NETSTACK_RDC_HEADER_LEN 0
|
#define SICSLOWPAN_CONF_MAC_MAX_PAYLOAD \
|
||||||
|
(NETSTACK_RADIO_MAX_PAYLOAD_LEN - NETSTACK_MAC_HEADER_LEN - \
|
||||||
#undef NETSTACK_CONF_MAC
|
NETSTACK_RDC_HEADER_LEN)
|
||||||
#define NETSTACK_CONF_MAC csma_driver
|
|
||||||
#define NETSTACK_MAC_HEADER_LEN 0
|
#define RIMESTATS_CONF_ENABLED 0
|
||||||
|
#define RIMESTATS_CONF_ON 0
|
||||||
#define SICSLOWPAN_CONF_MAC_MAX_PAYLOAD \
|
|
||||||
(NETSTACK_RADIO_MAX_PAYLOAD_LEN - NETSTACK_MAC_HEADER_LEN - \
|
/* Network setup for IPv6 */
|
||||||
NETSTACK_RDC_HEADER_LEN )
|
#define CXMAC_CONF_ANNOUNCEMENTS 0
|
||||||
|
|
||||||
#define RIMESTATS_CONF_ENABLED 0
|
/* A trick to resolve a compilation error with IAR. */
|
||||||
#define RIMESTATS_CONF_ON 0
|
#ifdef __ICCARM__
|
||||||
|
#define UIP_CONF_DS6_AADDR_NBU 1
|
||||||
|
#endif
|
||||||
/* Network setup for IPv6 */
|
|
||||||
|
/* radio driver blocks until ACK is received */
|
||||||
#define CXMAC_CONF_ANNOUNCEMENTS 0
|
#define NULLRDC_CONF_ACK_WAIT_TIME (0)
|
||||||
|
#define CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT 0
|
||||||
|
#define IEEE802154_CONF_PANID 0xABCD
|
||||||
/* A trick to resolve a compilation error with IAR. */
|
|
||||||
#ifdef __ICCARM__
|
#define AODV_COMPLIANCE
|
||||||
#define UIP_CONF_DS6_AADDR_NBU 1
|
|
||||||
#endif
|
#define WITH_ASCII 1
|
||||||
|
|
||||||
/* radio driver blocks until ACK is received */
|
#define PROCESS_CONF_NUMEVENTS 8
|
||||||
#define NULLRDC_CONF_ACK_WAIT_TIME (0)
|
#define PROCESS_CONF_STATS 1
|
||||||
#define CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT 0
|
/*#define PROCESS_CONF_FASTPOLL 4*/
|
||||||
#define IEEE802154_CONF_PANID 0xABCD
|
|
||||||
|
#define LINKADDR_CONF_SIZE 8
|
||||||
#define AODV_COMPLIANCE
|
|
||||||
|
#define UIP_CONF_LL_802154 1
|
||||||
#define WITH_ASCII 1
|
#define UIP_CONF_LLH_LEN 0
|
||||||
|
|
||||||
#define PROCESS_CONF_NUMEVENTS 8
|
#define UIP_CONF_ROUTER 1
|
||||||
#define PROCESS_CONF_STATS 1
|
|
||||||
/*#define PROCESS_CONF_FASTPOLL 4*/
|
/* configure number of neighbors and routes */
|
||||||
|
#ifndef UIP_CONF_DS6_ROUTE_NBU
|
||||||
|
#define UIP_CONF_DS6_ROUTE_NBU 30
|
||||||
#define LINKADDR_CONF_SIZE 8
|
#endif /* UIP_CONF_DS6_ROUTE_NBU */
|
||||||
|
|
||||||
#define UIP_CONF_LL_802154 1
|
#define UIP_CONF_ND6_SEND_RA 0
|
||||||
#define UIP_CONF_LLH_LEN 0
|
#define UIP_CONF_ND6_REACHABLE_TIME 600000 /* 90000// 600000 */
|
||||||
|
#define UIP_CONF_ND6_RETRANS_TIMER 10000
|
||||||
#define UIP_CONF_ROUTER 1
|
|
||||||
|
#define UIP_CONF_IPV6 1
|
||||||
/* configure number of neighbors and routes */
|
#ifndef UIP_CONF_IPV6_QUEUE_PKT
|
||||||
#ifndef UIP_CONF_DS6_ROUTE_NBU
|
#define UIP_CONF_IPV6_QUEUE_PKT 0
|
||||||
#define UIP_CONF_DS6_ROUTE_NBU 30
|
#endif /* UIP_CONF_IPV6_QUEUE_PKT */
|
||||||
#endif /* UIP_CONF_DS6_ROUTE_NBU */
|
#define UIP_CONF_IP_FORWARD 0
|
||||||
|
#ifndef UIP_CONF_BUFFER_SIZE
|
||||||
#define UIP_CONF_ND6_SEND_RA 0
|
#define UIP_CONF_BUFFER_SIZE 280
|
||||||
#define UIP_CONF_ND6_REACHABLE_TIME 600000 //90000// 600000
|
/* #define UIP_CONF_BUFFER_SIZE 600 */
|
||||||
#define UIP_CONF_ND6_RETRANS_TIMER 10000
|
#endif
|
||||||
|
|
||||||
|
#define SICSLOWPAN_CONF_MAXAGE 4
|
||||||
#define UIP_CONF_IPV6 1
|
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
|
||||||
#ifndef UIP_CONF_IPV6_QUEUE_PKT
|
|
||||||
#define UIP_CONF_IPV6_QUEUE_PKT 0
|
#ifndef SICSLOWPAN_CONF_MAX_MAC_TRANSMISSIONS
|
||||||
#endif /* UIP_CONF_IPV6_QUEUE_PKT */
|
#define SICSLOWPAN_CONF_MAX_MAC_TRANSMISSIONS 5
|
||||||
#define UIP_CONF_IP_FORWARD 0
|
#endif /* SICSLOWPAN_CONF_MAX_MAC_TRANSMISSIONS */
|
||||||
#ifndef UIP_CONF_BUFFER_SIZE
|
|
||||||
#define UIP_CONF_BUFFER_SIZE 280
|
#define UIP_CONF_ICMP_DEST_UNREACH 1
|
||||||
//#define UIP_CONF_BUFFER_SIZE 600
|
|
||||||
#endif
|
#define UIP_CONF_DHCP_LIGHT
|
||||||
|
#define UIP_CONF_LLH_LEN 0
|
||||||
#define SICSLOWPAN_CONF_MAXAGE 4
|
#ifndef UIP_CONF_RECEIVE_WINDOW
|
||||||
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
|
#define UIP_CONF_RECEIVE_WINDOW 150
|
||||||
|
#endif
|
||||||
|
#ifndef UIP_CONF_TCP_MSS
|
||||||
#ifndef SICSLOWPAN_CONF_MAX_MAC_TRANSMISSIONS
|
#define UIP_CONF_TCP_MSS UIP_CONF_RECEIVE_WINDOW
|
||||||
#define SICSLOWPAN_CONF_MAX_MAC_TRANSMISSIONS 5
|
#endif
|
||||||
#endif /* SICSLOWPAN_CONF_MAX_MAC_TRANSMISSIONS */
|
#define UIP_CONF_MAX_CONNECTIONS 4
|
||||||
|
#define UIP_CONF_MAX_LISTENPORTS 8
|
||||||
#define UIP_CONF_ICMP_DEST_UNREACH 1
|
#define UIP_CONF_UDP_CONNS 12
|
||||||
|
#define UIP_CONF_FWCACHE_SIZE 30
|
||||||
#define UIP_CONF_DHCP_LIGHT
|
#define UIP_CONF_BROADCAST 1
|
||||||
#define UIP_CONF_LLH_LEN 0
|
#define UIP_ARCH_IPCHKSUM 0
|
||||||
#ifndef UIP_CONF_RECEIVE_WINDOW
|
#define UIP_CONF_UDP 1
|
||||||
#define UIP_CONF_RECEIVE_WINDOW 150
|
#define UIP_CONF_UDP_CHECKSUMS 1
|
||||||
#endif
|
#define UIP_CONF_TCP 1
|
||||||
#ifndef UIP_CONF_TCP_MSS
|
/*---------------------------------------------------------------------------*/
|
||||||
#define UIP_CONF_TCP_MSS UIP_CONF_RECEIVE_WINDOW
|
/* include the project config */
|
||||||
#endif
|
/* PROJECT_CONF_H might be defined in the project Makefile */
|
||||||
#define UIP_CONF_MAX_CONNECTIONS 4
|
#ifdef PROJECT_CONF_H
|
||||||
#define UIP_CONF_MAX_LISTENPORTS 8
|
#include PROJECT_CONF_H
|
||||||
#define UIP_CONF_UDP_CONNS 12
|
#endif /* PROJECT_CONF_H */
|
||||||
#define UIP_CONF_FWCACHE_SIZE 30
|
/*---------------------------------------------------------------------------*/
|
||||||
#define UIP_CONF_BROADCAST 1
|
#endif /* CONTIKI_CONF_H */
|
||||||
#define UIP_ARCH_IPCHKSUM 0
|
/*---------------------------------------------------------------------------*/
|
||||||
#define UIP_CONF_UDP 1
|
|
||||||
#define UIP_CONF_UDP_CHECKSUMS 1
|
|
||||||
#define UIP_CONF_TCP 1
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* include the project config */
|
|
||||||
/* PROJECT_CONF_H might be defined in the project Makefile */
|
|
||||||
#ifdef PROJECT_CONF_H
|
|
||||||
#include PROJECT_CONF_H
|
|
||||||
#endif /* PROJECT_CONF_H */
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
#endif /* CONTIKI_CONF_H */
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
|
|
|
@ -1,198 +1,195 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file contiki-spirit1-main.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Contiki main file for stm32nucleo-spirit1 platform
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
* \addtogroup stm32nucleo-spirit1
|
||||||
*
|
* @{
|
||||||
******************************************************************************
|
*
|
||||||
*/
|
* \file
|
||||||
/**
|
* main file for stm32nucleo-spirit1 platform
|
||||||
* \addtogroup stm32nucleo-spirit1
|
*/
|
||||||
* @{
|
/*---------------------------------------------------------------------------*/
|
||||||
*
|
#include <stdio.h>
|
||||||
* \file
|
#include <string.h>
|
||||||
* main file for stm32nucleo-spirit1 platform
|
#include "stm32cube_hal_init.h"
|
||||||
*/
|
#include "contiki.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
#include "contiki-net.h"
|
||||||
#include <stdio.h>
|
#include "sys/autostart.h"
|
||||||
#include <string.h>
|
#include "dev/leds.h"
|
||||||
#include "stm32cube_hal_init.h"
|
#include "dev/serial-line.h"
|
||||||
#include "contiki.h"
|
#include "dev/slip.h"
|
||||||
#include "contiki-net.h"
|
#include "dev/watchdog.h"
|
||||||
#include "sys/autostart.h"
|
#include "dev/xmem.h"
|
||||||
#include "dev/leds.h"
|
#include "lib/random.h"
|
||||||
#include "dev/serial-line.h"
|
#include "net/netstack.h"
|
||||||
#include "dev/slip.h"
|
#include "net/ip/uip.h"
|
||||||
#include "dev/watchdog.h"
|
#include "net/mac/frame802154.h"
|
||||||
#include "dev/xmem.h"
|
#include "net/rime/rime.h"
|
||||||
#include "lib/random.h"
|
#include "stm32l1xx.h"
|
||||||
#include "net/netstack.h"
|
#include "SPIRIT_Config.h"
|
||||||
#include "net/ip/uip.h"
|
#include "SPIRIT_Management.h"
|
||||||
#include "net/mac/frame802154.h"
|
#include "spirit1.h"
|
||||||
#include "net/rime/rime.h"
|
#include "spirit1-arch.h"
|
||||||
#include "stm32l1xx.h"
|
#include "node-id.h"
|
||||||
#include "SPIRIT_Config.h"
|
#include "hw-config.h"
|
||||||
#include "SPIRIT_Management.h"
|
#include "stdbool.h"
|
||||||
#include "spirit1.h"
|
#include "dev/button-sensor.h"
|
||||||
#include "spirit1-arch.h"
|
#include "dev/radio-sensor.h"
|
||||||
#include "node-id.h"
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "hw-config.h"
|
#if NETSTACK_CONF_WITH_IPV6
|
||||||
#include "stdbool.h"
|
#include "net/ipv6/uip-ds6.h"
|
||||||
#include "dev/button-sensor.h"
|
#endif /*NETSTACK_CONF_WITH_IPV6*/
|
||||||
#include "dev/radio-sensor.h"
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
#if COMPILE_SENSORS
|
||||||
#if NETSTACK_CONF_WITH_IPV6
|
extern const struct sensors_sensor temperature_sensor;
|
||||||
#include "net/ipv6/uip-ds6.h"
|
extern const struct sensors_sensor humidity_sensor;
|
||||||
#endif /*NETSTACK_CONF_WITH_IPV6*/
|
extern const struct sensors_sensor pressure_sensor;
|
||||||
/*---------------------------------------------------------------------------*/
|
extern const struct sensors_sensor magneto_sensor;
|
||||||
#if COMPILE_SENSORS
|
extern const struct sensors_sensor acceleration_sensor;
|
||||||
extern const struct sensors_sensor temperature_sensor;
|
extern const struct sensors_sensor gyroscope_sensor;
|
||||||
extern const struct sensors_sensor humidity_sensor;
|
SENSORS(&button_sensor,
|
||||||
extern const struct sensors_sensor pressure_sensor;
|
&radio_sensor,
|
||||||
extern const struct sensors_sensor magneto_sensor;
|
&temperature_sensor,
|
||||||
extern const struct sensors_sensor acceleration_sensor;
|
&humidity_sensor,
|
||||||
extern const struct sensors_sensor gyroscope_sensor;
|
&pressure_sensor,
|
||||||
SENSORS(&button_sensor,
|
&magneto_sensor,
|
||||||
&radio_sensor,
|
&acceleration_sensor,
|
||||||
&temperature_sensor,
|
&gyroscope_sensor);
|
||||||
&humidity_sensor,
|
#else /*COMPILE_SENSORS*/
|
||||||
&pressure_sensor,
|
SENSORS(&button_sensor,
|
||||||
&magneto_sensor,
|
&radio_sensor);
|
||||||
&acceleration_sensor,
|
#endif /*COMPILE_SENSORS*/
|
||||||
&gyroscope_sensor);
|
/*---------------------------------------------------------------------------*/
|
||||||
#else /*COMPILE_SENSORS*/
|
extern unsigned char node_mac[8];
|
||||||
SENSORS(&button_sensor,
|
/*---------------------------------------------------------------------------*/
|
||||||
&radio_sensor);
|
#ifdef __GNUC__
|
||||||
#endif /*COMPILE_SENSORS*/
|
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
|
||||||
/*---------------------------------------------------------------------------*/
|
set to 'Yes') calls __io_putchar() */
|
||||||
extern unsigned char node_mac[8];
|
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
|
||||||
/*---------------------------------------------------------------------------*/
|
#else
|
||||||
#ifdef __GNUC__
|
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE * f)
|
||||||
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
|
#endif /* __GNUC__ */
|
||||||
set to 'Yes') calls __io_putchar() */
|
/*---------------------------------------------------------------------------*/
|
||||||
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
|
#if NETSTACK_CONF_WITH_IPV6
|
||||||
#else
|
PROCINIT(&etimer_process, &tcpip_process);
|
||||||
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
|
#else /*NETSTACK_CONF_WITH_IPV6*/
|
||||||
#endif /* __GNUC__ */
|
PROCINIT(&etimer_process);
|
||||||
/*---------------------------------------------------------------------------*/
|
#warning "No TCP/IP process!"
|
||||||
#if NETSTACK_CONF_WITH_IPV6
|
#endif /*NETSTACK_CONF_WITH_IPV6*/
|
||||||
PROCINIT(&etimer_process, &tcpip_process);
|
/*---------------------------------------------------------------------------*/
|
||||||
#else /*NETSTACK_CONF_WITH_IPV6*/
|
#define BUSYWAIT_UNTIL(cond, max_time) \
|
||||||
PROCINIT(&etimer_process);
|
do { \
|
||||||
#warning "No TCP/IP process!"
|
rtimer_clock_t t0; \
|
||||||
#endif /*NETSTACK_CONF_WITH_IPV6*/
|
t0 = RTIMER_NOW(); \
|
||||||
/*---------------------------------------------------------------------------*/
|
while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + (max_time))) ; \
|
||||||
#define BUSYWAIT_UNTIL(cond, max_time) \
|
} while(0)
|
||||||
do { \
|
/*---------------------------------------------------------------------------*/
|
||||||
rtimer_clock_t t0; \
|
static void set_rime_addr(void);
|
||||||
t0 = RTIMER_NOW(); \
|
void stm32cube_hal_init();
|
||||||
while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + (max_time))); \
|
/*---------------------------------------------------------------------------*/
|
||||||
} while(0)
|
#if 0
|
||||||
/*---------------------------------------------------------------------------*/
|
static void
|
||||||
static void set_rime_addr(void);
|
panic_main(void)
|
||||||
void stm32cube_hal_init();
|
{
|
||||||
/*---------------------------------------------------------------------------*/
|
volatile uint16_t k;
|
||||||
#if 0
|
while(1) {
|
||||||
static void panic_main(void)
|
leds_toggle(LEDS_ALL);
|
||||||
{
|
for(k = 0; k < 0xffff / 8; k += 1) {
|
||||||
volatile uint16_t k;
|
}
|
||||||
while(1) {
|
}
|
||||||
leds_toggle(LEDS_ALL);
|
}
|
||||||
for(k = 0; k < 0xffff/8; k += 1) { }
|
#endif
|
||||||
}
|
/*---------------------------------------------------------------------------*/
|
||||||
}
|
int
|
||||||
#endif
|
main(int argc, char *argv[])
|
||||||
/*---------------------------------------------------------------------------*/
|
{
|
||||||
int main (int argc, char *argv[])
|
stm32cube_hal_init();
|
||||||
{
|
|
||||||
stm32cube_hal_init();
|
/* init LEDs */
|
||||||
|
leds_init();
|
||||||
/* init LEDs */
|
|
||||||
leds_init();
|
/* Initialize Contiki and our processes. */
|
||||||
|
clock_init();
|
||||||
/* Initialize Contiki and our processes. */
|
ctimer_init();
|
||||||
clock_init();
|
rtimer_init();
|
||||||
ctimer_init();
|
watchdog_init();
|
||||||
rtimer_init();
|
process_init();
|
||||||
watchdog_init();
|
process_start(&etimer_process, NULL);
|
||||||
process_init();
|
|
||||||
process_start(&etimer_process, NULL);
|
/* Restore node id if such has been stored in external mem */
|
||||||
|
node_id_restore(); /* also configures node_mac[] */
|
||||||
|
|
||||||
/* Restore node id if such has been stored in external mem */
|
set_rime_addr();
|
||||||
node_id_restore(); /* also configures node_mac[] */
|
random_init(node_id);
|
||||||
|
|
||||||
set_rime_addr();
|
netstack_init();
|
||||||
random_init(node_id);
|
spirit_radio_driver.on();
|
||||||
|
|
||||||
netstack_init();
|
energest_init();
|
||||||
spirit_radio_driver.on();
|
|
||||||
|
#if NETSTACK_CONF_WITH_IPV6
|
||||||
energest_init();
|
memcpy(&uip_lladdr.addr, node_mac, sizeof(uip_lladdr.addr));
|
||||||
|
|
||||||
|
queuebuf_init();
|
||||||
#if NETSTACK_CONF_WITH_IPV6
|
process_start(&tcpip_process, NULL);
|
||||||
memcpy(&uip_lladdr.addr, node_mac, sizeof(uip_lladdr.addr));
|
|
||||||
|
uip_ipaddr_t ipaddr;
|
||||||
queuebuf_init();
|
uip_ip6addr(&ipaddr, 0xfc00, 0, 0, 0, 0, 0, 0, 0);
|
||||||
process_start(&tcpip_process, NULL);
|
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
|
||||||
|
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
|
||||||
uip_ipaddr_t ipaddr;
|
#endif /* NETSTACK_CONF_WITH_IPV6*/
|
||||||
uip_ip6addr(&ipaddr, 0xfc00, 0, 0, 0, 0, 0, 0, 0);
|
|
||||||
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
|
process_start(&sensors_process, NULL);
|
||||||
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
|
|
||||||
#endif /* NETSTACK_CONF_WITH_IPV6*/
|
autostart_start(autostart_processes);
|
||||||
|
|
||||||
process_start(&sensors_process, NULL);
|
watchdog_start();
|
||||||
|
|
||||||
autostart_start(autostart_processes);
|
while(1) {
|
||||||
|
int r = 0;
|
||||||
watchdog_start();
|
do {
|
||||||
|
r = process_run();
|
||||||
while(1) {
|
} while(r > 0);
|
||||||
int r = 0;
|
}
|
||||||
do {
|
}
|
||||||
r = process_run();
|
/*---------------------------------------------------------------------------*/
|
||||||
} while(r > 0);
|
static void
|
||||||
}
|
set_rime_addr(void)
|
||||||
}
|
{
|
||||||
/*---------------------------------------------------------------------------*/
|
linkaddr_t addr;
|
||||||
static void set_rime_addr(void)
|
|
||||||
{
|
memset(&addr, 0, sizeof(linkaddr_t));
|
||||||
linkaddr_t addr;
|
memcpy(addr.u8, node_mac, sizeof(addr.u8));
|
||||||
|
|
||||||
memset(&addr, 0, sizeof(linkaddr_t));
|
linkaddr_set_node_addr(&addr);
|
||||||
memcpy(addr.u8, node_mac, sizeof(addr.u8));
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
linkaddr_set_node_addr(&addr);
|
/** @} */
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** @} */
|
|
||||||
|
|
|
@ -1,39 +1,34 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file acceleration-sensor.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Enable aceleration sensor functionality
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* \addtogroup stm32nucleo-spirit1-temperature-sensor
|
* \addtogroup stm32nucleo-spirit1-temperature-sensor
|
||||||
* @{
|
* @{
|
||||||
|
@ -50,32 +45,37 @@
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int _active = 1;
|
static int _active = 1;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void init(void)
|
static void
|
||||||
|
init(void)
|
||||||
{
|
{
|
||||||
/*Acceleration and Gyroscope sensors share the same hw*/
|
/*Acceleration and Gyroscope sensors share the same hw*/
|
||||||
if (!st_lib_bsp_imu_6axes_is_initialized()) {
|
if(!st_lib_bsp_imu_6axes_is_initialized()) {
|
||||||
if (IMU_6AXES_OK == st_lib_bsp_imu_6axes_init()) {
|
if(IMU_6AXES_OK == st_lib_bsp_imu_6axes_init()) {
|
||||||
_active = 1;
|
_active = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void activate(void)
|
static void
|
||||||
|
activate(void)
|
||||||
{
|
{
|
||||||
_active = 1;
|
_active = 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void deactivate(void)
|
static void
|
||||||
|
deactivate(void)
|
||||||
{
|
{
|
||||||
_active = 0;
|
_active = 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int active(void)
|
static int
|
||||||
|
active(void)
|
||||||
{
|
{
|
||||||
return _active;
|
return _active;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int value(int type)
|
static int
|
||||||
|
value(int type)
|
||||||
{
|
{
|
||||||
int32_t ret_val = 0;
|
int32_t ret_val = 0;
|
||||||
volatile st_lib_axes_raw_typedef axes_raw_data;
|
volatile st_lib_axes_raw_typedef axes_raw_data;
|
||||||
|
@ -87,48 +87,50 @@ static int value(int type)
|
||||||
*/
|
*/
|
||||||
st_lib_bsp_imu_6axes_x_get_axes_raw(&axes_raw_data);
|
st_lib_bsp_imu_6axes_x_get_axes_raw(&axes_raw_data);
|
||||||
|
|
||||||
switch (type) {
|
switch(type) {
|
||||||
case X_AXIS:
|
case X_AXIS:
|
||||||
ret_val = axes_raw_data.AXIS_X ;
|
ret_val = axes_raw_data.AXIS_X;
|
||||||
break;
|
break;
|
||||||
case Y_AXIS:
|
case Y_AXIS:
|
||||||
ret_val = axes_raw_data.AXIS_Y ;
|
ret_val = axes_raw_data.AXIS_Y;
|
||||||
break;
|
break;
|
||||||
case Z_AXIS:
|
case Z_AXIS:
|
||||||
ret_val = axes_raw_data.AXIS_Z ;
|
ret_val = axes_raw_data.AXIS_Z;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int configure(int type, int value)
|
static int
|
||||||
|
configure(int type, int value)
|
||||||
{
|
{
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SENSORS_HW_INIT:
|
case SENSORS_HW_INIT:
|
||||||
init();
|
init();
|
||||||
return 1;
|
return 1;
|
||||||
case SENSORS_ACTIVE:
|
case SENSORS_ACTIVE:
|
||||||
if(value) {
|
if(value) {
|
||||||
activate();
|
activate();
|
||||||
} else {
|
} else {
|
||||||
deactivate();
|
deactivate();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int status(int type)
|
static int
|
||||||
|
status(int type)
|
||||||
{
|
{
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SENSORS_READY:
|
case SENSORS_READY:
|
||||||
return active();
|
return active();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,39 +1,33 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file acceleration-sensor.h
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Enable aceleration sensor functionality
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \addtogroup stm32nucleo-spirit1-peripherals
|
* \addtogroup stm32nucleo-spirit1-peripherals
|
||||||
|
|
|
@ -1,109 +1,111 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file platform/stm32nucleo-spirit1/dev/button-sensor.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Enable button sensor functionality
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
* \addtogroup stm32nucleo-spirit1-peripherals
|
||||||
*
|
* @{
|
||||||
******************************************************************************
|
*
|
||||||
*/
|
* \file
|
||||||
/**
|
* Driver for the stm32nucleo-spirit1 User Button
|
||||||
* \addtogroup stm32nucleo-spirit1-peripherals
|
*/
|
||||||
* @{
|
/*---------------------------------------------------------------------------*/
|
||||||
*
|
#include "dev/button-sensor.h"
|
||||||
* \file
|
#include "lib/sensors.h"
|
||||||
* Driver for the stm32nucleo-spirit1 User Button
|
#include "st-lib.h"
|
||||||
*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
static int _active = 0;
|
||||||
#include "dev/button-sensor.h"
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "lib/sensors.h"
|
static void
|
||||||
#include "st-lib.h"
|
init(void)
|
||||||
/*---------------------------------------------------------------------------*/
|
{
|
||||||
static int _active = 0 ;
|
/* See spirit1_appli.c for the Callback: it triggers the relevant
|
||||||
/*---------------------------------------------------------------------------*/
|
* sensors_changed event
|
||||||
static void init(void)
|
*/
|
||||||
{
|
st_lib_bsp_pb_init(BUTTON_USER, BUTTON_MODE_EXTI);
|
||||||
/* See spirit1_appli.c for the Callback: it triggers the relevant
|
}
|
||||||
* sensors_changed event
|
/*---------------------------------------------------------------------------*/
|
||||||
*/
|
static void
|
||||||
st_lib_bsp_pb_init(BUTTON_USER, BUTTON_MODE_EXTI);
|
activate(void)
|
||||||
}
|
{
|
||||||
/*---------------------------------------------------------------------------*/
|
_active = 1;
|
||||||
static void activate(void)
|
}
|
||||||
{
|
/*---------------------------------------------------------------------------*/
|
||||||
_active = 1;
|
static void
|
||||||
}
|
deactivate(void)
|
||||||
/*---------------------------------------------------------------------------*/
|
{
|
||||||
static void deactivate(void)
|
_active = 0;
|
||||||
{
|
}
|
||||||
_active = 0;
|
/*---------------------------------------------------------------------------*/
|
||||||
}
|
static int
|
||||||
/*---------------------------------------------------------------------------*/
|
active(void)
|
||||||
static int active(void)
|
{
|
||||||
{
|
return active;
|
||||||
return active;
|
}
|
||||||
}
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
static int
|
||||||
static int value(int type)
|
value(int type)
|
||||||
{
|
{
|
||||||
return st_lib_bsp_pb_get_state(BUTTON_USER);
|
return st_lib_bsp_pb_get_state(BUTTON_USER);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int configure(int type, int value)
|
static int
|
||||||
{
|
configure(int type, int value)
|
||||||
switch(type) {
|
{
|
||||||
case SENSORS_HW_INIT:
|
switch(type) {
|
||||||
init();
|
case SENSORS_HW_INIT:
|
||||||
return 1;
|
init();
|
||||||
case SENSORS_ACTIVE:
|
return 1;
|
||||||
if(value) {
|
case SENSORS_ACTIVE:
|
||||||
activate();
|
if(value) {
|
||||||
} else {
|
activate();
|
||||||
deactivate();
|
} else {
|
||||||
}
|
deactivate();
|
||||||
return 1;
|
}
|
||||||
}
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
|
||||||
}
|
return 0;
|
||||||
/*---------------------------------------------------------------------------*/
|
}
|
||||||
static int status(int type)
|
/*---------------------------------------------------------------------------*/
|
||||||
{
|
static int
|
||||||
switch(type) {
|
status(int type)
|
||||||
case SENSORS_READY:
|
{
|
||||||
return active();
|
switch(type) {
|
||||||
}
|
case SENSORS_READY:
|
||||||
|
return active();
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
return 0;
|
||||||
SENSORS_SENSOR(button_sensor, BUTTON_SENSOR, value, configure, status);
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** @} */
|
SENSORS_SENSOR(button_sensor, BUTTON_SENSOR, value, configure, status);
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/** @} */
|
||||||
|
|
|
@ -1,39 +1,34 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file gyroscope-sensor.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Enable aceleration sensor functionality
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* \addtogroup stm32nucleo-spirit1-gyroscope-sensor
|
* \addtogroup stm32nucleo-spirit1-gyroscope-sensor
|
||||||
* @{
|
* @{
|
||||||
|
@ -50,32 +45,37 @@
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int _active = 1;
|
static int _active = 1;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void init(void)
|
static void
|
||||||
|
init(void)
|
||||||
{
|
{
|
||||||
/*Acceleration and Gyroscope sensors share the same hw*/
|
/*Acceleration and Gyroscope sensors share the same hw*/
|
||||||
if (!st_lib_bsp_imu_6axes_is_initialized()) {
|
if(!st_lib_bsp_imu_6axes_is_initialized()) {
|
||||||
if (IMU_6AXES_OK == st_lib_bsp_imu_6axes_init()) {
|
if(IMU_6AXES_OK == st_lib_bsp_imu_6axes_init()) {
|
||||||
_active = 1;
|
_active = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void activate(void)
|
static void
|
||||||
|
activate(void)
|
||||||
{
|
{
|
||||||
_active = 1;
|
_active = 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void deactivate(void)
|
static void
|
||||||
|
deactivate(void)
|
||||||
{
|
{
|
||||||
_active = 0;
|
_active = 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int active(void)
|
static int
|
||||||
|
active(void)
|
||||||
{
|
{
|
||||||
return _active;
|
return _active;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int value(int type)
|
static int
|
||||||
|
value(int type)
|
||||||
{
|
{
|
||||||
int32_t ret_val = 0;
|
int32_t ret_val = 0;
|
||||||
volatile st_lib_axes_raw_typedef axes_raw_data;
|
volatile st_lib_axes_raw_typedef axes_raw_data;
|
||||||
|
@ -87,48 +87,50 @@ static int value(int type)
|
||||||
*/
|
*/
|
||||||
st_lib_bsp_imu_6axes_g_get_axes_raw(&axes_raw_data);
|
st_lib_bsp_imu_6axes_g_get_axes_raw(&axes_raw_data);
|
||||||
|
|
||||||
switch (type) {
|
switch(type) {
|
||||||
case X_AXIS:
|
case X_AXIS:
|
||||||
ret_val = axes_raw_data.AXIS_X ;
|
ret_val = axes_raw_data.AXIS_X;
|
||||||
break;
|
break;
|
||||||
case Y_AXIS:
|
case Y_AXIS:
|
||||||
ret_val = axes_raw_data.AXIS_Y ;
|
ret_val = axes_raw_data.AXIS_Y;
|
||||||
break;
|
break;
|
||||||
case Z_AXIS:
|
case Z_AXIS:
|
||||||
ret_val = axes_raw_data.AXIS_Z ;
|
ret_val = axes_raw_data.AXIS_Z;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int configure(int type, int value)
|
static int
|
||||||
|
configure(int type, int value)
|
||||||
{
|
{
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SENSORS_HW_INIT:
|
case SENSORS_HW_INIT:
|
||||||
init();
|
init();
|
||||||
return 1;
|
return 1;
|
||||||
case SENSORS_ACTIVE:
|
case SENSORS_ACTIVE:
|
||||||
if(value) {
|
if(value) {
|
||||||
activate();
|
activate();
|
||||||
} else {
|
} else {
|
||||||
deactivate();
|
deactivate();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int status(int type)
|
static int
|
||||||
|
status(int type)
|
||||||
{
|
{
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SENSORS_READY:
|
case SENSORS_READY:
|
||||||
return active();
|
return active();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,39 +1,33 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file gyroscope-sensor.h
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Enable aceleration sensor functionality
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \addtogroup stm32nucleo-spirit1-peripherals
|
* \addtogroup stm32nucleo-spirit1-peripherals
|
||||||
|
|
|
@ -1,120 +1,122 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file humidity-sensor.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Enable humidity sensor functionality
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
* \addtogroup stm32nucleo-spirit1-humidity-sensor
|
||||||
*
|
* @{
|
||||||
******************************************************************************
|
*
|
||||||
*/
|
* \file
|
||||||
/**
|
* Driver for the stm32nucleo-spirit1 Humidity sensor (on expansion board)
|
||||||
* \addtogroup stm32nucleo-spirit1-humidity-sensor
|
*/
|
||||||
* @{
|
/*---------------------------------------------------------------------------*/
|
||||||
*
|
#if COMPILE_SENSORS
|
||||||
* \file
|
/*---------------------------------------------------------------------------*/
|
||||||
* Driver for the stm32nucleo-spirit1 Humidity sensor (on expansion board)
|
#include "lib/sensors.h"
|
||||||
*/
|
#include "humidity-sensor.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
#include "st-lib.h"
|
||||||
#if COMPILE_SENSORS
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
static int _active = 1;
|
||||||
#include "lib/sensors.h"
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "humidity-sensor.h"
|
static void
|
||||||
#include "st-lib.h"
|
init(void)
|
||||||
/*---------------------------------------------------------------------------*/
|
{
|
||||||
static int _active = 1;
|
/*Temperature and Humity sensors share the same hw*/
|
||||||
/*---------------------------------------------------------------------------*/
|
if(!st_lib_bsp_hum_temp_is_initialized()) {
|
||||||
static void init(void)
|
st_lib_bsp_hum_temp_init();
|
||||||
{
|
_active = 1;
|
||||||
/*Temperature and Humity sensors share the same hw*/
|
}
|
||||||
if (!st_lib_bsp_hum_temp_is_initialized()) {
|
}
|
||||||
st_lib_bsp_hum_temp_init();
|
/*---------------------------------------------------------------------------*/
|
||||||
_active=1;
|
static void
|
||||||
}
|
activate(void)
|
||||||
}
|
{
|
||||||
/*---------------------------------------------------------------------------*/
|
_active = 1;
|
||||||
static void activate(void)
|
}
|
||||||
{
|
/*---------------------------------------------------------------------------*/
|
||||||
_active = 1;
|
static void
|
||||||
}
|
deactivate(void)
|
||||||
/*---------------------------------------------------------------------------*/
|
{
|
||||||
static void deactivate(void)
|
_active = 0;
|
||||||
{
|
}
|
||||||
_active = 0;
|
/*---------------------------------------------------------------------------*/
|
||||||
}
|
static int
|
||||||
/*---------------------------------------------------------------------------*/
|
active(void)
|
||||||
static int active(void)
|
{
|
||||||
{
|
return _active;
|
||||||
return _active;
|
}
|
||||||
}
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
static int
|
||||||
static int value(int type)
|
value(int type)
|
||||||
{
|
{
|
||||||
uint32_t humidity;
|
uint32_t humidity;
|
||||||
volatile float humidity_value;
|
volatile float humidity_value;
|
||||||
|
|
||||||
st_lib_bsp_hum_temp_get_humidity((float *)&humidity_value);
|
st_lib_bsp_hum_temp_get_humidity((float *)&humidity_value);
|
||||||
|
|
||||||
humidity = humidity_value * 10;
|
humidity = humidity_value * 10;
|
||||||
return humidity;
|
return humidity;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int configure(int type, int value)
|
static int
|
||||||
{
|
configure(int type, int value)
|
||||||
switch(type) {
|
{
|
||||||
case SENSORS_HW_INIT:
|
switch(type) {
|
||||||
init();
|
case SENSORS_HW_INIT:
|
||||||
return 1;
|
init();
|
||||||
case SENSORS_ACTIVE:
|
return 1;
|
||||||
if(value) {
|
case SENSORS_ACTIVE:
|
||||||
activate();
|
if(value) {
|
||||||
} else {
|
activate();
|
||||||
deactivate();
|
} else {
|
||||||
}
|
deactivate();
|
||||||
return 1;
|
}
|
||||||
}
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
|
||||||
}
|
return 0;
|
||||||
/*---------------------------------------------------------------------------*/
|
}
|
||||||
static int status(int type)
|
/*---------------------------------------------------------------------------*/
|
||||||
{
|
static int
|
||||||
switch(type) {
|
status(int type)
|
||||||
case SENSORS_READY:
|
{
|
||||||
return active();
|
switch(type) {
|
||||||
}
|
case SENSORS_READY:
|
||||||
|
return active();
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
return 0;
|
||||||
SENSORS_SENSOR(humidity_sensor, HUMIDITY_SENSOR, value, configure, status);
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#endif /*COMPILE_SENSORS*/
|
SENSORS_SENSOR(humidity_sensor, HUMIDITY_SENSOR, value, configure, status);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** @} */
|
#endif /*COMPILE_SENSORS*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/** @} */
|
||||||
|
|
|
@ -1,39 +1,33 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file humidity-sensor.h
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Enable humidity sensor functionality
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \addtogroup stm32nucleo-spirit1-peripherals
|
* \addtogroup stm32nucleo-spirit1-peripherals
|
||||||
|
|
|
@ -1,39 +1,34 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file platform/stm32nucleo-spirit1/dev/leds-arch.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Contiki LEDs API binding for the boards in use: Nucleo and SPIRIT1
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* \addtogroup stm32nucleo-spirit1-peripherals
|
* \addtogroup stm32nucleo-spirit1-peripherals
|
||||||
* @{
|
* @{
|
||||||
|
@ -50,14 +45,15 @@
|
||||||
/* The Red LED (on SPIRIT1 exp board) is exposed only if the sensor board is NOT
|
/* The Red LED (on SPIRIT1 exp board) is exposed only if the sensor board is NOT
|
||||||
* used, becasue of a pin conflict.
|
* used, becasue of a pin conflict.
|
||||||
*/
|
*/
|
||||||
extern st_lib_gpio_typedef* st_lib_a_led_gpio_port[];
|
extern st_lib_gpio_typedef *st_lib_a_led_gpio_port[];
|
||||||
extern const uint16_t st_lib_a_led_gpio_pin[];
|
extern const uint16_t st_lib_a_led_gpio_pin[];
|
||||||
#endif /*COMPILE_SENSORS*/
|
#endif /*COMPILE_SENSORS*/
|
||||||
|
|
||||||
extern st_lib_gpio_typedef* st_lib_gpio_port[];
|
extern st_lib_gpio_typedef *st_lib_gpio_port[];
|
||||||
extern const uint16_t st_lib_gpio_pin[];
|
extern const uint16_t st_lib_gpio_pin[];
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void leds_arch_init(void)
|
void
|
||||||
|
leds_arch_init(void)
|
||||||
{
|
{
|
||||||
/* We have at least one led, the one on the Nucleo (GREEN)*/
|
/* We have at least one led, the one on the Nucleo (GREEN)*/
|
||||||
st_lib_bsp_led_init(LED2);
|
st_lib_bsp_led_init(LED2);
|
||||||
|
@ -72,10 +68,11 @@ void leds_arch_init(void)
|
||||||
#endif /*COMPILE_SENSORS*/
|
#endif /*COMPILE_SENSORS*/
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
unsigned char leds_arch_get(void)
|
unsigned char
|
||||||
|
leds_arch_get(void)
|
||||||
{
|
{
|
||||||
unsigned char ret = 0 ;
|
unsigned char ret = 0;
|
||||||
if (st_lib_hal_gpio_read_pin(st_lib_gpio_port[LED2],st_lib_gpio_pin[LED2])) {
|
if(st_lib_hal_gpio_read_pin(st_lib_gpio_port[LED2], st_lib_gpio_pin[LED2])) {
|
||||||
ret |= LEDS_GREEN;
|
ret |= LEDS_GREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,8 +80,8 @@ unsigned char leds_arch_get(void)
|
||||||
/* The Red LED (on SPIRIT1 exp board) is exposed only if the sensor board is NOT
|
/* The Red LED (on SPIRIT1 exp board) is exposed only if the sensor board is NOT
|
||||||
* used, becasue of a pin conflict.
|
* used, becasue of a pin conflict.
|
||||||
*/
|
*/
|
||||||
if (st_lib_hal_gpio_read_pin(st_lib_a_led_gpio_port[RADIO_SHIELD_LED],
|
if(st_lib_hal_gpio_read_pin(st_lib_a_led_gpio_port[RADIO_SHIELD_LED],
|
||||||
st_lib_a_led_gpio_pin[RADIO_SHIELD_LED])) {
|
st_lib_a_led_gpio_pin[RADIO_SHIELD_LED])) {
|
||||||
ret |= LEDS_RED;
|
ret |= LEDS_RED;
|
||||||
}
|
}
|
||||||
#endif /*COMPILE_SENSORS*/
|
#endif /*COMPILE_SENSORS*/
|
||||||
|
@ -92,9 +89,10 @@ unsigned char leds_arch_get(void)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void leds_arch_set(unsigned char leds)
|
void
|
||||||
|
leds_arch_set(unsigned char leds)
|
||||||
{
|
{
|
||||||
if (leds & LEDS_GREEN) {
|
if(leds & LEDS_GREEN) {
|
||||||
st_lib_bsp_led_on(LED2);
|
st_lib_bsp_led_on(LED2);
|
||||||
} else {
|
} else {
|
||||||
st_lib_bsp_led_off(LED2);
|
st_lib_bsp_led_off(LED2);
|
||||||
|
@ -104,7 +102,7 @@ void leds_arch_set(unsigned char leds)
|
||||||
/* The Red LED (on SPIRIT1 exp board) is exposed only if the sensor board is NOT
|
/* The Red LED (on SPIRIT1 exp board) is exposed only if the sensor board is NOT
|
||||||
* used, becasue of a pin conflict.
|
* used, becasue of a pin conflict.
|
||||||
*/
|
*/
|
||||||
if (leds & LEDS_RED) {
|
if(leds & LEDS_RED) {
|
||||||
st_lib_radio_shield_led_on(RADIO_SHIELD_LED);
|
st_lib_radio_shield_led_on(RADIO_SHIELD_LED);
|
||||||
} else {
|
} else {
|
||||||
st_lib_radio_shield_led_off(RADIO_SHIELD_LED);
|
st_lib_radio_shield_led_off(RADIO_SHIELD_LED);
|
||||||
|
|
|
@ -1,39 +1,34 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file magneto-sensor.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Enable magneto sensor functionality
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* \addtogroup stm32nucleo-spirit1-magneto-sensor
|
* \addtogroup stm32nucleo-spirit1-magneto-sensor
|
||||||
* @{
|
* @{
|
||||||
|
@ -50,28 +45,33 @@
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int _active = 1;
|
static int _active = 1;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void init(void)
|
static void
|
||||||
|
init(void)
|
||||||
{
|
{
|
||||||
BSP_MAGNETO_Init();
|
BSP_MAGNETO_Init();
|
||||||
_active = 1;
|
_active = 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void activate(void)
|
static void
|
||||||
|
activate(void)
|
||||||
{
|
{
|
||||||
_active = 1;
|
_active = 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void deactivate(void)
|
static void
|
||||||
|
deactivate(void)
|
||||||
{
|
{
|
||||||
_active = 0;
|
_active = 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int active(void)
|
static int
|
||||||
|
active(void)
|
||||||
{
|
{
|
||||||
return _active;
|
return _active;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int value(int type)
|
static int
|
||||||
|
value(int type)
|
||||||
{
|
{
|
||||||
int32_t ret_val = 0;
|
int32_t ret_val = 0;
|
||||||
volatile st_lib_axes_raw_typedef axes_raw_data;
|
volatile st_lib_axes_raw_typedef axes_raw_data;
|
||||||
|
@ -83,48 +83,50 @@ static int value(int type)
|
||||||
*/
|
*/
|
||||||
st_lib_bsp_magneto_m_get_axes_raw(&axes_raw_data);
|
st_lib_bsp_magneto_m_get_axes_raw(&axes_raw_data);
|
||||||
|
|
||||||
switch (type) {
|
switch(type) {
|
||||||
case X_AXIS:
|
case X_AXIS:
|
||||||
ret_val = axes_raw_data.AXIS_X ;
|
ret_val = axes_raw_data.AXIS_X;
|
||||||
break;
|
break;
|
||||||
case Y_AXIS:
|
case Y_AXIS:
|
||||||
ret_val = axes_raw_data.AXIS_Y ;
|
ret_val = axes_raw_data.AXIS_Y;
|
||||||
break;
|
break;
|
||||||
case Z_AXIS:
|
case Z_AXIS:
|
||||||
ret_val = axes_raw_data.AXIS_Z ;
|
ret_val = axes_raw_data.AXIS_Z;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int configure(int type, int value)
|
static int
|
||||||
|
configure(int type, int value)
|
||||||
{
|
{
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SENSORS_HW_INIT:
|
case SENSORS_HW_INIT:
|
||||||
init();
|
init();
|
||||||
return 1;
|
return 1;
|
||||||
case SENSORS_ACTIVE:
|
case SENSORS_ACTIVE:
|
||||||
if(value) {
|
if(value) {
|
||||||
activate();
|
activate();
|
||||||
} else {
|
} else {
|
||||||
deactivate();
|
deactivate();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int status(int type)
|
static int
|
||||||
|
status(int type)
|
||||||
{
|
{
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SENSORS_READY:
|
case SENSORS_READY:
|
||||||
return active();
|
return active();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,39 +1,33 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file magneto-sensor.h
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Enable magneto sensor functionality
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \addtogroup stm32nucleo-spirit1-peripherals
|
* \addtogroup stm32nucleo-spirit1-peripherals
|
||||||
|
|
|
@ -1,39 +1,34 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file pressure-sensor.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Enable pressure sensor functionality
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* \addtogroup stm32nucleo-spirit1-pressure-sensor
|
* \addtogroup stm32nucleo-spirit1-pressure-sensor
|
||||||
* @{
|
* @{
|
||||||
|
@ -50,63 +45,70 @@
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int _active = 1;
|
static int _active = 1;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void init(void)
|
static void
|
||||||
|
init(void)
|
||||||
{
|
{
|
||||||
st_lib_bsp_pressure_init();
|
st_lib_bsp_pressure_init();
|
||||||
_active =1;
|
_active = 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void activate(void)
|
static void
|
||||||
|
activate(void)
|
||||||
{
|
{
|
||||||
_active = 1;
|
_active = 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void deactivate(void)
|
static void
|
||||||
|
deactivate(void)
|
||||||
{
|
{
|
||||||
_active = 0;
|
_active = 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int active(void)
|
static int
|
||||||
|
active(void)
|
||||||
{
|
{
|
||||||
return _active;
|
return _active;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int value(int type)
|
static int
|
||||||
|
value(int type)
|
||||||
{
|
{
|
||||||
uint16_t pressure;
|
uint16_t pressure;
|
||||||
volatile float pressure_value;
|
volatile float pressure_value;
|
||||||
|
|
||||||
st_lib_bsp_pressure_get_pressure((float *)&pressure_value);
|
st_lib_bsp_pressure_get_pressure((float *)&pressure_value);
|
||||||
pressure = pressure_value * 10;
|
pressure = pressure_value * 10;
|
||||||
|
|
||||||
return pressure;
|
return pressure;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int configure(int type, int value)
|
static int
|
||||||
|
configure(int type, int value)
|
||||||
{
|
{
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SENSORS_HW_INIT:
|
case SENSORS_HW_INIT:
|
||||||
init();
|
init();
|
||||||
return 1;
|
return 1;
|
||||||
case SENSORS_ACTIVE:
|
case SENSORS_ACTIVE:
|
||||||
if(value) {
|
if(value) {
|
||||||
activate();
|
activate();
|
||||||
} else {
|
} else {
|
||||||
deactivate();
|
deactivate();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int status(int type)
|
static int
|
||||||
|
status(int type)
|
||||||
{
|
{
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SENSORS_READY:
|
case SENSORS_READY:
|
||||||
return active();
|
return active();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,39 +1,33 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file pressure-sensor.h
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Enable pressure sensor functionality
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \addtogroup stm32nucleo-spirit1-peripherals
|
* \addtogroup stm32nucleo-spirit1-peripherals
|
||||||
|
|
|
@ -1,39 +1,34 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file platform/stm32nucleo-spirit1/dev/radio-sensor.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 7-September-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Enable radio sensor functionality
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* \addtogroup stm32nucleo-spirit1-peripherals
|
* \addtogroup stm32nucleo-spirit1-peripherals
|
||||||
* @{
|
* @{
|
||||||
|
@ -50,76 +45,84 @@
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int _active;
|
static int _active;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void init(void)
|
static void
|
||||||
|
init(void)
|
||||||
{
|
{
|
||||||
/*Nothing to do at the moment, can be used in the future.*/
|
/*Nothing to do at the moment, can be used in the future.*/
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void activate(void)
|
static void
|
||||||
|
activate(void)
|
||||||
{
|
{
|
||||||
_active = 1;
|
_active = 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void deactivate(void)
|
static void
|
||||||
|
deactivate(void)
|
||||||
{
|
{
|
||||||
_active = 0;
|
_active = 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int active(void)
|
static int
|
||||||
|
active(void)
|
||||||
{
|
{
|
||||||
return _active;
|
return _active;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int value(int type)
|
static int
|
||||||
|
value(int type)
|
||||||
{
|
{
|
||||||
int32_t radio_sensor;
|
int32_t radio_sensor;
|
||||||
float radio_sensor_value;
|
float radio_sensor_value;
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case RADIO_SENSOR_LAST_PACKET:
|
case RADIO_SENSOR_LAST_PACKET:
|
||||||
/*TODO: check which method of getting these value is more appropriate */
|
/*TODO: check which method of getting these value is more appropriate */
|
||||||
radio_sensor_value = DBM_VALUE(packetbuf_attr(PACKETBUF_ATTR_RSSI));
|
radio_sensor_value = DBM_VALUE(packetbuf_attr(PACKETBUF_ATTR_RSSI));
|
||||||
//radio_sensor_value = st_lib_spirit_qi_get_rssi_dbm();
|
/* radio_sensor_value = st_lib_spirit_qi_get_rssi_dbm(); */
|
||||||
radio_sensor = (int32_t) (radio_sensor_value * 10);
|
radio_sensor = (int32_t)(radio_sensor_value * 10);
|
||||||
break;
|
break;
|
||||||
case RADIO_SENSOR_LAST_VALUE:
|
case RADIO_SENSOR_LAST_VALUE:
|
||||||
default:
|
default:
|
||||||
/*TODO: check which method of getting these value is more appropriate */
|
/*TODO: check which method of getting these value is more appropriate */
|
||||||
radio_sensor = packetbuf_attr(PACKETBUF_ATTR_LINK_QUALITY);
|
radio_sensor = packetbuf_attr(PACKETBUF_ATTR_LINK_QUALITY);
|
||||||
//radio_sensor = (int32_t) st_lib_spirit_qi_get_lqi();
|
/* radio_sensor = (int32_t) st_lib_spirit_qi_get_lqi(); */
|
||||||
}
|
}
|
||||||
|
|
||||||
return radio_sensor;
|
return radio_sensor;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int configure(int type, int value)
|
static int
|
||||||
|
configure(int type, int value)
|
||||||
{
|
{
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SENSORS_HW_INIT:
|
case SENSORS_HW_INIT:
|
||||||
init();
|
init();
|
||||||
return 1;
|
return 1;
|
||||||
case SENSORS_ACTIVE:
|
case SENSORS_ACTIVE:
|
||||||
if(value) {
|
if(value) {
|
||||||
activate();
|
activate();
|
||||||
} else {
|
} else {
|
||||||
deactivate();
|
deactivate();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int status(int type)
|
static int
|
||||||
|
status(int type)
|
||||||
{
|
{
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SENSORS_READY:
|
case SENSORS_READY:
|
||||||
return active();
|
return active();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
SENSORS_SENSOR(radio_sensor, RADIO_SENSOR, value, configure, status);
|
SENSORS_SENSOR(radio_sensor, RADIO_SENSOR, value, configure, status);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
|
@ -1,39 +1,33 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file platform/stm32nucleo-spirit1/dev/sensor-common.h
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Common defines for sensors data structurers
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \addtogroup stm32nucleo-spirit1-peripherals
|
* \addtogroup stm32nucleo-spirit1-peripherals
|
||||||
|
@ -51,8 +45,8 @@
|
||||||
#define Y_AXIS 0x01
|
#define Y_AXIS 0x01
|
||||||
#define Z_AXIS 0x02
|
#define Z_AXIS 0x02
|
||||||
|
|
||||||
#define ABS_VALUE(x) (((x)>0)?(x):(-(x)))
|
#define ABS_VALUE(x) (((x) > 0) ? (x) : (-(x)))
|
||||||
#define DBM_VALUE(x) (-120.0+((float)((x)-20))/2)
|
#define DBM_VALUE(x) (-120.0 + ((float)((x) - 20)) / 2)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#endif /*SENSOR_COMMON_H_*/
|
#endif /*SENSOR_COMMON_H_*/
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,119 +1,121 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file platform/stm32nucleo-spirit1/dev/temperature-sensor.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Enable temperature sensor functionality
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
* \addtogroup stm32nucleo-spirit1-temperature-sensor
|
||||||
*
|
* @{
|
||||||
******************************************************************************
|
*
|
||||||
*/
|
* \file
|
||||||
/**
|
* Driver for the stm32nucleo-spirit1 Temperature sensor (on expansion board)
|
||||||
* \addtogroup stm32nucleo-spirit1-temperature-sensor
|
*/
|
||||||
* @{
|
/*---------------------------------------------------------------------------*/
|
||||||
*
|
#if COMPILE_SENSORS
|
||||||
* \file
|
/*---------------------------------------------------------------------------*/
|
||||||
* Driver for the stm32nucleo-spirit1 Temperature sensor (on expansion board)
|
#include "lib/sensors.h"
|
||||||
*/
|
#include "temperature-sensor.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
#include "st-lib.h"
|
||||||
#if COMPILE_SENSORS
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
static int _active = 0;
|
||||||
#include "lib/sensors.h"
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "temperature-sensor.h"
|
static void
|
||||||
#include "st-lib.h"
|
init(void)
|
||||||
/*---------------------------------------------------------------------------*/
|
{
|
||||||
static int _active = 0;
|
/*Temperature and Humity sensors share the same hw*/
|
||||||
/*---------------------------------------------------------------------------*/
|
if(!st_lib_bsp_hum_temp_is_initialized()) {
|
||||||
static void init(void)
|
st_lib_bsp_hum_temp_init();
|
||||||
{
|
_active = 1;
|
||||||
/*Temperature and Humity sensors share the same hw*/
|
}
|
||||||
if (!st_lib_bsp_hum_temp_is_initialized()) {
|
}
|
||||||
st_lib_bsp_hum_temp_init();
|
/*---------------------------------------------------------------------------*/
|
||||||
_active=1;
|
static void
|
||||||
}
|
activate(void)
|
||||||
}
|
{
|
||||||
/*---------------------------------------------------------------------------*/
|
_active = 1;
|
||||||
static void activate(void)
|
}
|
||||||
{
|
/*---------------------------------------------------------------------------*/
|
||||||
_active = 1;
|
static void
|
||||||
}
|
deactivate(void)
|
||||||
/*---------------------------------------------------------------------------*/
|
{
|
||||||
static void deactivate(void)
|
_active = 0;
|
||||||
{
|
}
|
||||||
_active = 0;
|
/*---------------------------------------------------------------------------*/
|
||||||
}
|
static int
|
||||||
/*---------------------------------------------------------------------------*/
|
active(void)
|
||||||
static int active(void)
|
{
|
||||||
{
|
return _active;
|
||||||
return _active;
|
}
|
||||||
}
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
static int
|
||||||
static int value(int type)
|
value(int type)
|
||||||
{
|
{
|
||||||
int32_t temperature;
|
int32_t temperature;
|
||||||
volatile float temperature_value;
|
volatile float temperature_value;
|
||||||
|
|
||||||
st_lib_bsp_hum_temp_get_temperature((float *)&temperature_value);
|
st_lib_bsp_hum_temp_get_temperature((float *)&temperature_value);
|
||||||
temperature = temperature_value * 10;
|
temperature = temperature_value * 10;
|
||||||
return temperature;
|
return temperature;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int configure(int type, int value)
|
static int
|
||||||
{
|
configure(int type, int value)
|
||||||
switch(type) {
|
{
|
||||||
case SENSORS_HW_INIT:
|
switch(type) {
|
||||||
init();
|
case SENSORS_HW_INIT:
|
||||||
return 1;
|
init();
|
||||||
case SENSORS_ACTIVE:
|
return 1;
|
||||||
if(value) {
|
case SENSORS_ACTIVE:
|
||||||
activate();
|
if(value) {
|
||||||
} else {
|
activate();
|
||||||
deactivate();
|
} else {
|
||||||
}
|
deactivate();
|
||||||
return 1;
|
}
|
||||||
}
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
|
||||||
}
|
return 0;
|
||||||
/*---------------------------------------------------------------------------*/
|
}
|
||||||
static int status(int type)
|
/*---------------------------------------------------------------------------*/
|
||||||
{
|
static int
|
||||||
switch(type) {
|
status(int type)
|
||||||
case SENSORS_READY:
|
{
|
||||||
return active();
|
switch(type) {
|
||||||
}
|
case SENSORS_READY:
|
||||||
|
return active();
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
return 0;
|
||||||
SENSORS_SENSOR(temperature_sensor, TEMPERATURE_SENSOR,
|
}
|
||||||
value, configure, status);
|
/*---------------------------------------------------------------------------*/
|
||||||
#endif /*COMPILE_SENSORS*/
|
SENSORS_SENSOR(temperature_sensor, TEMPERATURE_SENSOR,
|
||||||
/*---------------------------------------------------------------------------*/
|
value, configure, status);
|
||||||
/** @} */
|
#endif /*COMPILE_SENSORS*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/** @} */
|
||||||
|
|
|
@ -1,39 +1,33 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file platform/stm32nucleo-spirit1/dev/temperature-sensor.h
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Enable temperature sensor functionality
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \addtogroup stm32nucleo-spirit1-peripherals
|
* \addtogroup stm32nucleo-spirit1-peripherals
|
||||||
|
|
|
@ -1,54 +1,48 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file platform/stm32nucleo-spirit1/dev/uart1.h
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Include file for BAUD2UBR macro
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
* \addtogroup stm32nucleo-spirit1-peripherals
|
||||||
*
|
* @{
|
||||||
******************************************************************************
|
*
|
||||||
*/
|
*
|
||||||
/*---------------------------------------------------------------------------*/
|
* \file
|
||||||
/**
|
* Header file for UART related definitions.
|
||||||
* \addtogroup stm32nucleo-spirit1-peripherals
|
*/
|
||||||
* @{
|
/*---------------------------------------------------------------------------*/
|
||||||
*
|
#ifndef UART1_H_
|
||||||
*
|
#define UART1_H_
|
||||||
* \file
|
/*---------------------------------------------------------------------------*/
|
||||||
* Header file for UART related definitions.
|
#define BAUD2UBR(baud) baud
|
||||||
*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
#endif /* UART1_H_ */
|
||||||
#ifndef UART1_H_
|
/*---------------------------------------------------------------------------*/
|
||||||
#define UART1_H_
|
/** @} */
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
#define BAUD2UBR(baud) baud
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
#endif /* UART1_H_ */
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** @} */
|
|
||||||
|
|
|
@ -1,125 +1,117 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file hw-config.h
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-May-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Header file for Hardware Configuration & Setup
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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
|
#ifndef __HW_CONFIG_H
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
#define __HW_CONFIG_H
|
||||||
*
|
/*---------------------------------------------------------------------------*/
|
||||||
******************************************************************************
|
#include "stm32l-spirit1-config.h"
|
||||||
*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
#define UART_RxBufferSize 512
|
||||||
#ifndef __HW_CONFIG_H
|
/*---------------------------------------------------------------------------*/
|
||||||
#define __HW_CONFIG_H
|
#define I2Cx I2C1
|
||||||
/*---------------------------------------------------------------------------*/
|
#define I2Cx_CLK_ENABLE() __I2C1_CLK_ENABLE()
|
||||||
#include "stm32l-spirit1-config.h"
|
#define I2Cx_SDA_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
|
||||||
/*---------------------------------------------------------------------------*/
|
#define I2Cx_SCL_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
|
||||||
#define UART_RxBufferSize 512
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
#define I2Cx_FORCE_RESET() __I2C1_FORCE_RESET()
|
||||||
#define I2Cx I2C1
|
#define I2Cx_RELEASE_RESET() __I2C1_RELEASE_RESET()
|
||||||
#define I2Cx_CLK_ENABLE() __I2C1_CLK_ENABLE()
|
/*---------------------------------------------------------------------------*/
|
||||||
#define I2Cx_SDA_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
|
/* Definition for I2Cx Pins */
|
||||||
#define I2Cx_SCL_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
|
#define I2Cx_SCL_PIN GPIO_PIN_8
|
||||||
/*---------------------------------------------------------------------------*/
|
#define I2Cx_SCL_GPIO_PORT GPIOB
|
||||||
#define I2Cx_FORCE_RESET() __I2C1_FORCE_RESET()
|
#define I2Cx_SDA_PIN GPIO_PIN_9
|
||||||
#define I2Cx_RELEASE_RESET() __I2C1_RELEASE_RESET()
|
#define I2Cx_SDA_GPIO_PORT GPIOB
|
||||||
/*---------------------------------------------------------------------------*/
|
#define I2Cx_SCL_SDA_AF GPIO_AF4_I2C1
|
||||||
/* Definition for I2Cx Pins */
|
|
||||||
#define I2Cx_SCL_PIN GPIO_PIN_8
|
/* Definition for I2Cx's NVIC */
|
||||||
#define I2Cx_SCL_GPIO_PORT GPIOB
|
#define I2Cx_EV_IRQn I2C1_EV_IRQn
|
||||||
#define I2Cx_SDA_PIN GPIO_PIN_9
|
#define I2Cx_ER_IRQn I2C1_ER_IRQn
|
||||||
#define I2Cx_SDA_GPIO_PORT GPIOB
|
#define I2Cx_EV_IRQHandler I2C1_EV_IRQHandler
|
||||||
#define I2Cx_SCL_SDA_AF GPIO_AF4_I2C1
|
#define I2Cx_ER_IRQHandler I2C1_ER_IRQHandler
|
||||||
|
|
||||||
/* Definition for I2Cx's NVIC */
|
#define I2Cx I2C1
|
||||||
#define I2Cx_EV_IRQn I2C1_EV_IRQn
|
#define I2Cx_CLK_ENABLE() __I2C1_CLK_ENABLE()
|
||||||
#define I2Cx_ER_IRQn I2C1_ER_IRQn
|
#define I2Cx_SDA_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
|
||||||
#define I2Cx_EV_IRQHandler I2C1_EV_IRQHandler
|
#define I2Cx_SCL_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
|
||||||
#define I2Cx_ER_IRQHandler I2C1_ER_IRQHandler
|
|
||||||
|
#define I2Cx_FORCE_RESET() __I2C1_FORCE_RESET()
|
||||||
|
#define I2Cx_RELEASE_RESET() __I2C1_RELEASE_RESET()
|
||||||
#define I2Cx I2C1
|
|
||||||
#define I2Cx_CLK_ENABLE() __I2C1_CLK_ENABLE()
|
/* Definition for I2Cx Pins */
|
||||||
#define I2Cx_SDA_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
|
#define I2Cx_SCL_PIN GPIO_PIN_8
|
||||||
#define I2Cx_SCL_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
|
#define I2Cx_SCL_GPIO_PORT GPIOB
|
||||||
|
#define I2Cx_SDA_PIN GPIO_PIN_9
|
||||||
#define I2Cx_FORCE_RESET() __I2C1_FORCE_RESET()
|
#define I2Cx_SDA_GPIO_PORT GPIOB
|
||||||
#define I2Cx_RELEASE_RESET() __I2C1_RELEASE_RESET()
|
#define I2Cx_SCL_SDA_AF GPIO_AF4_I2C1
|
||||||
|
|
||||||
/* Definition for I2Cx Pins */
|
/* Definition for I2Cx's NVIC */
|
||||||
#define I2Cx_SCL_PIN GPIO_PIN_8
|
#define I2Cx_EV_IRQn I2C1_EV_IRQn
|
||||||
#define I2Cx_SCL_GPIO_PORT GPIOB
|
#define I2Cx_ER_IRQn I2C1_ER_IRQn
|
||||||
#define I2Cx_SDA_PIN GPIO_PIN_9
|
#define I2Cx_EV_IRQHandler I2C1_EV_IRQHandler
|
||||||
#define I2Cx_SDA_GPIO_PORT GPIOB
|
#define I2Cx_ER_IRQHandler I2C1_ER_IRQHandler
|
||||||
#define I2Cx_SCL_SDA_AF GPIO_AF4_I2C1
|
|
||||||
|
/* User can use this section to tailor USARTx/UARTx instance used and associated
|
||||||
/* Definition for I2Cx's NVIC */
|
resources */
|
||||||
#define I2Cx_EV_IRQn I2C1_EV_IRQn
|
/* Definition for USARTx clock resources */
|
||||||
#define I2Cx_ER_IRQn I2C1_ER_IRQn
|
#define USARTx USART2
|
||||||
#define I2Cx_EV_IRQHandler I2C1_EV_IRQHandler
|
#define USARTx_CLK_ENABLE() __USART2_CLK_ENABLE();
|
||||||
#define I2Cx_ER_IRQHandler I2C1_ER_IRQHandler
|
#define DMAx_CLK_ENABLE() __DMA1_CLK_ENABLE()
|
||||||
|
#define USARTx_RX_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
|
||||||
/* User can use this section to tailor USARTx/UARTx instance used and associated
|
#define USARTx_TX_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
|
||||||
resources */
|
|
||||||
/* Definition for USARTx clock resources */
|
#define USARTx_FORCE_RESET() __USART2_FORCE_RESET()
|
||||||
#define USARTx USART2
|
#define USARTx_RELEASE_RESET() __USART2_RELEASE_RESET()
|
||||||
#define USARTx_CLK_ENABLE() __USART2_CLK_ENABLE();
|
|
||||||
#define DMAx_CLK_ENABLE() __DMA1_CLK_ENABLE()
|
/* Definition for USARTx Pins */
|
||||||
#define USARTx_RX_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
|
#define USARTx_TX_PIN GPIO_PIN_2
|
||||||
#define USARTx_TX_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
|
#define USARTx_TX_GPIO_PORT GPIOA
|
||||||
|
|
||||||
#define USARTx_FORCE_RESET() __USART2_FORCE_RESET()
|
#define USARTx_RX_PIN GPIO_PIN_3
|
||||||
#define USARTx_RELEASE_RESET() __USART2_RELEASE_RESET()
|
#define USARTx_RX_GPIO_PORT GPIOA
|
||||||
|
|
||||||
/* Definition for USARTx Pins */
|
/* Definition for USARTx's NVIC */
|
||||||
#define USARTx_TX_PIN GPIO_PIN_2
|
#define USARTx_IRQn USART2_IRQn
|
||||||
#define USARTx_TX_GPIO_PORT GPIOA
|
#define USARTx_IRQHandler USART2_IRQHandler
|
||||||
|
|
||||||
#define USARTx_RX_PIN GPIO_PIN_3
|
#define USARTx_TX_AF GPIO_AF7_USART2
|
||||||
#define USARTx_RX_GPIO_PORT GPIOA
|
#define USARTx_RX_AF GPIO_AF7_USART2
|
||||||
|
|
||||||
/* Definition for USARTx's NVIC */
|
/* Enable sensor mask */
|
||||||
#define USARTx_IRQn USART2_IRQn
|
#define PRESSURE_SENSOR 0x00000001
|
||||||
#define USARTx_IRQHandler USART2_IRQHandler
|
#define TEMPERATURE_SENSOR 0x00000002
|
||||||
|
#define HUMIDITY_SENSOR 0x00000004
|
||||||
#define USARTx_TX_AF GPIO_AF7_USART2
|
#define UV_SENSOR 0x00000008
|
||||||
#define USARTx_RX_AF GPIO_AF7_USART2
|
#define ACCELEROMETER_SENSOR 0x00000010
|
||||||
|
#define GYROSCOPE_SENSOR 0x00000020
|
||||||
|
#define MAGNETIC_SENSOR 0x00000040
|
||||||
/* Enable sensor mask */
|
/*---------------------------------------------------------------------------*/
|
||||||
#define PRESSURE_SENSOR 0x00000001
|
#endif /*__HW_CONFIG_H*/
|
||||||
#define TEMPERATURE_SENSOR 0x00000002
|
/*---------------------------------------------------------------------------*/
|
||||||
#define HUMIDITY_SENSOR 0x00000004
|
|
||||||
#define UV_SENSOR 0x00000008
|
|
||||||
#define ACCELEROMETER_SENSOR 0x00000010
|
|
||||||
#define GYROSCOPE_SENSOR 0x00000020
|
|
||||||
#define MAGNETIC_SENSOR 0x00000040
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
#endif /*__HW_CONFIG_H*/
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
|
|
|
@ -1,60 +1,55 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file platform/stm32nucleo-spirit1/node-id.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Source file for node Id
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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
|
#include "node-id.h"
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
#include "contiki-conf.h"
|
||||||
*
|
#include <string.h>
|
||||||
******************************************************************************
|
/*---------------------------------------------------------------------------*/
|
||||||
*/
|
unsigned short node_id = 0;
|
||||||
/*---------------------------------------------------------------------------*/
|
unsigned char node_mac[8];
|
||||||
#include "node-id.h"
|
volatile uint32_t device_id[3];
|
||||||
#include "contiki-conf.h"
|
/*---------------------------------------------------------------------------*/
|
||||||
#include <string.h>
|
#define DEVICE_ID_REG0 (*((volatile uint32_t *)0x1FF80050))
|
||||||
/*---------------------------------------------------------------------------*/
|
#define DEVICE_ID_REG1 (*((volatile uint32_t *)0x1FF80054))
|
||||||
unsigned short node_id = 0;
|
#define DEVICE_ID_REG2 (*((volatile uint32_t *)0x1FF80064))
|
||||||
unsigned char node_mac[8];
|
/*---------------------------------------------------------------------------*/
|
||||||
volatile uint32_t device_id[3];
|
void
|
||||||
/*---------------------------------------------------------------------------*/
|
node_id_restore(void)
|
||||||
#define DEVICE_ID_REG0 (*((volatile uint32_t *) 0x1FF80050))
|
{
|
||||||
#define DEVICE_ID_REG1 (*((volatile uint32_t *) 0x1FF80054))
|
device_id[0] = DEVICE_ID_REG0;
|
||||||
#define DEVICE_ID_REG2 (*((volatile uint32_t *) 0x1FF80064))
|
device_id[1] = DEVICE_ID_REG1;
|
||||||
/*---------------------------------------------------------------------------*/
|
device_id[2] = DEVICE_ID_REG2;
|
||||||
void node_id_restore(void)
|
|
||||||
{
|
(*(uint32_t *)node_mac) = DEVICE_ID_REG1;
|
||||||
device_id[0] = DEVICE_ID_REG0;
|
(*(((uint32_t *)node_mac) + 1)) = DEVICE_ID_REG2 + DEVICE_ID_REG0;
|
||||||
device_id[1] = DEVICE_ID_REG1;
|
node_id = (unsigned short)DEVICE_ID_REG2;
|
||||||
device_id[2] = DEVICE_ID_REG2;
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
(*(uint32_t*)node_mac)=DEVICE_ID_REG1;
|
|
||||||
(*(((uint32_t*)node_mac)+1))=DEVICE_ID_REG2+DEVICE_ID_REG0;
|
|
||||||
node_id = (unsigned short) DEVICE_ID_REG2;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
|
|
|
@ -1,115 +1,109 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file platform/stm32nucleo-spirit1/platform-conf.h
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-May-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Configuration parameters
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
* \addtogroup stm32nucleo-spirit1
|
||||||
*
|
* @{
|
||||||
******************************************************************************
|
*
|
||||||
*/
|
* \defgroup stm32nucleo-spirit1-peripherals User Button on STM32 Nucleo
|
||||||
/*---------------------------------------------------------------------------*/
|
*
|
||||||
/**
|
* Defines some of the platforms capabilities
|
||||||
* \addtogroup stm32nucleo-spirit1
|
* @{
|
||||||
* @{
|
*
|
||||||
*
|
* \file
|
||||||
* \defgroup stm32nucleo-spirit1-peripherals User Button on STM32 Nucleo
|
* Header file for the stm32nucleo-spirit1 platform configuration
|
||||||
*
|
*/
|
||||||
* Defines some of the platforms capabilities
|
/*---------------------------------------------------------------------------*/
|
||||||
* @{
|
#ifndef __PLATFORM_CONF_H__
|
||||||
*
|
#define __PLATFORM_CONF_H__
|
||||||
* \file
|
/*---------------------------------------------------------------------------*/
|
||||||
* Header file for the stm32nucleo-spirit1 platform configuration
|
#include <inttypes.h>
|
||||||
*/
|
#include <string.h>
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#ifndef __PLATFORM_CONF_H__
|
#define PLATFORM_HAS_LEDS 1
|
||||||
#define __PLATFORM_CONF_H__
|
#define PLATFORM_HAS_BUTTON 1
|
||||||
/*---------------------------------------------------------------------------*/
|
#define PLATFORM_HAS_RADIO 1
|
||||||
#include <inttypes.h>
|
|
||||||
#include <string.h>
|
#define LEDS_GREEN 1 /*Nucleo LED*/
|
||||||
/*---------------------------------------------------------------------------*/
|
#define LEDS_RED 2 /*SPIRIT1 LED*/
|
||||||
#define PLATFORM_HAS_LEDS 1
|
|
||||||
#define PLATFORM_HAS_BUTTON 1
|
#ifdef COMPILE_SENSORS
|
||||||
#define PLATFORM_HAS_RADIO 1
|
#define LEDS_CONF_ALL 1 /*Can't use SPIRIT1 LED in this case*/
|
||||||
|
#else
|
||||||
#define LEDS_GREEN 1 /*Nucleo LED*/
|
#define LEDS_CONF_ALL 3 /*No sensors -> we can use SPIRIT1 LED in this case*/
|
||||||
#define LEDS_RED 2 /*SPIRIT1 LED*/
|
#endif /*COMPILE_SENSORS*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
#ifdef COMPILE_SENSORS
|
#define F_CPU 32000000ul
|
||||||
#define LEDS_CONF_ALL 1 /*Can't use SPIRIT1 LED in this case*/
|
#define RTIMER_ARCH_SECOND 32768
|
||||||
#else
|
#define PRESCALER ((F_CPU / (RTIMER_ARCH_SECOND * 2)))
|
||||||
#define LEDS_CONF_ALL 3 /*No sensors -> we can use SPIRIT1 LED in this case*/
|
|
||||||
#endif /*COMPILE_SENSORS*/
|
#define UART1_CONF_TX_WITH_INTERRUPT 0
|
||||||
/*---------------------------------------------------------------------------*/
|
#define WITH_SERIAL_LINE_INPUT 1
|
||||||
#define F_CPU 32000000ul
|
#define TELNETD_CONF_NUMLINES 6
|
||||||
#define RTIMER_ARCH_SECOND 32768
|
#define NETSTACK_CONF_RADIO spirit_radio_driver
|
||||||
#define PRESCALER ((F_CPU / (RTIMER_ARCH_SECOND*2)))
|
#define NETSTACK_RADIO_MAX_PAYLOAD_LEN 96 /* spirit1-config.h */
|
||||||
|
|
||||||
#define UART1_CONF_TX_WITH_INTERRUPT 0
|
/*---------------------------------------------------------------------------*/
|
||||||
#define WITH_SERIAL_LINE_INPUT 1
|
/* define ticks/second for slow and fast clocks. Notice that these should be a
|
||||||
#define TELNETD_CONF_NUMLINES 6
|
power of two, eg 64,128,256,512 etc, for efficiency as POT's can be optimized
|
||||||
#define NETSTACK_CONF_RADIO spirit_radio_driver
|
well. */
|
||||||
#define NETSTACK_RADIO_MAX_PAYLOAD_LEN 96 /* spirit1-config.h */
|
#define CLOCK_CONF_SECOND 128
|
||||||
|
/* One tick: 62.5 ms */
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/* define ticks/second for slow and fast clocks. Notice that these should be a
|
#define RTIMER_CLOCK_LT(a, b) ((signed short)((a) - (b)) < 0)
|
||||||
power of two, eg 64,128,256,512 etc, for efficiency as POT's can be optimized
|
/*---------------------------------------------------------------------------*/
|
||||||
well. */
|
typedef unsigned long clock_time_t;
|
||||||
#define CLOCK_CONF_SECOND 128
|
typedef unsigned long long rtimer_clock_t;
|
||||||
/* One tick: 62.5 ms */
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#define CC_CONF_REGISTER_ARGS 0
|
||||||
#define RTIMER_CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
|
#define CC_CONF_FUNCTION_POINTER_ARGS 1
|
||||||
/*---------------------------------------------------------------------------*/
|
#define CC_CONF_FASTCALL
|
||||||
typedef unsigned long clock_time_t;
|
#define CC_CONF_VA_ARGS 1
|
||||||
typedef unsigned long long rtimer_clock_t;
|
#define CC_CONF_INLINE inline
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
#define CC_CONF_REGISTER_ARGS 0
|
#define CCIF
|
||||||
#define CC_CONF_FUNCTION_POINTER_ARGS 1
|
#define CLIF
|
||||||
#define CC_CONF_FASTCALL
|
/*---------------------------------------------------------------------------*/
|
||||||
#define CC_CONF_VA_ARGS 1
|
typedef uint8_t u8_t;
|
||||||
#define CC_CONF_INLINE inline
|
typedef uint16_t u16_t;
|
||||||
|
typedef uint32_t u32_t;
|
||||||
#define CCIF
|
typedef int32_t s32_t;
|
||||||
#define CLIF
|
typedef unsigned short uip_stats_t;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
typedef uint8_t u8_t;
|
#define MULTICHAN_CONF_SET_CHANNEL(x)
|
||||||
typedef uint16_t u16_t;
|
#define MULTICHAN_CONF_READ_RSSI(x) 0
|
||||||
typedef uint32_t u32_t;
|
/*---------------------------------------------------------------------------*/
|
||||||
typedef int32_t s32_t;
|
#endif /* __PLATFORM_CONF_H__ */
|
||||||
typedef unsigned short uip_stats_t;
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
/**
|
||||||
#define MULTICHAN_CONF_SET_CHANNEL(x)
|
* @}
|
||||||
#define MULTICHAN_CONF_READ_RSSI(x) 0
|
* @}
|
||||||
/*---------------------------------------------------------------------------*/
|
*/
|
||||||
#endif /* __PLATFORM_CONF_H__ */
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
|
@ -1,86 +1,78 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file main.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Source file for SPIRIT1
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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
|
#include "stm32l1xx.h"
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
#include "spirit1-arch.h"
|
||||||
*
|
#include "spirit1.h"
|
||||||
******************************************************************************
|
#include "st-lib.h"
|
||||||
*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
extern void spirit1_interrupt_callback(void);
|
||||||
#include "stm32l1xx.h"
|
st_lib_spirit_bool spiritdk_timer_expired = S_FALSE;
|
||||||
#include "spirit1-arch.h"
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "spirit1.h"
|
/* use the SPI-port to acquire the status bytes from the radio. */
|
||||||
#include "st-lib.h"
|
#define CS_TO_SCLK_DELAY 0x0100
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
extern void spirit1_interrupt_callback(void);
|
extern st_lib_spi_handle_typedef st_lib_p_spi_handle;
|
||||||
st_lib_spirit_bool spiritdk_timer_expired = S_FALSE;
|
/*---------------------------------------------------------------------------*/
|
||||||
/*---------------------------------------------------------------------------*/
|
uint16_t
|
||||||
/* use the SPI-port to acquire the status bytes from the radio. */
|
spirit1_arch_refresh_status(void)
|
||||||
#define CS_TO_SCLK_DELAY 0x0100
|
{
|
||||||
/*---------------------------------------------------------------------------*/
|
volatile uint16_t mcstate = 0x0000;
|
||||||
extern st_lib_spi_handle_typedef st_lib_p_spi_handle;
|
uint8_t header[2];
|
||||||
/*---------------------------------------------------------------------------*/
|
header[0] = 0x01;
|
||||||
uint16_t
|
header[1] = MC_STATE1_BASE;
|
||||||
spirit1_arch_refresh_status(void)
|
uint32_t spi_timeout = ((uint32_t)1000); /*<! Value of Timeout when SPI communication fails */
|
||||||
{
|
|
||||||
volatile uint16_t mcstate = 0x0000;
|
IRQ_DISABLE();
|
||||||
uint8_t header[2];
|
|
||||||
header[0]=0x01;
|
/* Puts the SPI chip select low to start the transaction */
|
||||||
header[1]=MC_STATE1_BASE;
|
st_lib_radio_spi_cs_low();
|
||||||
uint32_t spi_timeout = ((uint32_t)1000); /*<! Value of Timeout when SPI communication fails */
|
|
||||||
|
for(volatile uint16_t index = 0; index < CS_TO_SCLK_DELAY; index++) {
|
||||||
IRQ_DISABLE();
|
}
|
||||||
|
|
||||||
/* Puts the SPI chip select low to start the transaction */
|
/* Write the aHeader bytes and read the SPIRIT1 status bytes */
|
||||||
st_lib_radio_spi_cs_low();
|
st_lib_hal_spi_transmit_receive(&st_lib_p_spi_handle, (uint8_t *)&header[0], (uint8_t *)&mcstate, 1, spi_timeout);
|
||||||
|
mcstate = mcstate << 8;
|
||||||
for (volatile uint16_t index = 0; index < CS_TO_SCLK_DELAY; index++);
|
|
||||||
|
/* Write the aHeader bytes and read the SPIRIT1 status bytes */
|
||||||
/* Write the aHeader bytes and read the SPIRIT1 status bytes */
|
st_lib_hal_spi_transmit_receive(&st_lib_p_spi_handle, (uint8_t *)&header[1], (uint8_t *)&mcstate, 1, spi_timeout);
|
||||||
st_lib_hal_spi_transmit_receive(&st_lib_p_spi_handle, (uint8_t *)&header[0], (uint8_t *)&mcstate, 1, spi_timeout);
|
|
||||||
mcstate = mcstate<<8;
|
/* To be sure to don't rise the Chip Select before the end of last sending */
|
||||||
|
while(st_lib_hal_spi_get_flag(&st_lib_p_spi_handle, SPI_FLAG_TXE) == RESET) ;
|
||||||
/* Write the aHeader bytes and read the SPIRIT1 status bytes */
|
|
||||||
st_lib_hal_spi_transmit_receive(&st_lib_p_spi_handle, (uint8_t *)&header[1], (uint8_t *)&mcstate, 1, spi_timeout);
|
/* Puts the SPI chip select high to end the transaction */
|
||||||
|
st_lib_radio_spi_cs_high();
|
||||||
/* To be sure to don't rise the Chip Select before the end of last sending */
|
|
||||||
while (st_lib_hal_spi_get_flag(&st_lib_p_spi_handle, SPI_FLAG_TXE) == RESET);
|
IRQ_ENABLE();
|
||||||
|
|
||||||
/* Puts the SPI chip select high to end the transaction */
|
return mcstate;
|
||||||
st_lib_radio_spi_cs_high();
|
}
|
||||||
|
|
||||||
IRQ_ENABLE();
|
|
||||||
|
|
||||||
return mcstate;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,49 +1,49 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, STMicroelectronics.
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#ifndef __SPIRIT1_ARCH_H__
|
#ifndef __SPIRIT1_ARCH_H__
|
||||||
#define __SPIRIT1_ARCH_H__
|
#define __SPIRIT1_ARCH_H__
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "SPIRIT_Management.h"
|
#include "SPIRIT_Management.h"
|
||||||
#include "radio_gpio.h"
|
#include "radio_gpio.h"
|
||||||
#include "radio_spi.h"
|
#include "radio_spi.h"
|
||||||
#include "st-lib.h"
|
#include "st-lib.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#define IRQ_ENABLE() st_lib_radio_gpio_interrupt_cmd(RADIO_GPIO_IRQ,0x0F,0x0F,ENABLE);
|
#define IRQ_ENABLE() st_lib_radio_gpio_interrupt_cmd(RADIO_GPIO_IRQ, 0x0F, 0x0F, ENABLE);
|
||||||
#define IRQ_DISABLE() st_lib_radio_gpio_interrupt_cmd(RADIO_GPIO_IRQ,0x0F,0x0F,DISABLE);
|
#define IRQ_DISABLE() st_lib_radio_gpio_interrupt_cmd(RADIO_GPIO_IRQ, 0x0F, 0x0F, DISABLE);
|
||||||
#define spirit_spi_busy() (!(RADIO_SPI_CS_PORT->IDR & RADIO_SPI_CS_PIN))
|
#define spirit_spi_busy() (!(RADIO_SPI_CS_PORT->IDR & RADIO_SPI_CS_PIN))
|
||||||
#define SPIRIT1_STATUS() (spirit1_arch_refresh_status() & SPIRIT1_STATE_STATEBITS)
|
#define SPIRIT1_STATUS() (spirit1_arch_refresh_status() & SPIRIT1_STATE_STATEBITS)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
uint16_t spirit1_arch_refresh_status(void);
|
uint16_t spirit1_arch_refresh_status(void);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#endif /* __SPIRIT1_ARCH_H__ */
|
#endif /* __SPIRIT1_ARCH_H__ */
|
||||||
|
|
|
@ -1,59 +1,59 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, STMicroelectronics.
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#ifndef __SPIRIT1_CONFIG_H__
|
#ifndef __SPIRIT1_CONFIG_H__
|
||||||
#define __SPIRIT1_CONFIG_H__
|
#define __SPIRIT1_CONFIG_H__
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "radio.h"
|
#include "radio.h"
|
||||||
#include "SPIRIT_Config.h"
|
#include "SPIRIT_Config.h"
|
||||||
#include "spirit1-const.h"
|
#include "spirit1-const.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#define CCA_THRESHOLD -98.0 /* dBm */
|
#define CCA_THRESHOLD -98.0 /* dBm */
|
||||||
#define XTAL_FREQUENCY 50000000 /* Hz */
|
#define XTAL_FREQUENCY 50000000 /* Hz */
|
||||||
#define SPIRIT_MAX_FIFO_LEN 96
|
#define SPIRIT_MAX_FIFO_LEN 96
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The MAX_PACKET_LEN is an arbitrary value used to define the two array
|
* The MAX_PACKET_LEN is an arbitrary value used to define the two array
|
||||||
* spirit_txbuf and spirit_rxbuf.
|
* spirit_txbuf and spirit_rxbuf.
|
||||||
* The SPIRIT1 supports with its packet handler a length of 65,535 bytes,
|
* The SPIRIT1 supports with its packet handler a length of 65,535 bytes,
|
||||||
* and in direct mode (without packet handler) there is no limit of data.
|
* and in direct mode (without packet handler) there is no limit of data.
|
||||||
*/
|
*/
|
||||||
#define MAX_PACKET_LEN SPIRIT_MAX_FIFO_LEN
|
#define MAX_PACKET_LEN SPIRIT_MAX_FIFO_LEN
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* Spirit1 IC version
|
* Spirit1 IC version
|
||||||
*/
|
*/
|
||||||
#define SPIRIT1_VERSION SPIRIT_VERSION_3_0
|
#define SPIRIT1_VERSION SPIRIT_VERSION_3_0
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#endif /* __SPIRIT1_CONFIG_H__ */
|
#endif /* __SPIRIT1_CONFIG_H__ */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,65 +1,65 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, STMicroelectronics.
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* contributors may be used to endorse or promote products derived
|
* may be used to endorse or promote products derived from this software
|
||||||
* from this software without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
* SUCH DAMAGE.
|
||||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#ifndef __SPIRIT1_CONST_H__
|
#ifndef __SPIRIT1_CONST_H__
|
||||||
#define __SPIRIT1_CONST_H__
|
#define __SPIRIT1_CONST_H__
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* The state bitfield and values for different states, as read from MC_STATE[1:0] registers,
|
/* The state bitfield and values for different states, as read from MC_STATE[1:0] registers,
|
||||||
which are returned on any SPI read or write operation. */
|
which are returned on any SPI read or write operation. */
|
||||||
#define SPIRIT1_STATE_STATEBITS (0x00FE)
|
#define SPIRIT1_STATE_STATEBITS (0x00FE)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define SPIRIT1_STATE_STANDBY ((0x0040)<<1)
|
#define SPIRIT1_STATE_STANDBY ((0x0040) << 1)
|
||||||
#define SPIRIT1_STATE_SLEEP ((0x0036)<<1)
|
#define SPIRIT1_STATE_SLEEP ((0x0036) << 1)
|
||||||
#define SPIRIT1_STATE_READY ((0x0003)<<1)
|
#define SPIRIT1_STATE_READY ((0x0003) << 1)
|
||||||
#define SPIRIT1_STATE_LOCK ((0x000F)<<1)
|
#define SPIRIT1_STATE_LOCK ((0x000F) << 1)
|
||||||
#define SPIRIT1_STATE_RX ((0x0033)<<1)
|
#define SPIRIT1_STATE_RX ((0x0033) << 1)
|
||||||
#define SPIRIT1_STATE_TX ((0x005F)<<1)
|
#define SPIRIT1_STATE_TX ((0x005F) << 1)
|
||||||
/* NB the below states were extracted from ST drivers, but are not specified in the datasheet */
|
/* NB the below states were extracted from ST drivers, but are not specified in the datasheet */
|
||||||
#define SPIRIT1_STATE_PM_SETUP ((0x003D)<<1)
|
#define SPIRIT1_STATE_PM_SETUP ((0x003D) << 1)
|
||||||
#define SPIRIT1_STATE_XO_SETTLING ((0x0023)<<1)
|
#define SPIRIT1_STATE_XO_SETTLING ((0x0023) << 1)
|
||||||
#define SPIRIT1_STATE_SYNTH_SETUP ((0x0053)<<1)
|
#define SPIRIT1_STATE_SYNTH_SETUP ((0x0053) << 1)
|
||||||
#define SPIRIT1_STATE_PROTOCOL ((0x001F)<<1)
|
#define SPIRIT1_STATE_PROTOCOL ((0x001F) << 1)
|
||||||
#define SPIRIT1_STATE_SYNTH_CALIBRATION ((0x004F)<<1)
|
#define SPIRIT1_STATE_SYNTH_CALIBRATION ((0x004F) << 1)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* strobe commands */
|
/* strobe commands */
|
||||||
#define SPIRIT1_STROBE_TX 0x60
|
#define SPIRIT1_STROBE_TX 0x60
|
||||||
#define SPIRIT1_STROBE_RX 0x61
|
#define SPIRIT1_STROBE_RX 0x61
|
||||||
#define SPIRIT1_STROBE_READY 0x62
|
#define SPIRIT1_STROBE_READY 0x62
|
||||||
#define SPIRIT1_STROBE_STANDBY 0x63
|
#define SPIRIT1_STROBE_STANDBY 0x63
|
||||||
#define SPIRIT1_STROBE_SLEEP 0x64
|
#define SPIRIT1_STROBE_SLEEP 0x64
|
||||||
#define SPIRIT1_STROBE_SABORT 0x67
|
#define SPIRIT1_STROBE_SABORT 0x67
|
||||||
#define SPIRIT1_STROBE_SRES 0x70
|
#define SPIRIT1_STROBE_SRES 0x70
|
||||||
#define SPIRIT1_STROBE_FRX 0x71
|
#define SPIRIT1_STROBE_FRX 0x71
|
||||||
#define SPIRIT1_STROBE_FTX 0x72
|
#define SPIRIT1_STROBE_FTX 0x72
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#endif /* __SPIRIT1_CONST_H__ */
|
#endif /* __SPIRIT1_CONST_H__ */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,46 +1,46 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, STMicroelectronics.
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#ifndef __SPIRIT_H__
|
#ifndef __SPIRIT_H__
|
||||||
#define __SPIRIT_H__
|
#define __SPIRIT_H__
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "radio.h"
|
#include "radio.h"
|
||||||
#include "SPIRIT_Config.h"
|
#include "SPIRIT_Config.h"
|
||||||
#include "spirit1-config.h"
|
#include "spirit1-config.h"
|
||||||
#include "spirit1_appli.h"
|
#include "spirit1_appli.h"
|
||||||
#include "spirit1-const.h"
|
#include "spirit1-const.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
extern const struct radio_driver spirit_radio_driver;
|
extern const struct radio_driver spirit_radio_driver;
|
||||||
void spirit1_interrupt_callback(void);
|
void spirit1_interrupt_callback(void);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#endif /* __SPIRIT_H__ */
|
#endif /* __SPIRIT_H__ */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,39 +1,33 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file st-lib.h
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 30-July-2015
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Contiki style wrapping library for STM32Cube HAL APIs
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* are permitted provided that the following conditions are met:
|
* may be used to endorse or promote products derived from this software
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* without specific prior written permission.
|
||||||
* this list of conditions and the following disclaimer.
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* and/or other materials provided with the distribution.
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* may be used to endorse or promote products derived from this software
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* without specific prior written permission.
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
*
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* SUCH DAMAGE.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \defgroup stm32nucleo-spirit1 STM32Cube HAL APIs
|
* \defgroup stm32nucleo-spirit1 STM32Cube HAL APIs
|
||||||
|
@ -73,7 +67,6 @@
|
||||||
#define st_lib_spirit_spi_write_linear_fifo(...) SpiritSpiWriteLinearFifo(__VA_ARGS__)
|
#define st_lib_spirit_spi_write_linear_fifo(...) SpiritSpiWriteLinearFifo(__VA_ARGS__)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* radio_gpio.h */
|
/* radio_gpio.h */
|
||||||
#include "radio_gpio.h"
|
#include "radio_gpio.h"
|
||||||
|
@ -241,7 +234,6 @@
|
||||||
/* stm32l1xx_hal_rcc.h */
|
/* stm32l1xx_hal_rcc.h */
|
||||||
#include "stm32l1xx_hal_rcc.h"
|
#include "stm32l1xx_hal_rcc.h"
|
||||||
|
|
||||||
|
|
||||||
#define st_lib_tim2_clk_enable(...) __TIM2_CLK_ENABLE(__VA_ARGS__)
|
#define st_lib_tim2_clk_enable(...) __TIM2_CLK_ENABLE(__VA_ARGS__)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -274,7 +266,6 @@
|
||||||
#define st_lib_hal_tim_oc_config_channel(...) HAL_TIM_OC_ConfigChannel(__VA_ARGS__)
|
#define st_lib_hal_tim_oc_config_channel(...) HAL_TIM_OC_ConfigChannel(__VA_ARGS__)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* stm32l1xx_hal_uart.h */
|
/* stm32l1xx_hal_uart.h */
|
||||||
#include "stm32l1xx_hal_uart.h"
|
#include "stm32l1xx_hal_uart.h"
|
||||||
|
|
|
@ -1,98 +1,102 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file stm32l-spirit1-config.h
|
* All rights reserved.
|
||||||
* @author MCD Application Team
|
*
|
||||||
* @version V3.4.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 29-June-2012
|
* modification, are permitted provided that the following conditions
|
||||||
* @brief Evaluation board specific configuration file.
|
* are met:
|
||||||
******************************************************************************
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* @attention
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
*
|
* documentation and/or other materials provided with the distribution.
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* You may not use this file except in compliance with the License.
|
* may be used to endorse or promote products derived from this software
|
||||||
* You may obtain a copy of the License at:
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
*
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* See the License for the specific language governing permissions and
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* limitations under the License.
|
* 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.
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
*
|
||||||
#ifndef __STM32L_SPIRIT1_CONFIG_H
|
*
|
||||||
#define __STM32L_SPIRIT1_CONFIG_H
|
*/
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __STM32L_SPIRIT1_CONFIG_H
|
||||||
/* Exported types ------------------------------------------------------------*/
|
#define __STM32L_SPIRIT1_CONFIG_H
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
/* Define the STM32F10x hardware depending on the used evaluation board */
|
|
||||||
#ifdef USE_STM3210B_EVAL
|
/* Exported types ------------------------------------------------------------*/
|
||||||
#define USB_DISCONNECT GPIOD
|
/* Exported constants --------------------------------------------------------*/
|
||||||
#define USB_DISCONNECT_PIN GPIO_PIN_9
|
|
||||||
#define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOD
|
/* Define the STM32F10x hardware depending on the used evaluation board */
|
||||||
#define EVAL_COM1_IRQHandler USART1_IRQHandler
|
#ifdef USE_STM3210B_EVAL
|
||||||
|
#define USB_DISCONNECT GPIOD
|
||||||
#elif defined (USE_STM3210E_EVAL)
|
#define USB_DISCONNECT_PIN GPIO_PIN_9
|
||||||
#define USB_DISCONNECT GPIOB
|
#define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOD
|
||||||
#define USB_DISCONNECT_PIN GPIO_PIN_14
|
#define EVAL_COM1_IRQHandler USART1_IRQHandler
|
||||||
#define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOB
|
|
||||||
#define EVAL_COM1_IRQHandler USART1_IRQHandler
|
#elif defined(USE_STM3210E_EVAL)
|
||||||
|
#define USB_DISCONNECT GPIOB
|
||||||
#elif defined (USE_STM3210C_EVAL)
|
#define USB_DISCONNECT_PIN GPIO_PIN_14
|
||||||
#define USB_DISCONNECT 0
|
#define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOB
|
||||||
#define USB_DISCONNECT_PIN 0
|
#define EVAL_COM1_IRQHandler USART1_IRQHandler
|
||||||
#define RCC_APB2Periph_GPIO_DISCONNECT 0
|
|
||||||
#define EVAL_COM1_IRQHandler USART2_IRQHandler
|
#elif defined(USE_STM3210C_EVAL)
|
||||||
|
#define USB_DISCONNECT 0
|
||||||
#elif defined (USE_STM32L152_EVAL) || defined (USE_STM32L152D_EVAL)
|
#define USB_DISCONNECT_PIN 0
|
||||||
/*
|
#define RCC_APB2Periph_GPIO_DISCONNECT 0
|
||||||
For STM32L15xx devices it is possible to use the internal USB pullup
|
#define EVAL_COM1_IRQHandler USART2_IRQHandler
|
||||||
controlled by register SYSCFG_PMC (refer to RM0038 reference manual for
|
|
||||||
more details).
|
#elif defined(USE_STM32L152_EVAL) || defined(USE_STM32L152D_EVAL)
|
||||||
It is also possible to use external pullup (and disable the internal pullup)
|
/*
|
||||||
by setting the define USB_USE_EXTERNAL_PULLUP in file platform_config.h
|
For STM32L15xx devices it is possible to use the internal USB pullup
|
||||||
and configuring the right pin to be used for the external pull up configuration.
|
controlled by register SYSCFG_PMC (refer to RM0038 reference manual for
|
||||||
To have more details on how to use an external pull up, please refer to
|
more details).
|
||||||
STM3210E-EVAL evaluation board manuals.
|
It is also possible to use external pullup (and disable the internal pullup)
|
||||||
*/
|
by setting the define USB_USE_EXTERNAL_PULLUP in file platform_config.h
|
||||||
/* Uncomment the following define to use an external pull up instead of the
|
and configuring the right pin to be used for the external pull up configuration.
|
||||||
integrated STM32L15xx internal pull up. In this case make sure to set up
|
To have more details on how to use an external pull up, please refer to
|
||||||
correctly the external required hardware and the GPIO defines below.*/
|
STM3210E-EVAL evaluation board manuals.
|
||||||
/* #define USB_USE_EXTERNAL_PULLUP */
|
*/
|
||||||
|
/* Uncomment the following define to use an external pull up instead of the
|
||||||
#if !defined(USB_USE_EXTERNAL_PULLUP)
|
integrated STM32L15xx internal pull up. In this case make sure to set up
|
||||||
#define STM32L15_USB_CONNECT SYSCFG_USBPuCmd(ENABLE)
|
correctly the external required hardware and the GPIO defines below.*/
|
||||||
#define STM32L15_USB_DISCONNECT SYSCFG_USBPuCmd(DISABLE)
|
/* #define USB_USE_EXTERNAL_PULLUP */
|
||||||
|
|
||||||
#elif defined(USB_USE_EXTERNAL_PULLUP)
|
#if !defined(USB_USE_EXTERNAL_PULLUP)
|
||||||
/* PA0 is chosen just as illustrating example, you should modify the defines
|
#define STM32L15_USB_CONNECT SYSCFG_USBPuCmd(ENABLE)
|
||||||
below according to your hardware configuration. */
|
#define STM32L15_USB_DISCONNECT SYSCFG_USBPuCmd(DISABLE)
|
||||||
#define USB_DISCONNECT GPIOA
|
|
||||||
#define USB_DISCONNECT_PIN GPIO_PIN_0
|
#elif defined(USB_USE_EXTERNAL_PULLUP)
|
||||||
#define RCC_AHBPeriph_GPIO_DISCONNECT RCC_AHBPeriph_GPIOA
|
/* PA0 is chosen just as illustrating example, you should modify the defines
|
||||||
#define STM32L15_USB_CONNECT GPIO_ResetBits(USB_DISCONNECT, USB_DISCONNECT_PIN)
|
below according to your hardware configuration. */
|
||||||
#define STM32L15_USB_DISCONNECT GPIO_SetBits(USB_DISCONNECT, USB_DISCONNECT_PIN)
|
#define USB_DISCONNECT GPIOA
|
||||||
#endif /* USB_USE_EXTERNAL_PULLUP */
|
#define USB_DISCONNECT_PIN GPIO_PIN_0
|
||||||
|
#define RCC_AHBPeriph_GPIO_DISCONNECT RCC_AHBPeriph_GPIOA
|
||||||
#ifdef USE_STM32L152_EVAL
|
#define STM32L15_USB_CONNECT GPIO_ResetBits(USB_DISCONNECT, USB_DISCONNECT_PIN)
|
||||||
#define EVAL_COM1_IRQHandler USART2_IRQHandler
|
#define STM32L15_USB_DISCONNECT GPIO_SetBits(USB_DISCONNECT, USB_DISCONNECT_PIN)
|
||||||
#elif defined (USE_STM32L152D_EVAL)
|
#endif /* USB_USE_EXTERNAL_PULLUP */
|
||||||
#define EVAL_COM1_IRQHandler USART1_IRQHandler
|
|
||||||
#endif /*USE_STM32L152_EVAL*/
|
#ifdef USE_STM32L152_EVAL
|
||||||
|
#define EVAL_COM1_IRQHandler USART2_IRQHandler
|
||||||
#endif /* USE_STM3210B_EVAL */
|
#elif defined(USE_STM32L152D_EVAL)
|
||||||
|
#define EVAL_COM1_IRQHandler USART1_IRQHandler
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
#endif /*USE_STM32L152_EVAL*/
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
|
#endif /* USE_STM3210B_EVAL */
|
||||||
#endif /* __STM32L_SPIRIT1_CONFIG_H */
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
|
||||||
|
#endif /* __STM32L_SPIRIT1_CONFIG_H */
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
|
|
|
@ -1,93 +1,90 @@
|
||||||
/**
|
/*
|
||||||
******************************************************************************
|
* Copyright (c) 2012, STMicroelectronics.
|
||||||
* @file uart-msg.c
|
* All rights reserved.
|
||||||
* @author System LAB
|
*
|
||||||
* @version V1.0.0
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* @date 17-June-2015
|
* modification, are permitted provided that the following conditions
|
||||||
******************************************************************************
|
* are met:
|
||||||
* @attention
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
*
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
*
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* documentation and/or other materials provided with the distribution.
|
||||||
* are permitted provided that the following conditions are met:
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* may be used to endorse or promote products derived from this software
|
||||||
* this list of conditions and the following disclaimer.
|
* without specific prior written permission.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
*
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* and/or other materials provided with the distribution.
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* may be used to endorse or promote products derived from this software
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* without specific prior written permission.
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
*
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* SUCH DAMAGE.
|
||||||
* 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 "contiki.h"
|
||||||
*
|
#include "dev/leds.h"
|
||||||
******************************************************************************
|
#include "stm32l1xx_nucleo.h"
|
||||||
*/
|
#include "platform-conf.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
#include <stdio.h>
|
||||||
#include "contiki.h"
|
#include "dev/slip.h"
|
||||||
#include "dev/leds.h"
|
#include "hw-config.h"
|
||||||
#include "stm32l1xx_nucleo.h"
|
#include "stm32l1xx_hal.h"
|
||||||
#include "platform-conf.h"
|
#include "st-lib.h"
|
||||||
#include <stdio.h>
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "dev/slip.h"
|
void uart_send_msg(char *);
|
||||||
#include "hw-config.h"
|
extern st_lib_uart_handle_typedef st_lib_uart_handle;
|
||||||
#include "stm32l1xx_hal.h"
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "st-lib.h"
|
static unsigned char databyte[1] = { 0 };
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void uart_send_msg(char *);
|
/**
|
||||||
extern st_lib_uart_handle_typedef st_lib_uart_handle;
|
* @brief Rx Transfer completed callbacks.
|
||||||
/*---------------------------------------------------------------------------*/
|
* @param huart: Pointer to a st_lib_uart_handle_typedef structure that contains
|
||||||
static unsigned char databyte[1] = {0};
|
* the configuration information for the specified UART module.
|
||||||
/*---------------------------------------------------------------------------*/
|
* @retval None
|
||||||
/**
|
*/
|
||||||
* @brief Rx Transfer completed callbacks.
|
void
|
||||||
* @param huart: Pointer to a st_lib_uart_handle_typedef structure that contains
|
st_lib_hal_uart_rx_cplt_callback(st_lib_uart_handle_typedef *huart)
|
||||||
* the configuration information for the specified UART module.
|
{
|
||||||
* @retval None
|
slip_input_byte(databyte[0]);
|
||||||
*/
|
st_lib_hal_uart_receive_it(&st_lib_uart_handle, databyte, 1);
|
||||||
void st_lib_hal_uart_rx_cplt_callback(st_lib_uart_handle_typedef *huart)
|
}
|
||||||
{
|
/*---------------------------------------------------------------------------*/
|
||||||
slip_input_byte(databyte[0]);
|
void
|
||||||
st_lib_hal_uart_receive_it(&st_lib_uart_handle, databyte, 1);
|
uart1_set_input(int (*input)(unsigned char c))
|
||||||
}
|
{
|
||||||
/*---------------------------------------------------------------------------*/
|
st_lib_hal_uart_receive_it(&st_lib_uart_handle, databyte, 1);
|
||||||
void
|
}
|
||||||
uart1_set_input(int (*input) (unsigned char c))
|
/*--------------------------------------------------------------------------*/
|
||||||
{
|
void
|
||||||
st_lib_hal_uart_receive_it(&st_lib_uart_handle, databyte, 1);
|
slip_arch_init(unsigned long ubr)
|
||||||
}
|
{
|
||||||
/*--------------------------------------------------------------------------*/
|
st_lib_hal_uart_enable_it(&st_lib_uart_handle, UART_IT_RXNE);
|
||||||
void
|
/* uart1_set_input(slip_input_byte); */
|
||||||
slip_arch_init(unsigned long ubr)
|
}
|
||||||
{
|
/*--------------------------------------------------------------------------*/
|
||||||
st_lib_hal_uart_enable_it(&st_lib_uart_handle, UART_IT_RXNE);
|
void
|
||||||
//uart1_set_input(slip_input_byte);
|
slip_arch_writeb(unsigned char c)
|
||||||
}
|
{
|
||||||
/*--------------------------------------------------------------------------*/
|
uart_send_msg(&c);
|
||||||
void
|
}
|
||||||
slip_arch_writeb(unsigned char c)
|
/*--------------------------------------------------------------------------*/
|
||||||
{
|
|
||||||
uart_send_msg(&c);
|
/**
|
||||||
}
|
* @brief Send a message via UART
|
||||||
/*--------------------------------------------------------------------------*/
|
* @param msg the pointer to the message to be sent
|
||||||
|
* @retval None
|
||||||
/**
|
*/
|
||||||
* @brief Send a message via UART
|
void
|
||||||
* @param msg the pointer to the message to be sent
|
uart_send_msg(char *msg)
|
||||||
* @retval None
|
{
|
||||||
*/
|
st_lib_hal_uart_transmit(&st_lib_uart_handle, (uint8_t *)msg, 1, 5000);
|
||||||
void uart_send_msg(char *msg)
|
}
|
||||||
{
|
/*--------------------------------------------------------------------------*/
|
||||||
st_lib_hal_uart_transmit(&st_lib_uart_handle, (uint8_t*)msg, 1, 5000);
|
|
||||||
}
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
Loading…
Reference in a new issue