Stair56E UART project

This commit is contained in:
2026-08-05 19:07:52 +08:00
parent 7ca1af130d
commit f5654b70cc
2500 changed files with 619007 additions and 282610 deletions
+62 -62
View File
@@ -1,62 +1,62 @@
/**
****************************************************************************************
*
* @file co_bt.h
*
* @brief This file contains the common Bluetooth defines, enumerations and structures
* definitions for use by all modules in RW stack.
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef CO_BT_H_
#define CO_BT_H_
/**
****************************************************************************************
* @addtogroup COMMON Common SW Block
* @ingroup ROOT
* @brief The Common RW SW Block.
*
* The COMMON is the block with Bluetooth definitions and structures shared
* to all the protocol stack blocks. This also contain software wide error code
* definitions, mathematical functions, help functions, list and buffer definitions.
*
* @{
****************************************************************************************
*/
/**
****************************************************************************************
* @addtogroup CO_BT Common Bluetooth defines
* @ingroup COMMON
* @brief Common Bluetooth definitions and structures.
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdbool.h> // standard boolean definitions
#include <stddef.h> // standard definitions
#include <stdint.h> // standard integer definitions
/*
* DEFINES
****************************************************************************************
*/
#include "co_bt_defines.h" // Bluetooth defines
#include "co_lmp.h" // Bluetooth LMP definitions
#include "co_hci.h" // Bluetooth HCI definitions
#include "co_error.h" // Bluetooth error codes definitions
/// @} CO_BT
#endif // CO_BT_H_
/**
****************************************************************************************
*
* @file co_bt.h
*
* @brief This file contains the common Bluetooth defines, enumerations and structures
* definitions for use by all modules in RW stack.
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef CO_BT_H_
#define CO_BT_H_
/**
****************************************************************************************
* @addtogroup COMMON Common SW Block
* @ingroup ROOT
* @brief The Common RW SW Block.
*
* The COMMON is the block with Bluetooth definitions and structures shared
* to all the protocol stack blocks. This also contain software wide error code
* definitions, mathematical functions, help functions, list and buffer definitions.
*
* @{
****************************************************************************************
*/
/**
****************************************************************************************
* @addtogroup CO_BT Common Bluetooth defines
* @ingroup COMMON
* @brief Common Bluetooth definitions and structures.
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdbool.h> // standard boolean definitions
#include <stddef.h> // standard definitions
#include <stdint.h> // standard integer definitions
/*
* DEFINES
****************************************************************************************
*/
#include "co_bt_defines.h" // Bluetooth defines
#include "co_lmp.h" // Bluetooth LMP definitions
#include "co_hci.h" // Bluetooth HCI definitions
#include "co_error.h" // Bluetooth error codes definitions
/// @} CO_BT
#endif // CO_BT_H_
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+134 -134
View File
@@ -1,134 +1,134 @@
/**
****************************************************************************************
*
* @file co_djob.h
*
* @brief Common delayed job definitions
*
* Copyright (C) RivieraWaves 2009-2019
*
****************************************************************************************
*/
#ifndef _CO_DJOB_H_
#define _CO_DJOB_H_
/**
****************************************************************************************
* @defgroup CO_DJOB Utilities
* @ingroup COMMON
* @brief Delayed job utilities
*
* This module contains the delayed job utilities functions and macros.
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // standard definitions
#include <stddef.h> // standard definitions
#include "co_list.h" // common bt definitions
/*
* MACRO DEFINITIONS
****************************************************************************************
*/
/*
* ENUMERATIONS DEFINITIONS
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Job function to called into a background context
*
* @param[in] p_env Pointer to environment that will be used as callback parameter.
****************************************************************************************
*/
typedef void (*co_djob_cb)(void* p_env);
/// Job element structure
typedef struct co_djob
{
/// List element header
co_list_hdr_t hdr;
/// Pointer to environment that will be used as callback parameter.
void* p_env;
/// Callback to execute in background context
co_djob_cb cb;
} co_djob_t;
/*
* CONSTANT DECLARATIONS
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/*
****************************************************************************************
* Delayed Job functions
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Prepare Delayed job structure
*
* @param[in] p_djob Pointer to the delayed job structure
* @param[in] cb Callback to execute in background context
* @param[in] p_env Pointer to environment that will be used as callback parameter.
****************************************************************************************
*/
void co_djob_prepare(co_djob_t* p_djob, co_djob_cb cb, void* p_env);
/**
****************************************************************************************
* @brief Register to execute a job delayed in background
*
* @param[in] p_djob Pointer to the delayed job structure
****************************************************************************************
*/
void co_djob_reg(co_djob_t* p_djob);
/**
****************************************************************************************
* @brief Un-register a job that waits to be executed
*
* @param[in] p_djob Pointer to the delayed job structure
****************************************************************************************
*/
void co_djob_unreg(co_djob_t* p_djob);
/**
****************************************************************************************
* @brief Initialize Common delayed job module.
*
* @param[in] init_type Type of initialization (@see enum rwip_init_type)
****************************************************************************************
*/
void co_djob_init(uint8_t init_type);
/// @} CO_DJOB
#endif // _CO_DJOB_H_
/**
****************************************************************************************
*
* @file co_djob.h
*
* @brief Common delayed job definitions
*
* Copyright (C) RivieraWaves 2009-2019
*
****************************************************************************************
*/
#ifndef _CO_DJOB_H_
#define _CO_DJOB_H_
/**
****************************************************************************************
* @defgroup CO_DJOB Utilities
* @ingroup COMMON
* @brief Delayed job utilities
*
* This module contains the delayed job utilities functions and macros.
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // standard definitions
#include <stddef.h> // standard definitions
#include "co_list.h" // common bt definitions
/*
* MACRO DEFINITIONS
****************************************************************************************
*/
/*
* ENUMERATIONS DEFINITIONS
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Job function to called into a background context
*
* @param[in] p_env Pointer to environment that will be used as callback parameter.
****************************************************************************************
*/
typedef void (*co_djob_cb)(void* p_env);
/// Job element structure
typedef struct co_djob
{
/// List element header
co_list_hdr_t hdr;
/// Pointer to environment that will be used as callback parameter.
void* p_env;
/// Callback to execute in background context
co_djob_cb cb;
} co_djob_t;
/*
* CONSTANT DECLARATIONS
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/*
****************************************************************************************
* Delayed Job functions
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Prepare Delayed job structure
*
* @param[in] p_djob Pointer to the delayed job structure
* @param[in] cb Callback to execute in background context
* @param[in] p_env Pointer to environment that will be used as callback parameter.
****************************************************************************************
*/
void co_djob_prepare(co_djob_t* p_djob, co_djob_cb cb, void* p_env);
/**
****************************************************************************************
* @brief Register to execute a job delayed in background
*
* @param[in] p_djob Pointer to the delayed job structure
****************************************************************************************
*/
void co_djob_reg(co_djob_t* p_djob);
/**
****************************************************************************************
* @brief Un-register a job that waits to be executed
*
* @param[in] p_djob Pointer to the delayed job structure
****************************************************************************************
*/
void co_djob_unreg(co_djob_t* p_djob);
/**
****************************************************************************************
* @brief Initialize Common delayed job module.
*
* @param[in] init_type Type of initialization (@see enum rwip_init_type)
****************************************************************************************
*/
void co_djob_init(uint8_t init_type);
/// @} CO_DJOB
#endif // _CO_DJOB_H_
+349 -349
View File
@@ -1,349 +1,349 @@
/**
****************************************************************************************
*
* @file co_endian.h
*
* @brief Common endianness conversion functions
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef _CO_ENDIAN_H_
#define _CO_ENDIAN_H_
#include <stdint.h> // standard integer definitions
#include "rwip_config.h" // stack configuration
#include "arch.h" // architectural platform definition
/**
****************************************************************************************
* @defgroup CO_ENDIAN Endianness
* @ingroup COMMON
* @brief Endianness conversion functions.
*
* This set of functions converts values between the local system
* and a external one. It is inspired from the <tt>htonl</tt>-like functions
* from the standard C library.
*
* Example:
* @code
* struct eth_header *header = get_header(); // get pointer on Eth II packet header
* uint16_t eth_id; // will contain the type of the packet
* eth_id = co_ntohs(header->eth_id); // retrieve the type with correct endianness
* @endcode
*
* @{
* ****************************************************************************************
* */
/**
****************************************************************************************
* @brief Swap bytes of an array of bytes
* .
* The swap is done in every case. Should not be called directly.
*
* @param[in] p_val_out The output value.
* @param[in] p_val_in The input value.
*
* @param[in] len number of bytes to swap
****************************************************************************************
*/
__INLINE void co_bswap(uint8_t* p_val_out, const uint8_t* p_val_in, uint16_t len)
{
while (len > 0)
{
len--;
*p_val_out = p_val_in[len];
p_val_out++;
}
}
/// @} CO_ENDIAN
/**
****************************************************************************************
* @brief Swap bytes of a 32 bits value.
* The swap is done in every case. Should not be called directly.
* @param[in] val32 The 32 bits value to swap.
* @return The 32 bit swapped value.
****************************************************************************************
*/
__INLINE uint32_t co_bswap32(uint32_t val32)
{
return (val32<<24) | ((val32<<8)&0xFF0000) | ((val32>>8)&0xFF00) | ((val32>>24)&0xFF);
}
/**
****************************************************************************************
* @brief Swap bytes of a 24 bits value.
* The swap is done in every case. Should not be called directly.
* @param[in] val24 The 24 bits value to swap.
* @return The 24 bit swapped value.
****************************************************************************************
*/
__INLINE uint32_t co_bswap24(uint32_t val24)
{
return ((val24<<16)&0xFF0000) | ((val24)&0xFF00) | ((val24>>16)&0xFF);
}
/**
****************************************************************************************
* @brief Swap bytes of a 16 bits value.
* The swap is done in every case. Should not be called directly.
* @param[in] val16 The 16 bit value to swap.
* @return The 16 bit swapped value.
****************************************************************************************
*/
__INLINE uint16_t co_bswap16(uint16_t val16)
{
return ((val16<<8)&0xFF00) | ((val16>>8)&0xFF);
}
/// @} CO_ENDIAN
/**
* ****************************************************************************************
* @defgroup CO_ENDIAN_NET Endianness (Network)
* @ingroup CO_ENDIAN
* @brief Endianness conversion functions for Network data
*
* Converts values between the local system and big-endian network data
* (e.g. IP, Ethernet, but NOT WLAN).
*
* The \b host term in the descriptions of these functions refers
* to the local system, i.e. \b application or \b embedded system.
* Therefore, these functions will behave differently depending on which
* side they are used. The reason of this terminology is to keep the
* same name than the standard C function.
*
* Behavior will depends on the endianness of the host:
* - little endian: swap bytes;
* - big endian: identity function.
*
* @{
* ****************************************************************************************
* */
/**
****************************************************************************************
* @brief Convert host to network long word.
*
* @param[in] hostlong Long word value to convert.
*
* @return The converted long word.
****************************************************************************************
*/
__INLINE uint32_t co_htonl(uint32_t hostlong)
{
#if (!CPU_LE)
return hostlong;
#else
return co_bswap32(hostlong);
#endif // CPU_LE
}
/**
****************************************************************************************
* @brief Convert host to network long 24-bit value.
*
* @param[in] val24 24-bit value to convert.
*
* @return The converted 24-but value.
****************************************************************************************
*/
__INLINE uint32_t co_hton24(uint32_t host24)
{
#if (!CPU_LE)
return host24;
#else
return co_bswap24(host24);
#endif // CPU_LE
}
/**
****************************************************************************************
* @brief Convert host to network short word.
*
* @param[in] hostshort Short word value to convert.
*
* @return The converted short word.
****************************************************************************************
*/
__INLINE uint16_t co_htons(uint16_t hostshort)
{
#if (!CPU_LE)
return hostshort;
#else
return co_bswap16(hostshort);
#endif // CPU_LE
}
/**
****************************************************************************************
* @brief Convert network to host long word.
*
* @param[in] netlong Long word value to convert.
*
* @return The converted long word.
****************************************************************************************
*/
__INLINE uint32_t co_ntohl(uint32_t netlong)
{
return co_htonl(netlong);
}
/**
****************************************************************************************
* @brief Convert network to host 24-bit value.
*
* @param[in] val24 24-bit to convert.
*
* @return The converted 24-bit value.
****************************************************************************************
*/
__INLINE uint32_t co_ntoh24(uint32_t val24)
{
return co_hton24(val24);
}
/**
****************************************************************************************
* @brief Convert network to host short word.
*
* @param[in] netshort Short word value to convert.
*
* @return The converted short word.
****************************************************************************************
*/
__INLINE uint16_t co_ntohs(uint16_t netshort)
{
return co_htons(netshort);
}
/// @} CO_ENDIAN_NET
/**
* ****************************************************************************************
* @defgroup CO_ENDIAN_BT Endianness (BT)
* @ingroup CO_ENDIAN
* @brief Endianness conversion functions for Bluetooth data (HCI and protocol)
*
* Converts values between the local system and little-endian Bluetooth data.
*
* The \b host term in the descriptions of these functions refers
* to the local system (check \ref CO_ENDIAN_NET "this comment").
*
* Behavior will depends on the endianness of the host:
* - little endian: identity function;
* - big endian: swap bytes.
*
* @addtogroup CO_ENDIAN_BT
* @{
* ****************************************************************************************
* */
/**
****************************************************************************************
* @brief Convert Bluetooth to host 24-bit value.
*
* @param[in] val24 24-bit to convert.
*
* @return The converted 24-bit value.
****************************************************************************************
*/
__INLINE uint32_t co_htob24(uint32_t val24)
{
#if (CPU_LE)
return val24;
#else
return co_hton24(val24);
#endif // CPU_LE
}
/**
****************************************************************************************
* @brief Convert host to Bluetooth long word.
*
* @param[in] hostlong Long word value to convert.
*
* @return The converted long word.
****************************************************************************************
*/
__INLINE uint32_t co_htobl(uint32_t hostlong)
{
#if (CPU_LE)
return hostlong;
#else
return co_bswap32(hostlong);
#endif // CPU_LE
}
/**
****************************************************************************************
* @brief Convert host to Bluetooth short word.
*
* @param[in] hostshort Short word value to convert.
*
* @return The converted short word.
****************************************************************************************
*/
__INLINE uint16_t co_htobs(uint16_t hostshort)
{
#if (CPU_LE)
return hostshort;
#else
return co_bswap16(hostshort);
#endif // CPU_LE
}
/**
****************************************************************************************
* @brief Convert Bluetooth to host 24-bit value.
*
* @param[in] val24 24-bit to convert.
*
* @return The converted 24-bit value.
****************************************************************************************
*/
__INLINE uint32_t co_btoh24(uint32_t val24)
{
return co_htob24(val24);
}
/**
****************************************************************************************
* @brief Convert Bluetooth to host long word.
*
* @param[in] btlong Long word value to convert.
*
* @return The converted long word.
****************************************************************************************
*/
__INLINE uint32_t co_btohl(uint32_t btlong)
{
return co_htobl(btlong);
}
/**
****************************************************************************************
* @brief Convert Bluetooth to host short word.
*
* @param[in] btshort Short word value to convert.
*
* @return The converted short word.
****************************************************************************************
*/
__INLINE uint16_t co_btohs(uint16_t btshort)
{
return co_htobs(btshort);
}
/// @} CO_ENDIAN
#endif // _CO_ENDIAN_H_
/**
****************************************************************************************
*
* @file co_endian.h
*
* @brief Common endianness conversion functions
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef _CO_ENDIAN_H_
#define _CO_ENDIAN_H_
#include <stdint.h> // standard integer definitions
#include "rwip_config.h" // stack configuration
#include "arch.h" // architectural platform definition
/**
****************************************************************************************
* @defgroup CO_ENDIAN Endianness
* @ingroup COMMON
* @brief Endianness conversion functions.
*
* This set of functions converts values between the local system
* and a external one. It is inspired from the <tt>htonl</tt>-like functions
* from the standard C library.
*
* Example:
* @code
* struct eth_header *header = get_header(); // get pointer on Eth II packet header
* uint16_t eth_id; // will contain the type of the packet
* eth_id = co_ntohs(header->eth_id); // retrieve the type with correct endianness
* @endcode
*
* @{
* ****************************************************************************************
* */
/**
****************************************************************************************
* @brief Swap bytes of an array of bytes
* .
* The swap is done in every case. Should not be called directly.
*
* @param[in] p_val_out The output value.
* @param[in] p_val_in The input value.
*
* @param[in] len number of bytes to swap
****************************************************************************************
*/
__INLINE void co_bswap(uint8_t* p_val_out, const uint8_t* p_val_in, uint16_t len)
{
while (len > 0)
{
len--;
*p_val_out = p_val_in[len];
p_val_out++;
}
}
/// @} CO_ENDIAN
/**
****************************************************************************************
* @brief Swap bytes of a 32 bits value.
* The swap is done in every case. Should not be called directly.
* @param[in] val32 The 32 bits value to swap.
* @return The 32 bit swapped value.
****************************************************************************************
*/
__INLINE uint32_t co_bswap32(uint32_t val32)
{
return (val32<<24) | ((val32<<8)&0xFF0000) | ((val32>>8)&0xFF00) | ((val32>>24)&0xFF);
}
/**
****************************************************************************************
* @brief Swap bytes of a 24 bits value.
* The swap is done in every case. Should not be called directly.
* @param[in] val24 The 24 bits value to swap.
* @return The 24 bit swapped value.
****************************************************************************************
*/
__INLINE uint32_t co_bswap24(uint32_t val24)
{
return ((val24<<16)&0xFF0000) | ((val24)&0xFF00) | ((val24>>16)&0xFF);
}
/**
****************************************************************************************
* @brief Swap bytes of a 16 bits value.
* The swap is done in every case. Should not be called directly.
* @param[in] val16 The 16 bit value to swap.
* @return The 16 bit swapped value.
****************************************************************************************
*/
__INLINE uint16_t co_bswap16(uint16_t val16)
{
return ((val16<<8)&0xFF00) | ((val16>>8)&0xFF);
}
/// @} CO_ENDIAN
/**
* ****************************************************************************************
* @defgroup CO_ENDIAN_NET Endianness (Network)
* @ingroup CO_ENDIAN
* @brief Endianness conversion functions for Network data
*
* Converts values between the local system and big-endian network data
* (e.g. IP, Ethernet, but NOT WLAN).
*
* The \b host term in the descriptions of these functions refers
* to the local system, i.e. \b application or \b embedded system.
* Therefore, these functions will behave differently depending on which
* side they are used. The reason of this terminology is to keep the
* same name than the standard C function.
*
* Behavior will depends on the endianness of the host:
* - little endian: swap bytes;
* - big endian: identity function.
*
* @{
* ****************************************************************************************
* */
/**
****************************************************************************************
* @brief Convert host to network long word.
*
* @param[in] hostlong Long word value to convert.
*
* @return The converted long word.
****************************************************************************************
*/
__INLINE uint32_t co_htonl(uint32_t hostlong)
{
#if (!CPU_LE)
return hostlong;
#else
return co_bswap32(hostlong);
#endif // CPU_LE
}
/**
****************************************************************************************
* @brief Convert host to network long 24-bit value.
*
* @param[in] val24 24-bit value to convert.
*
* @return The converted 24-but value.
****************************************************************************************
*/
__INLINE uint32_t co_hton24(uint32_t host24)
{
#if (!CPU_LE)
return host24;
#else
return co_bswap24(host24);
#endif // CPU_LE
}
/**
****************************************************************************************
* @brief Convert host to network short word.
*
* @param[in] hostshort Short word value to convert.
*
* @return The converted short word.
****************************************************************************************
*/
__INLINE uint16_t co_htons(uint16_t hostshort)
{
#if (!CPU_LE)
return hostshort;
#else
return co_bswap16(hostshort);
#endif // CPU_LE
}
/**
****************************************************************************************
* @brief Convert network to host long word.
*
* @param[in] netlong Long word value to convert.
*
* @return The converted long word.
****************************************************************************************
*/
__INLINE uint32_t co_ntohl(uint32_t netlong)
{
return co_htonl(netlong);
}
/**
****************************************************************************************
* @brief Convert network to host 24-bit value.
*
* @param[in] val24 24-bit to convert.
*
* @return The converted 24-bit value.
****************************************************************************************
*/
__INLINE uint32_t co_ntoh24(uint32_t val24)
{
return co_hton24(val24);
}
/**
****************************************************************************************
* @brief Convert network to host short word.
*
* @param[in] netshort Short word value to convert.
*
* @return The converted short word.
****************************************************************************************
*/
__INLINE uint16_t co_ntohs(uint16_t netshort)
{
return co_htons(netshort);
}
/// @} CO_ENDIAN_NET
/**
* ****************************************************************************************
* @defgroup CO_ENDIAN_BT Endianness (BT)
* @ingroup CO_ENDIAN
* @brief Endianness conversion functions for Bluetooth data (HCI and protocol)
*
* Converts values between the local system and little-endian Bluetooth data.
*
* The \b host term in the descriptions of these functions refers
* to the local system (check \ref CO_ENDIAN_NET "this comment").
*
* Behavior will depends on the endianness of the host:
* - little endian: identity function;
* - big endian: swap bytes.
*
* @addtogroup CO_ENDIAN_BT
* @{
* ****************************************************************************************
* */
/**
****************************************************************************************
* @brief Convert Bluetooth to host 24-bit value.
*
* @param[in] val24 24-bit to convert.
*
* @return The converted 24-bit value.
****************************************************************************************
*/
__INLINE uint32_t co_htob24(uint32_t val24)
{
#if (CPU_LE)
return val24;
#else
return co_hton24(val24);
#endif // CPU_LE
}
/**
****************************************************************************************
* @brief Convert host to Bluetooth long word.
*
* @param[in] hostlong Long word value to convert.
*
* @return The converted long word.
****************************************************************************************
*/
__INLINE uint32_t co_htobl(uint32_t hostlong)
{
#if (CPU_LE)
return hostlong;
#else
return co_bswap32(hostlong);
#endif // CPU_LE
}
/**
****************************************************************************************
* @brief Convert host to Bluetooth short word.
*
* @param[in] hostshort Short word value to convert.
*
* @return The converted short word.
****************************************************************************************
*/
__INLINE uint16_t co_htobs(uint16_t hostshort)
{
#if (CPU_LE)
return hostshort;
#else
return co_bswap16(hostshort);
#endif // CPU_LE
}
/**
****************************************************************************************
* @brief Convert Bluetooth to host 24-bit value.
*
* @param[in] val24 24-bit to convert.
*
* @return The converted 24-bit value.
****************************************************************************************
*/
__INLINE uint32_t co_btoh24(uint32_t val24)
{
return co_htob24(val24);
}
/**
****************************************************************************************
* @brief Convert Bluetooth to host long word.
*
* @param[in] btlong Long word value to convert.
*
* @return The converted long word.
****************************************************************************************
*/
__INLINE uint32_t co_btohl(uint32_t btlong)
{
return co_htobl(btlong);
}
/**
****************************************************************************************
* @brief Convert Bluetooth to host short word.
*
* @param[in] btshort Short word value to convert.
*
* @return The converted short word.
****************************************************************************************
*/
__INLINE uint16_t co_btohs(uint16_t btshort)
{
return co_htobs(btshort);
}
/// @} CO_ENDIAN
#endif // _CO_ENDIAN_H_
+116 -116
View File
@@ -1,116 +1,116 @@
/**
****************************************************************************************
*
* @file co_error.h
*
* @brief List of codes for error in RW Software.
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef CO_ERROR_H_
#define CO_ERROR_H_
/**
****************************************************************************************
* @addtogroup CO_ERROR Error Codes
* @ingroup COMMON
* @brief Defines error codes in messages.
*
* @{
****************************************************************************************
*/
/*
* DEFINES
****************************************************************************************
*/
enum co_error
{
/*****************************************************
*** ERROR CODES ***
*****************************************************/
CO_ERROR_NO_ERROR = 0x00,
CO_ERROR_UNKNOWN_HCI_COMMAND = 0x01,
CO_ERROR_UNKNOWN_CONNECTION_ID = 0x02,
CO_ERROR_HARDWARE_FAILURE = 0x03,
CO_ERROR_PAGE_TIMEOUT = 0x04,
CO_ERROR_AUTH_FAILURE = 0x05,
CO_ERROR_PIN_MISSING = 0x06,
CO_ERROR_MEMORY_CAPA_EXCEED = 0x07,
CO_ERROR_CON_TIMEOUT = 0x08,
CO_ERROR_CON_LIMIT_EXCEED = 0x09,
CO_ERROR_SYNC_CON_LIMIT_DEV_EXCEED = 0x0A,
CO_ERROR_CON_ALREADY_EXISTS = 0x0B,
CO_ERROR_COMMAND_DISALLOWED = 0x0C,
CO_ERROR_CONN_REJ_LIMITED_RESOURCES = 0x0D,
CO_ERROR_CONN_REJ_SECURITY_REASONS = 0x0E,
CO_ERROR_CONN_REJ_UNACCEPTABLE_BDADDR = 0x0F,
CO_ERROR_CONN_ACCEPT_TIMEOUT_EXCEED = 0x10,
CO_ERROR_UNSUPPORTED = 0x11,
CO_ERROR_INVALID_HCI_PARAM = 0x12,
CO_ERROR_REMOTE_USER_TERM_CON = 0x13,
CO_ERROR_REMOTE_DEV_TERM_LOW_RESOURCES = 0x14,
CO_ERROR_REMOTE_DEV_POWER_OFF = 0x15,
CO_ERROR_CON_TERM_BY_LOCAL_HOST = 0x16,
CO_ERROR_REPEATED_ATTEMPTS = 0x17,
CO_ERROR_PAIRING_NOT_ALLOWED = 0x18,
CO_ERROR_UNKNOWN_LMP_PDU = 0x19,
CO_ERROR_UNSUPPORTED_REMOTE_FEATURE = 0x1A,
CO_ERROR_SCO_OFFSET_REJECTED = 0x1B,
CO_ERROR_SCO_INTERVAL_REJECTED = 0x1C,
CO_ERROR_SCO_AIR_MODE_REJECTED = 0x1D,
CO_ERROR_INVALID_LMP_PARAM = 0x1E,
CO_ERROR_UNSPECIFIED_ERROR = 0x1F,
CO_ERROR_UNSUPPORTED_LMP_PARAM_VALUE = 0x20,
CO_ERROR_ROLE_CHANGE_NOT_ALLOWED = 0x21,
CO_ERROR_LMP_RSP_TIMEOUT = 0x22,
CO_ERROR_LMP_COLLISION = 0x23,
CO_ERROR_LMP_PDU_NOT_ALLOWED = 0x24,
CO_ERROR_ENC_MODE_NOT_ACCEPT = 0x25,
CO_ERROR_LINK_KEY_CANT_CHANGE = 0x26,
CO_ERROR_QOS_NOT_SUPPORTED = 0x27,
CO_ERROR_INSTANT_PASSED = 0x28,
CO_ERROR_PAIRING_WITH_UNIT_KEY_NOT_SUP = 0x29,
CO_ERROR_DIFF_TRANSACTION_COLLISION = 0x2A,
CO_ERROR_QOS_UNACCEPTABLE_PARAM = 0x2C,
CO_ERROR_QOS_REJECTED = 0x2D,
CO_ERROR_CHANNEL_CLASS_NOT_SUP = 0x2E,
CO_ERROR_INSUFFICIENT_SECURITY = 0x2F,
CO_ERROR_PARAM_OUT_OF_MAND_RANGE = 0x30,
CO_ERROR_ROLE_SWITCH_PEND = 0x32, /* LM_ROLE_SWITCH_PENDING */
CO_ERROR_RESERVED_SLOT_VIOLATION = 0x34, /* LM_RESERVED_SLOT_VIOLATION */
CO_ERROR_ROLE_SWITCH_FAIL = 0x35, /* LM_ROLE_SWITCH_FAILED */
CO_ERROR_EIR_TOO_LARGE = 0x36, /* LM_EXTENDED_INQUIRY_RESPONSE_TOO_LARGE */
CO_ERROR_SP_NOT_SUPPORTED_HOST = 0x37,
CO_ERROR_HOST_BUSY_PAIRING = 0x38,
CO_ERROR_CONTROLLER_BUSY = 0x3A,
CO_ERROR_UNACCEPTABLE_CONN_PARAM = 0x3B,
CO_ERROR_ADV_TO = 0x3C,
CO_ERROR_TERMINATED_MIC_FAILURE = 0x3D,
CO_ERROR_CONN_FAILED_TO_BE_EST = 0x3E,
CO_ERROR_CCA_REJ_USE_CLOCK_DRAG = 0x40,
CO_ERROR_TYPE0_SUBMAP_NOT_DEFINED = 0x41,
CO_ERROR_UNKNOWN_ADVERTISING_ID = 0x42,
CO_ERROR_LIMIT_REACHED = 0x43,
CO_ERROR_OPERATION_CANCELED_BY_HOST = 0x44,
CO_ERROR_PKT_TOO_LONG = 0x45,
CO_ERROR_UNDEFINED = 0xFF,
/*****************************************************
*** HW ERROR CODES ***
*****************************************************/
CO_ERROR_HW_UART_OUT_OF_SYNC = 0x00,
CO_ERROR_HW_MEM_ALLOC_FAIL = 0x01,
};
/// @} CO_ERROR
#endif // CO_ERROR_H_
/**
****************************************************************************************
*
* @file co_error.h
*
* @brief List of codes for error in RW Software.
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef CO_ERROR_H_
#define CO_ERROR_H_
/**
****************************************************************************************
* @addtogroup CO_ERROR Error Codes
* @ingroup COMMON
* @brief Defines error codes in messages.
*
* @{
****************************************************************************************
*/
/*
* DEFINES
****************************************************************************************
*/
enum co_error
{
/*****************************************************
*** ERROR CODES ***
*****************************************************/
CO_ERROR_NO_ERROR = 0x00,
CO_ERROR_UNKNOWN_HCI_COMMAND = 0x01,
CO_ERROR_UNKNOWN_CONNECTION_ID = 0x02,
CO_ERROR_HARDWARE_FAILURE = 0x03,
CO_ERROR_PAGE_TIMEOUT = 0x04,
CO_ERROR_AUTH_FAILURE = 0x05,
CO_ERROR_PIN_MISSING = 0x06,
CO_ERROR_MEMORY_CAPA_EXCEED = 0x07,
CO_ERROR_CON_TIMEOUT = 0x08,
CO_ERROR_CON_LIMIT_EXCEED = 0x09,
CO_ERROR_SYNC_CON_LIMIT_DEV_EXCEED = 0x0A,
CO_ERROR_CON_ALREADY_EXISTS = 0x0B,
CO_ERROR_COMMAND_DISALLOWED = 0x0C,
CO_ERROR_CONN_REJ_LIMITED_RESOURCES = 0x0D,
CO_ERROR_CONN_REJ_SECURITY_REASONS = 0x0E,
CO_ERROR_CONN_REJ_UNACCEPTABLE_BDADDR = 0x0F,
CO_ERROR_CONN_ACCEPT_TIMEOUT_EXCEED = 0x10,
CO_ERROR_UNSUPPORTED = 0x11,
CO_ERROR_INVALID_HCI_PARAM = 0x12,
CO_ERROR_REMOTE_USER_TERM_CON = 0x13,
CO_ERROR_REMOTE_DEV_TERM_LOW_RESOURCES = 0x14,
CO_ERROR_REMOTE_DEV_POWER_OFF = 0x15,
CO_ERROR_CON_TERM_BY_LOCAL_HOST = 0x16,
CO_ERROR_REPEATED_ATTEMPTS = 0x17,
CO_ERROR_PAIRING_NOT_ALLOWED = 0x18,
CO_ERROR_UNKNOWN_LMP_PDU = 0x19,
CO_ERROR_UNSUPPORTED_REMOTE_FEATURE = 0x1A,
CO_ERROR_SCO_OFFSET_REJECTED = 0x1B,
CO_ERROR_SCO_INTERVAL_REJECTED = 0x1C,
CO_ERROR_SCO_AIR_MODE_REJECTED = 0x1D,
CO_ERROR_INVALID_LMP_PARAM = 0x1E,
CO_ERROR_UNSPECIFIED_ERROR = 0x1F,
CO_ERROR_UNSUPPORTED_LMP_PARAM_VALUE = 0x20,
CO_ERROR_ROLE_CHANGE_NOT_ALLOWED = 0x21,
CO_ERROR_LMP_RSP_TIMEOUT = 0x22,
CO_ERROR_LMP_COLLISION = 0x23,
CO_ERROR_LMP_PDU_NOT_ALLOWED = 0x24,
CO_ERROR_ENC_MODE_NOT_ACCEPT = 0x25,
CO_ERROR_LINK_KEY_CANT_CHANGE = 0x26,
CO_ERROR_QOS_NOT_SUPPORTED = 0x27,
CO_ERROR_INSTANT_PASSED = 0x28,
CO_ERROR_PAIRING_WITH_UNIT_KEY_NOT_SUP = 0x29,
CO_ERROR_DIFF_TRANSACTION_COLLISION = 0x2A,
CO_ERROR_QOS_UNACCEPTABLE_PARAM = 0x2C,
CO_ERROR_QOS_REJECTED = 0x2D,
CO_ERROR_CHANNEL_CLASS_NOT_SUP = 0x2E,
CO_ERROR_INSUFFICIENT_SECURITY = 0x2F,
CO_ERROR_PARAM_OUT_OF_MAND_RANGE = 0x30,
CO_ERROR_ROLE_SWITCH_PEND = 0x32, /* LM_ROLE_SWITCH_PENDING */
CO_ERROR_RESERVED_SLOT_VIOLATION = 0x34, /* LM_RESERVED_SLOT_VIOLATION */
CO_ERROR_ROLE_SWITCH_FAIL = 0x35, /* LM_ROLE_SWITCH_FAILED */
CO_ERROR_EIR_TOO_LARGE = 0x36, /* LM_EXTENDED_INQUIRY_RESPONSE_TOO_LARGE */
CO_ERROR_SP_NOT_SUPPORTED_HOST = 0x37,
CO_ERROR_HOST_BUSY_PAIRING = 0x38,
CO_ERROR_CONTROLLER_BUSY = 0x3A,
CO_ERROR_UNACCEPTABLE_CONN_PARAM = 0x3B,
CO_ERROR_ADV_TO = 0x3C,
CO_ERROR_TERMINATED_MIC_FAILURE = 0x3D,
CO_ERROR_CONN_FAILED_TO_BE_EST = 0x3E,
CO_ERROR_CCA_REJ_USE_CLOCK_DRAG = 0x40,
CO_ERROR_TYPE0_SUBMAP_NOT_DEFINED = 0x41,
CO_ERROR_UNKNOWN_ADVERTISING_ID = 0x42,
CO_ERROR_LIMIT_REACHED = 0x43,
CO_ERROR_OPERATION_CANCELED_BY_HOST = 0x44,
CO_ERROR_PKT_TOO_LONG = 0x45,
CO_ERROR_UNDEFINED = 0xFF,
/*****************************************************
*** HW ERROR CODES ***
*****************************************************/
CO_ERROR_HW_UART_OUT_OF_SYNC = 0x00,
CO_ERROR_HW_MEM_ALLOC_FAIL = 0x01,
};
/// @} CO_ERROR
#endif // CO_ERROR_H_
File diff suppressed because it is too large Load Diff
+316 -316
View File
@@ -1,316 +1,316 @@
/**
****************************************************************************************
*
* @file co_list.h
*
* @brief Common list structures definitions
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef _CO_LIST_H_
#define _CO_LIST_H_
/**
*****************************************************************************************
* @defgroup CO_LIST List management
* @ingroup COMMON
*
* @brief List management.
*
* This module contains the list structures and handling functions.
* @{
*****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // standard definition
#include <stdbool.h> // boolean definition
#include <stddef.h> // for NULL and size_t
#include "rwip_config.h" // stack configuration
#include "compiler.h" // for __INLINE
/*
* DEFINES
****************************************************************************************
*/
/// structure of a list element header
/*@TRACE*/
struct co_list_hdr
{
/// Pointer to next co_list_hdr
struct co_list_hdr *next;
};
/// simplify type name of list element header
typedef struct co_list_hdr co_list_hdr_t;
/// structure of a list
struct co_list
{
/// pointer to first element of the list
struct co_list_hdr *first;
/// pointer to the last element
struct co_list_hdr *last;
#if (KE_PROFILING)
/// number of element in the list
uint32_t cnt;
/// max number of element in the list
uint32_t maxcnt;
/// min number of element in the list
uint32_t mincnt;
#endif //KE_PROFILING
};
/// simplify type name of list
typedef struct co_list co_list_t;
/*
* MACROS
****************************************************************************************
*/
/// pop a specific element from the list
#define CO_LIST_POP_ELT(list, elt) co_list_extract(&(list), &(elt->hdr));
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize a list to defaults values.
*
* @param list Pointer to the list structure.
****************************************************************************************
*/
void co_list_init(struct co_list *list);
/**
****************************************************************************************
* @brief Construct a list of free elements representing a pool
*
* @param list Pointer to the list structure
* @param pool Pointer to the pool to be initialized
* @param elmt_size Size of one element of the pool (in bytes)
* @param elmt_cnt Number of elements available in the pool
****************************************************************************************
*/
void co_list_pool_init(struct co_list *list,
void *pool,
size_t elmt_size,
uint32_t elmt_cnt);
/**
****************************************************************************************
* @brief Add an element as last on the list.
*
* @param list Pointer to the list structure
* @param list_hdr Pointer to the header to add at the end of the list
*
****************************************************************************************
*/
void co_list_push_back(struct co_list *list, struct co_list_hdr *list_hdr);
/**
****************************************************************************************
* @brief Append a sequence of elements at the end of a list.
*
* Note: the elements to append shall be linked together
*
* @param list Pointer to the list structure
* @param first_hdr Pointer to the first element to append
* @param last_hdr Pointer to the last element to append
****************************************************************************************
*/
void co_list_push_back_sublist(struct co_list *list, struct co_list_hdr *first_hdr, struct co_list_hdr *last_hdr);
/**
****************************************************************************************
* @brief Add an element as first on the list.
*
* @param list Pointer to the list structure
* @param list_hdr Pointer to the header to add at the beginning of the list
****************************************************************************************
*/
void co_list_push_front(struct co_list *list, struct co_list_hdr *list_hdr);
/**
****************************************************************************************
* @brief Extract the first element of the list.
* @param list Pointer to the list structure
* @return The pointer to the element extracted, and NULL if the list is empty.
****************************************************************************************
*/
struct co_list_hdr *co_list_pop_front(struct co_list *list);
/**
****************************************************************************************
* @brief Search for a given element in the list, and extract it if found.
*
* @param list Pointer to the list structure
* @param list_hdr Element to extract
*
* @return true if the element is found in the list, false otherwise
****************************************************************************************
*/
bool co_list_extract(struct co_list *list, struct co_list_hdr *list_hdr);
/**
****************************************************************************************
* @brief Extract an element when the previous element is known
*
* Note: the element to remove shall follow immediately the reference within the list
*
* @param list Pointer to the list structure
* @param elt_ref_hdr Pointer to the referenced element (NULL if element to extract is the first in the list)
* @param elt_to_rem_hdr Pointer to the element to be extracted
****************************************************************************************
*/
void co_list_extract_after(struct co_list *list, struct co_list_hdr *elt_ref_hdr, struct co_list_hdr *elt_to_rem_hdr);
/**
****************************************************************************************
* @brief Extract a sub-list when the previous element is known
*
* Note: the elements to remove shall be linked together and follow immediately the reference element
*
* @param[in] list Pointer to the list structure
* @param[in] ref_hdr Pointer to the referenced element (NULL if first element to extract is first in the list)
* @param[in] last_hdr Pointer to the last element to extract ()
****************************************************************************************
*/
void co_list_extract_sublist(struct co_list *list, struct co_list_hdr *ref_hdr, struct co_list_hdr *last_hdr);
/**
****************************************************************************************
* @brief Searched a given element in the list.
*
* @param list Pointer to the list structure
* @param list_hdr Pointer to the searched element
*
* @return true if the element is found in the list, false otherwise
****************************************************************************************
*/
// bool co_list_find(struct co_list *list, struct co_list_hdr *list_hdr);
/**
****************************************************************************************
* @brief Merge two lists in a single one.
*
* This function appends the list pointed by list2 to the list pointed by list1. Once the
* merge is done, it empties list2.
*
* @param list1 Pointer to the destination list
* @param list2 Pointer to the list to append to list1
****************************************************************************************
*/
// void co_list_merge(struct co_list *list1, struct co_list *list2);
/**
****************************************************************************************
* @brief Insert a given element in the list before the referenced element.
*
* @param list Pointer to the list structure
* @param elt_ref_hdr Pointer to the referenced element
* @param elt_to_add_hdr Pointer to the element to be inserted
*
* @return true if the element is found in the list, false otherwise
****************************************************************************************
*/
void co_list_insert_before(struct co_list *list,
struct co_list_hdr *elt_ref_hdr, struct co_list_hdr *elt_to_add_hdr);
/**
****************************************************************************************
* @brief Insert a given element in the list after the referenced element.
*
* @param list Pointer to the list structure
* @param elt_ref_hdr Pointer to the referenced element
* @param elt_to_add_hdr Pointer to the element to be inserted
*
* @return true if the element is found in the list, false otherwise
****************************************************************************************
*/
void co_list_insert_after(struct co_list *list,
struct co_list_hdr *elt_ref_hdr, struct co_list_hdr *elt_to_add_hdr);
/**
****************************************************************************************
* @brief Count number of elements present in the list
*
* @param list Pointer to the list structure
*
* @return Number of elements present in the list
****************************************************************************************
*/
// uint16_t co_list_size(struct co_list *list);
/**
****************************************************************************************
* @brief Test if the list is empty.
* @param list Pointer to the list structure.
* @return true if the list is empty, false else otherwise.
****************************************************************************************
*/
__INLINE bool co_list_is_empty(const struct co_list *const list)
{
bool listempty;
listempty = (list->first == NULL);
return (listempty);
}
/**
****************************************************************************************
* @brief Pick the first element from the list without removing it.
*
* @param list Pointer to the list structure.
*
* @return First element address. Returns NULL pointer if the list is empty.
****************************************************************************************
*/
__INLINE struct co_list_hdr *co_list_pick(const struct co_list *const list)
{
return(list->first);
}
/**
****************************************************************************************
* @brief Pick last element from the list without removing it.
*
* @param list Pointer to the list structure.
*
* @return Last element address. Returns NULL pointer if the list is empty.
****************************************************************************************
*/
__INLINE struct co_list_hdr *co_list_tail(const struct co_list *const list)
{
return(list->last);
}
/**
****************************************************************************************
* @brief Return following element of a list element.
*
* @param list_hdr Pointer to the list element.
*
* @return The pointer to the next element.
****************************************************************************************
*/
__INLINE struct co_list_hdr *co_list_next(const struct co_list_hdr *const list_hdr)
{
return(list_hdr->next);
}
/// @} CO_LIST
#endif // _CO_LIST_H_
/**
****************************************************************************************
*
* @file co_list.h
*
* @brief Common list structures definitions
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef _CO_LIST_H_
#define _CO_LIST_H_
/**
*****************************************************************************************
* @defgroup CO_LIST List management
* @ingroup COMMON
*
* @brief List management.
*
* This module contains the list structures and handling functions.
* @{
*****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // standard definition
#include <stdbool.h> // boolean definition
#include <stddef.h> // for NULL and size_t
#include "rwip_config.h" // stack configuration
#include "compiler.h" // for __INLINE
/*
* DEFINES
****************************************************************************************
*/
/// structure of a list element header
/*@TRACE*/
struct co_list_hdr
{
/// Pointer to next co_list_hdr
struct co_list_hdr *next;
};
/// simplify type name of list element header
typedef struct co_list_hdr co_list_hdr_t;
/// structure of a list
struct co_list
{
/// pointer to first element of the list
struct co_list_hdr *first;
/// pointer to the last element
struct co_list_hdr *last;
#if (KE_PROFILING)
/// number of element in the list
uint32_t cnt;
/// max number of element in the list
uint32_t maxcnt;
/// min number of element in the list
uint32_t mincnt;
#endif //KE_PROFILING
};
/// simplify type name of list
typedef struct co_list co_list_t;
/*
* MACROS
****************************************************************************************
*/
/// pop a specific element from the list
#define CO_LIST_POP_ELT(list, elt) co_list_extract(&(list), &(elt->hdr));
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize a list to defaults values.
*
* @param list Pointer to the list structure.
****************************************************************************************
*/
void co_list_init(struct co_list *list);
/**
****************************************************************************************
* @brief Construct a list of free elements representing a pool
*
* @param list Pointer to the list structure
* @param pool Pointer to the pool to be initialized
* @param elmt_size Size of one element of the pool (in bytes)
* @param elmt_cnt Number of elements available in the pool
****************************************************************************************
*/
void co_list_pool_init(struct co_list *list,
void *pool,
size_t elmt_size,
uint32_t elmt_cnt);
/**
****************************************************************************************
* @brief Add an element as last on the list.
*
* @param list Pointer to the list structure
* @param list_hdr Pointer to the header to add at the end of the list
*
****************************************************************************************
*/
void co_list_push_back(struct co_list *list, struct co_list_hdr *list_hdr);
/**
****************************************************************************************
* @brief Append a sequence of elements at the end of a list.
*
* Note: the elements to append shall be linked together
*
* @param list Pointer to the list structure
* @param first_hdr Pointer to the first element to append
* @param last_hdr Pointer to the last element to append
****************************************************************************************
*/
void co_list_push_back_sublist(struct co_list *list, struct co_list_hdr *first_hdr, struct co_list_hdr *last_hdr);
/**
****************************************************************************************
* @brief Add an element as first on the list.
*
* @param list Pointer to the list structure
* @param list_hdr Pointer to the header to add at the beginning of the list
****************************************************************************************
*/
void co_list_push_front(struct co_list *list, struct co_list_hdr *list_hdr);
/**
****************************************************************************************
* @brief Extract the first element of the list.
* @param list Pointer to the list structure
* @return The pointer to the element extracted, and NULL if the list is empty.
****************************************************************************************
*/
struct co_list_hdr *co_list_pop_front(struct co_list *list);
/**
****************************************************************************************
* @brief Search for a given element in the list, and extract it if found.
*
* @param list Pointer to the list structure
* @param list_hdr Element to extract
*
* @return true if the element is found in the list, false otherwise
****************************************************************************************
*/
bool co_list_extract(struct co_list *list, struct co_list_hdr *list_hdr);
/**
****************************************************************************************
* @brief Extract an element when the previous element is known
*
* Note: the element to remove shall follow immediately the reference within the list
*
* @param list Pointer to the list structure
* @param elt_ref_hdr Pointer to the referenced element (NULL if element to extract is the first in the list)
* @param elt_to_rem_hdr Pointer to the element to be extracted
****************************************************************************************
*/
void co_list_extract_after(struct co_list *list, struct co_list_hdr *elt_ref_hdr, struct co_list_hdr *elt_to_rem_hdr);
/**
****************************************************************************************
* @brief Extract a sub-list when the previous element is known
*
* Note: the elements to remove shall be linked together and follow immediately the reference element
*
* @param[in] list Pointer to the list structure
* @param[in] ref_hdr Pointer to the referenced element (NULL if first element to extract is first in the list)
* @param[in] last_hdr Pointer to the last element to extract ()
****************************************************************************************
*/
void co_list_extract_sublist(struct co_list *list, struct co_list_hdr *ref_hdr, struct co_list_hdr *last_hdr);
/**
****************************************************************************************
* @brief Searched a given element in the list.
*
* @param list Pointer to the list structure
* @param list_hdr Pointer to the searched element
*
* @return true if the element is found in the list, false otherwise
****************************************************************************************
*/
// bool co_list_find(struct co_list *list, struct co_list_hdr *list_hdr);
/**
****************************************************************************************
* @brief Merge two lists in a single one.
*
* This function appends the list pointed by list2 to the list pointed by list1. Once the
* merge is done, it empties list2.
*
* @param list1 Pointer to the destination list
* @param list2 Pointer to the list to append to list1
****************************************************************************************
*/
// void co_list_merge(struct co_list *list1, struct co_list *list2);
/**
****************************************************************************************
* @brief Insert a given element in the list before the referenced element.
*
* @param list Pointer to the list structure
* @param elt_ref_hdr Pointer to the referenced element
* @param elt_to_add_hdr Pointer to the element to be inserted
*
* @return true if the element is found in the list, false otherwise
****************************************************************************************
*/
void co_list_insert_before(struct co_list *list,
struct co_list_hdr *elt_ref_hdr, struct co_list_hdr *elt_to_add_hdr);
/**
****************************************************************************************
* @brief Insert a given element in the list after the referenced element.
*
* @param list Pointer to the list structure
* @param elt_ref_hdr Pointer to the referenced element
* @param elt_to_add_hdr Pointer to the element to be inserted
*
* @return true if the element is found in the list, false otherwise
****************************************************************************************
*/
void co_list_insert_after(struct co_list *list,
struct co_list_hdr *elt_ref_hdr, struct co_list_hdr *elt_to_add_hdr);
/**
****************************************************************************************
* @brief Count number of elements present in the list
*
* @param list Pointer to the list structure
*
* @return Number of elements present in the list
****************************************************************************************
*/
// uint16_t co_list_size(struct co_list *list);
/**
****************************************************************************************
* @brief Test if the list is empty.
* @param list Pointer to the list structure.
* @return true if the list is empty, false else otherwise.
****************************************************************************************
*/
__INLINE bool co_list_is_empty(const struct co_list *const list)
{
bool listempty;
listempty = (list->first == NULL);
return (listempty);
}
/**
****************************************************************************************
* @brief Pick the first element from the list without removing it.
*
* @param list Pointer to the list structure.
*
* @return First element address. Returns NULL pointer if the list is empty.
****************************************************************************************
*/
__INLINE struct co_list_hdr *co_list_pick(const struct co_list *const list)
{
return(list->first);
}
/**
****************************************************************************************
* @brief Pick last element from the list without removing it.
*
* @param list Pointer to the list structure.
*
* @return Last element address. Returns NULL pointer if the list is empty.
****************************************************************************************
*/
__INLINE struct co_list_hdr *co_list_tail(const struct co_list *const list)
{
return(list->last);
}
/**
****************************************************************************************
* @brief Return following element of a list element.
*
* @param list_hdr Pointer to the list element.
*
* @return The pointer to the next element.
****************************************************************************************
*/
__INLINE struct co_list_hdr *co_list_next(const struct co_list_hdr *const list_hdr)
{
return(list_hdr->next);
}
/// @} CO_LIST
#endif // _CO_LIST_H_
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+307 -307
View File
@@ -1,307 +1,307 @@
/**
****************************************************************************************
*
* @file co_math.h
*
* @brief Common optimized math functions
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef _CO_MATH_H_
#define _CO_MATH_H_
/**
*****************************************************************************************
* @defgroup CO_MATH Math functions
* @ingroup COMMON
* @brief Optimized math functions and other computations.
*
* @{
*****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // standard integer definitions
#include <stdbool.h> // boolean definitions
#include <stdlib.h> // standard library
#include "compiler.h" // for __INLINE
#include "arch.h" // for ASSERT_ERR
extern void srand (unsigned int seed);
extern int rand (void);
/*
* MACROS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Return value with one bit set.
*
* @param[in] pos Position of the bit to set.
*
* @return Value with one bit set. There is no return type since this is a macro and this
* will be resolved by the compiler upon assignment to an l-value.
****************************************************************************************
*/
#define CO_BIT(pos) (1UL<<(pos))
/**
****************************************************************************************
* @brief Return value bit into a bit field.
*
* @param[in] bf Bit Field
* @param[in] pos Position of the bit
*
* @return value of a bit into a bit field
****************************************************************************************
*/
#define CO_BIT_GET(bf, pos) (((((uint8_t*)bf)[((pos) >> 3)])>>((pos) & 0x7)) & 0x1)
/**
****************************************************************************************
* @brief Update value bit into a bit field.
*
* @param[in] bf Bit Field
* @param[in] pos Position of the bit
* @param[in] val New value of the bit (0 or 1)
****************************************************************************************
*/
#define CO_BIT_SET(bf, pos, val) (((uint8_t*)bf)[((pos) >> 3)]) = ((((uint8_t*)bf)[((pos) >> 3)]) & ~CO_BIT(((pos) & 0x7))) \
| (((val) & 0x1) << ((pos) & 0x7))
/**
****************************************************************************************
* @brief Align val on the multiple of 4 equal or nearest higher.
* @param[in] val Value to align.
* @return Value aligned.
****************************************************************************************
*/
#define CO_ALIGN4_HI(val) (((val)+3)&~3)
/**
****************************************************************************************
* @brief Align val on the multiple of 4 equal or nearest lower.
* @param[in] val Value to align.
* @return Value aligned.
****************************************************************************************
*/
#define CO_ALIGN4_LO(val) ((val)&~3)
/**
****************************************************************************************
* @brief Align val on the multiple of 2 equal or nearest higher.
* @param[in] val Value to align.
* @return Value aligned.
****************************************************************************************
*/
#define CO_ALIGN2_HI(val) (((val)+1)&~1)
/**
****************************************************************************************
* @brief Align val on the multiple of 2 equal or nearest lower.
* @param[in] val Value to align.
* @return Value aligned.
****************************************************************************************
*/
#define CO_ALIGN2_LO(val) ((val)&~1)
/**
****************************************************************************************
* Perform a division and ceil up the result
*
* @param[in] val Value to divide
* @param[in] div Divide value
* @return ceil(val/div)
****************************************************************************************
*/
#define CO_DIVIDE_CEIL(val, div) (((val) + ((div) - 1))/ (div))
/**
****************************************************************************************
* Perform a division and round the result
*
* @param[in] val Value to divide
* @param[in] div Divide value
* @return round(val/div)
****************************************************************************************
*/
#define CO_DIVIDE_ROUND(val, div) (((val) + ((div) >> 1))/ (div))
/**
****************************************************************************************
* Perform a modulo operation
*
* @param[in] val Dividend
* @param[in] div Divisor
* @return val/div)
****************************************************************************************
*/
//#define CO_MOD(val, div) ((val) % (div))
__INLINE uint32_t co_mod(uint32_t val, uint32_t div)
{
ASSERT_ERR(div);
return ((val) % (div));
}
#define CO_MOD(val, div) co_mod(val, div)
/*
* FUNCTION DEFINTIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Count leading zeros.
* @param[in] val Value to count the number of leading zeros on.
* @return Number of leading zeros when value is written as 32 bits.
****************************************************************************************
*/
__INLINE uint32_t co_clz(uint32_t val)
{
#if defined(__arm__)
return __builtin_clz(val);
#elif defined(__GNUC__)
if (val == 0)
{
return 32;
}
return __builtin_clz(val);
#else
uint32_t i;
for (i = 0; i < 32; i++)
{
if (val & CO_BIT(31 - i))
break;
}
return i;
#endif // defined(__arm__)
}
/**
****************************************************************************************
* @brief Count trailing zeros.
* @param[in] val Value to count the number of trailing zeros on.
* @return Number of trailing zeros when value is written as 32 bits.
****************************************************************************************
*/
__INLINE uint32_t co_ctz(uint32_t val)
{
#if defined(__arm__)
return __builtin_ctz(val);
#elif defined(__GNUC__)
if (val == 0)
{
return 32;
}
return __builtin_ctz(val);
#else
uint32_t i;
for (i = 0; i < 32; i++)
{
if (val & CO_BIT(i))
break;
}
return i;
#endif // defined(__arm__)
}
/**
****************************************************************************************
* @brief Function to initialize the random seed.
* @param[in] seed The seed number to use to generate the random sequence.
****************************************************************************************
*/
__INLINE void co_random_init(uint32_t seed)
{
srand(seed);
}
/**
****************************************************************************************
* @brief Function to get an 8 bit random number.
* @return Random byte value.
****************************************************************************************
*/
__INLINE uint8_t co_rand_byte(void)
{
return (uint8_t)(rand() & 0xFF);
}
/**
****************************************************************************************
* @brief Function to get an 16 bit random number.
* @return Random half word value.
****************************************************************************************
*/
__INLINE uint16_t co_rand_hword(void)
{
return (uint16_t)(rand() & 0xFFFF);
}
/**
****************************************************************************************
* @brief Function to get an 32 bit random number.
* @return Random word value.
****************************************************************************************
*/
__INLINE uint32_t co_rand_word(void)
{
return (uint32_t)rand();
}
/**
****************************************************************************************
* @brief Function to return the smallest of 2 unsigned 32 bits words.
* @return The smallest value.
****************************************************************************************
*/
__INLINE uint32_t co_min(uint32_t a, uint32_t b)
{
return a < b ? a : b;
}
/**
****************************************************************************************
* @brief Function to return the smallest of 2 signed 32 bits words.
* @return The smallest value.
****************************************************************************************
*/
__INLINE int32_t co_min_s(int32_t a, int32_t b)
{
return a < b ? a : b;
}
/**
****************************************************************************************
* @brief Function to return the greatest of 2 unsigned 32 bits words.
* @return The greatest value.
****************************************************************************************
*/
__INLINE uint32_t co_max(uint32_t a, uint32_t b)
{
return a > b ? a : b;
}
/**
****************************************************************************************
* @brief Function to return the absolute value of a signed integer.
* @return The absolute value.
****************************************************************************************
*/
__INLINE int co_abs(int val)
{
return (val < 0) ? (0 - val) : val;
}
/// @} CO_MATH
#endif // _CO_MATH_H_
/**
****************************************************************************************
*
* @file co_math.h
*
* @brief Common optimized math functions
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef _CO_MATH_H_
#define _CO_MATH_H_
/**
*****************************************************************************************
* @defgroup CO_MATH Math functions
* @ingroup COMMON
* @brief Optimized math functions and other computations.
*
* @{
*****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // standard integer definitions
#include <stdbool.h> // boolean definitions
#include <stdlib.h> // standard library
#include "compiler.h" // for __INLINE
#include "arch.h" // for ASSERT_ERR
extern void srand (unsigned int seed);
extern int rand (void);
/*
* MACROS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Return value with one bit set.
*
* @param[in] pos Position of the bit to set.
*
* @return Value with one bit set. There is no return type since this is a macro and this
* will be resolved by the compiler upon assignment to an l-value.
****************************************************************************************
*/
#define CO_BIT(pos) (1UL<<(pos))
/**
****************************************************************************************
* @brief Return value bit into a bit field.
*
* @param[in] bf Bit Field
* @param[in] pos Position of the bit
*
* @return value of a bit into a bit field
****************************************************************************************
*/
#define CO_BIT_GET(bf, pos) (((((uint8_t*)bf)[((pos) >> 3)])>>((pos) & 0x7)) & 0x1)
/**
****************************************************************************************
* @brief Update value bit into a bit field.
*
* @param[in] bf Bit Field
* @param[in] pos Position of the bit
* @param[in] val New value of the bit (0 or 1)
****************************************************************************************
*/
#define CO_BIT_SET(bf, pos, val) (((uint8_t*)bf)[((pos) >> 3)]) = ((((uint8_t*)bf)[((pos) >> 3)]) & ~CO_BIT(((pos) & 0x7))) \
| (((val) & 0x1) << ((pos) & 0x7))
/**
****************************************************************************************
* @brief Align val on the multiple of 4 equal or nearest higher.
* @param[in] val Value to align.
* @return Value aligned.
****************************************************************************************
*/
#define CO_ALIGN4_HI(val) (((val)+3)&~3)
/**
****************************************************************************************
* @brief Align val on the multiple of 4 equal or nearest lower.
* @param[in] val Value to align.
* @return Value aligned.
****************************************************************************************
*/
#define CO_ALIGN4_LO(val) ((val)&~3)
/**
****************************************************************************************
* @brief Align val on the multiple of 2 equal or nearest higher.
* @param[in] val Value to align.
* @return Value aligned.
****************************************************************************************
*/
#define CO_ALIGN2_HI(val) (((val)+1)&~1)
/**
****************************************************************************************
* @brief Align val on the multiple of 2 equal or nearest lower.
* @param[in] val Value to align.
* @return Value aligned.
****************************************************************************************
*/
#define CO_ALIGN2_LO(val) ((val)&~1)
/**
****************************************************************************************
* Perform a division and ceil up the result
*
* @param[in] val Value to divide
* @param[in] div Divide value
* @return ceil(val/div)
****************************************************************************************
*/
#define CO_DIVIDE_CEIL(val, div) (((val) + ((div) - 1))/ (div))
/**
****************************************************************************************
* Perform a division and round the result
*
* @param[in] val Value to divide
* @param[in] div Divide value
* @return round(val/div)
****************************************************************************************
*/
#define CO_DIVIDE_ROUND(val, div) (((val) + ((div) >> 1))/ (div))
/**
****************************************************************************************
* Perform a modulo operation
*
* @param[in] val Dividend
* @param[in] div Divisor
* @return val/div)
****************************************************************************************
*/
//#define CO_MOD(val, div) ((val) % (div))
__INLINE uint32_t co_mod(uint32_t val, uint32_t div)
{
ASSERT_ERR(div);
return ((val) % (div));
}
#define CO_MOD(val, div) co_mod(val, div)
/*
* FUNCTION DEFINTIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Count leading zeros.
* @param[in] val Value to count the number of leading zeros on.
* @return Number of leading zeros when value is written as 32 bits.
****************************************************************************************
*/
__INLINE uint32_t co_clz(uint32_t val)
{
#if defined(__arm__)
return __builtin_clz(val);
#elif defined(__GNUC__)
if (val == 0)
{
return 32;
}
return __builtin_clz(val);
#else
uint32_t i;
for (i = 0; i < 32; i++)
{
if (val & CO_BIT(31 - i))
break;
}
return i;
#endif // defined(__arm__)
}
/**
****************************************************************************************
* @brief Count trailing zeros.
* @param[in] val Value to count the number of trailing zeros on.
* @return Number of trailing zeros when value is written as 32 bits.
****************************************************************************************
*/
__INLINE uint32_t co_ctz(uint32_t val)
{
#if defined(__arm__)
return __builtin_ctz(val);
#elif defined(__GNUC__)
if (val == 0)
{
return 32;
}
return __builtin_ctz(val);
#else
uint32_t i;
for (i = 0; i < 32; i++)
{
if (val & CO_BIT(i))
break;
}
return i;
#endif // defined(__arm__)
}
/**
****************************************************************************************
* @brief Function to initialize the random seed.
* @param[in] seed The seed number to use to generate the random sequence.
****************************************************************************************
*/
void co_random_init(uint32_t seed);
//{
// srand(seed);
//}
///**
// ****************************************************************************************
// * @brief Function to get an 8 bit random number.
// * @return Random byte value.
// ****************************************************************************************
// */
uint8_t co_rand_byte(void);
//{
// return (uint8_t)(rand() & 0xFF);
//}
///**
// ****************************************************************************************
// * @brief Function to get an 16 bit random number.
// * @return Random half word value.
// ****************************************************************************************
// */
uint16_t co_rand_hword(void);
//{
// return (uint16_t)(rand() & 0xFFFF);
//}
///**
// ****************************************************************************************
// * @brief Function to get an 32 bit random number.
// * @return Random word value.
// ****************************************************************************************
// */
uint32_t co_rand_word(void);
//{
// return (uint32_t)rand();
//}
/**
****************************************************************************************
* @brief Function to return the smallest of 2 unsigned 32 bits words.
* @return The smallest value.
****************************************************************************************
*/
__INLINE uint32_t co_min(uint32_t a, uint32_t b)
{
return a < b ? a : b;
}
/**
****************************************************************************************
* @brief Function to return the smallest of 2 signed 32 bits words.
* @return The smallest value.
****************************************************************************************
*/
__INLINE int32_t co_min_s(int32_t a, int32_t b)
{
return a < b ? a : b;
}
/**
****************************************************************************************
* @brief Function to return the greatest of 2 unsigned 32 bits words.
* @return The greatest value.
****************************************************************************************
*/
__INLINE uint32_t co_max(uint32_t a, uint32_t b)
{
return a > b ? a : b;
}
/**
****************************************************************************************
* @brief Function to return the absolute value of a signed integer.
* @return The absolute value.
****************************************************************************************
*/
__INLINE int co_abs(int val)
{
return (val < 0) ? (0 - val) : val;
}
/// @} CO_MATH
#endif // _CO_MATH_H_
+210 -210
View File
@@ -1,210 +1,210 @@
/**
****************************************************************************************
*
* @file co_time.h
*
* @brief The Common Time module provides information about the device time and a
* scheduler for timers used by the different modules. It maintains a list of
* pending timers sorted by ascending expiration time. One timer is programmed
* at a given time. A callback is associated with each timer and is called upon
* expiration of the timer.
*
* Timers shall be used for non real time software.
*
* Copyright (C) RivieraWaves 2009-2019
*
****************************************************************************************
*/
#ifndef _CO_TIME_H_
#define _CO_TIME_H_
/**
****************************************************************************************
* @defgroup CO_TIME Utilities
* @ingroup COMMON
* @brief Time utilities
*
* This module contains the Common time utilities functions and macros.
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // standard definitions
#include <stddef.h> // standard definitions
/*
* MACRO DEFINITIONS
****************************************************************************************
*/
/*
* ENUMERATIONS DEFINITIONS
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Function to called once timer expires
*
* @param[in] p_env Pointer to environment that will be used as callback parameter.
****************************************************************************************
*/
typedef void (*co_time_timer_cb)(void* p_env);
/// Timer structure
typedef struct co_time_timer
{
/// Pointer to next timer in timer list
struct co_time_timer * p_next;
/// Pointer to environment that will be used as callback parameter.
void* p_env;
/// Callback to execute in background context upon timer expiration
co_time_timer_cb cb;
/// Expiration time [0-31] part (in milliseconds)
uint32_t exp_time_ms_lsb;
/// Timer bit field (@see enum co_time_timer_bf)
uint32_t timer_bf;
} co_time_timer_t;
/// Time Structure
typedef struct co_time
{
/// Current time [0-31] part (in milliseconds)
uint32_t ms_lsb;
/// Current time [32-39] part (in milliseconds)
uint8_t ms_msb;
} co_time_t;
/*
* CONSTANT DECLARATIONS
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize Common time module.
*
* @param[in] init_type Type of initialization (@see enum rwip_init_type)
****************************************************************************************
*/
void co_time_init(uint8_t init_type);
/*
****************************************************************************************
* Time and timer functions
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Retrieve current time in milliseconds.
*
* Time value can be either Up-time of the device or Time since the device has been
* started for the first time.
*
* This depends if system is able to compensate power-off time to update internal time value
*
* @return current time in milliseconds.
*
****************************************************************************************
*/
co_time_t co_time_get(void);
/**
****************************************************************************************
* @brief Retrieve current time in milliseconds.
*
* Compensate device time. This compensation should be done after power-up of the device.
* The time compensation is automatically performed by device when wake-up from sleep mode.
* This function shall be called when no timer are programmed at device start-up.
*
* @param[in] delta_time_ms_lsb Delta time [0-31] part (in milliseconds)
* @param[in] delta_time_ms_msb Delta time [32-39] part (in milliseconds)
****************************************************************************************
*/
// void co_time_compensate(uint32_t delta_time_ms_lsb, uint8_t delta_time_ms_msb);
/**
****************************************************************************************
* @brief Initialize timer structure.
*
* @param[in] p_timer Pointer to the timer structure.
* @param[in] cb Function to be called upon timer expiration.
* @param[in] p_env Pointer to be passed to the callback
****************************************************************************************
*/
void co_time_timer_init(co_time_timer_t* p_timer, co_time_timer_cb cb, void* p_env);
/**
****************************************************************************************
* @brief Program a timer to be scheduled in the future.
* If timer is already programmed, it is restarted.
* If delay is less than 10ms, delay is set to 10ms.
*
* @param[in] p_timer Pointer to the timer structure.
* @param[in] delay_ms Duration before expiration of the timer (in milliseconds).
****************************************************************************************
*/
void co_time_timer_set(co_time_timer_t* p_timer, uint32_t delay_ms);
/**
****************************************************************************************
* @brief Program a timer to be scheduled in the future with duration greater than 49 days.
* If timer is already programmed, it is restarted.
* If delay is less than 10ms, delay is set to 10ms.
*
* @param[in] p_timer Pointer to the timer structure.
* @param[in] delay_ms_lsb Duration before expiration of the timer [0-31] part (in milliseconds)
* @param[in] delay_ms_msb Duration before expiration of the timer [32-39] part (in milliseconds)
****************************************************************************************
*/
// void co_time_timer_long_set(co_time_timer_t* p_timer, uint32_t delay_ms_lsb, uint8_t delay_ms_msb);
/**
****************************************************************************************
* @brief Program a timer to be scheduled periodically. If timer is already programmed,
* it is restarted.
* If period exceed maximum value, timer is programmed using maximum period.
* If period less than 10ms, period is set to 10ms.
*
* @param[in] p_timer Pointer to the timer structure.
* @param[in] period_ms Periodic duration (in milliseconds). Range [10, 48388607] max ~2 hours
****************************************************************************************
*/
// void co_time_timer_periodic_set(co_time_timer_t* p_timer, uint32_t period_ms);
/**
****************************************************************************************
* @brief Stop a programmed timer.
*
* @param[in] p_timer Pointer to the timer structure.
****************************************************************************************
*/
void co_time_timer_stop(co_time_timer_t* p_timer);
/// @} CO_TIME
#endif // _CO_TIME_H_
/**
****************************************************************************************
*
* @file co_time.h
*
* @brief The Common Time module provides information about the device time and a
* scheduler for timers used by the different modules. It maintains a list of
* pending timers sorted by ascending expiration time. One timer is programmed
* at a given time. A callback is associated with each timer and is called upon
* expiration of the timer.
*
* Timers shall be used for non real time software.
*
* Copyright (C) RivieraWaves 2009-2019
*
****************************************************************************************
*/
#ifndef _CO_TIME_H_
#define _CO_TIME_H_
/**
****************************************************************************************
* @defgroup CO_TIME Utilities
* @ingroup COMMON
* @brief Time utilities
*
* This module contains the Common time utilities functions and macros.
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // standard definitions
#include <stddef.h> // standard definitions
/*
* MACRO DEFINITIONS
****************************************************************************************
*/
/*
* ENUMERATIONS DEFINITIONS
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Function to called once timer expires
*
* @param[in] p_env Pointer to environment that will be used as callback parameter.
****************************************************************************************
*/
typedef void (*co_time_timer_cb)(void* p_env);
/// Timer structure
typedef struct co_time_timer
{
/// Pointer to next timer in timer list
struct co_time_timer * p_next;
/// Pointer to environment that will be used as callback parameter.
void* p_env;
/// Callback to execute in background context upon timer expiration
co_time_timer_cb cb;
/// Expiration time [0-31] part (in milliseconds)
uint32_t exp_time_ms_lsb;
/// Timer bit field (@see enum co_time_timer_bf)
uint32_t timer_bf;
} co_time_timer_t;
/// Time Structure
typedef struct co_time
{
/// Current time [0-31] part (in milliseconds)
uint32_t ms_lsb;
/// Current time [32-39] part (in milliseconds)
uint8_t ms_msb;
} co_time_t;
/*
* CONSTANT DECLARATIONS
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize Common time module.
*
* @param[in] init_type Type of initialization (@see enum rwip_init_type)
****************************************************************************************
*/
void co_time_init(uint8_t init_type);
/*
****************************************************************************************
* Time and timer functions
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Retrieve current time in milliseconds.
*
* Time value can be either Up-time of the device or Time since the device has been
* started for the first time.
*
* This depends if system is able to compensate power-off time to update internal time value
*
* @return current time in milliseconds.
*
****************************************************************************************
*/
co_time_t co_time_get(void);
/**
****************************************************************************************
* @brief Retrieve current time in milliseconds.
*
* Compensate device time. This compensation should be done after power-up of the device.
* The time compensation is automatically performed by device when wake-up from sleep mode.
* This function shall be called when no timer are programmed at device start-up.
*
* @param[in] delta_time_ms_lsb Delta time [0-31] part (in milliseconds)
* @param[in] delta_time_ms_msb Delta time [32-39] part (in milliseconds)
****************************************************************************************
*/
// void co_time_compensate(uint32_t delta_time_ms_lsb, uint8_t delta_time_ms_msb);
/**
****************************************************************************************
* @brief Initialize timer structure.
*
* @param[in] p_timer Pointer to the timer structure.
* @param[in] cb Function to be called upon timer expiration.
* @param[in] p_env Pointer to be passed to the callback
****************************************************************************************
*/
void co_time_timer_init(co_time_timer_t* p_timer, co_time_timer_cb cb, void* p_env);
/**
****************************************************************************************
* @brief Program a timer to be scheduled in the future.
* If timer is already programmed, it is restarted.
* If delay is less than 10ms, delay is set to 10ms.
*
* @param[in] p_timer Pointer to the timer structure.
* @param[in] delay_ms Duration before expiration of the timer (in milliseconds).
****************************************************************************************
*/
void co_time_timer_set(co_time_timer_t* p_timer, uint32_t delay_ms);
/**
****************************************************************************************
* @brief Program a timer to be scheduled in the future with duration greater than 49 days.
* If timer is already programmed, it is restarted.
* If delay is less than 10ms, delay is set to 10ms.
*
* @param[in] p_timer Pointer to the timer structure.
* @param[in] delay_ms_lsb Duration before expiration of the timer [0-31] part (in milliseconds)
* @param[in] delay_ms_msb Duration before expiration of the timer [32-39] part (in milliseconds)
****************************************************************************************
*/
// void co_time_timer_long_set(co_time_timer_t* p_timer, uint32_t delay_ms_lsb, uint8_t delay_ms_msb);
/**
****************************************************************************************
* @brief Program a timer to be scheduled periodically. If timer is already programmed,
* it is restarted.
* If period exceed maximum value, timer is programmed using maximum period.
* If period less than 10ms, period is set to 10ms.
*
* @param[in] p_timer Pointer to the timer structure.
* @param[in] period_ms Periodic duration (in milliseconds). Range [10, 48388607] max ~2 hours
****************************************************************************************
*/
// void co_time_timer_periodic_set(co_time_timer_t* p_timer, uint32_t period_ms);
/**
****************************************************************************************
* @brief Stop a programmed timer.
*
* @param[in] p_timer Pointer to the timer structure.
****************************************************************************************
*/
void co_time_timer_stop(co_time_timer_t* p_timer);
/// @} CO_TIME
#endif // _CO_TIME_H_
File diff suppressed because it is too large Load Diff
+46 -46
View File
@@ -1,46 +1,46 @@
/**
****************************************************************************************
*
* @file co_version.h
*
* @brief Version definitions for BT5.1
*
* Copyright (C) RivieraWaves 2009-2018
*
*
****************************************************************************************
*/
#ifndef _CO_VERSION_H_
#define _CO_VERSION_H_
/**
****************************************************************************************
* @defgroup CO_VERSION Version Defines
* @ingroup COMMON
*
* @brief Bluetooth Controller Version definitions.
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "co_bt.h" // BT standard definitions
/// RWBT SW Major Version
#define RWBT_SW_VERSION_MAJOR (BT52_VERSION)
/// RWBT SW Minor Version
#define RWBT_SW_VERSION_MINOR 0
/// RWBT SW Build Version
#define RWBT_SW_VERSION_BUILD 4
/// RWBT SW Major Version
#define RWBT_SW_VERSION_SUB_BUILD 0
/// @} CO_VERSION
#endif // _CO_VERSION_H_
/**
****************************************************************************************
*
* @file co_version.h
*
* @brief Version definitions for BT5.1
*
* Copyright (C) RivieraWaves 2009-2018
*
*
****************************************************************************************
*/
#ifndef _CO_VERSION_H_
#define _CO_VERSION_H_
/**
****************************************************************************************
* @defgroup CO_VERSION Version Defines
* @ingroup COMMON
*
* @brief Bluetooth Controller Version definitions.
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "co_bt.h" // BT standard definitions
/// RWBT SW Major Version
#define RWBT_SW_VERSION_MAJOR (BT52_VERSION)
/// RWBT SW Minor Version
#define RWBT_SW_VERSION_MINOR 0
/// RWBT SW Build Version
#define RWBT_SW_VERSION_BUILD 4
/// RWBT SW Major Version
#define RWBT_SW_VERSION_SUB_BUILD 0
/// @} CO_VERSION
#endif // _CO_VERSION_H_