📄 sys_module.h
字号:
* \param dst_mod_id ID of the destination module * * \param type Unique message identifier. Kernel message types are defined in * message_types.h * * \param size Size of the payload (in bytes) that is being dispatched as a * part of the message * * \param *data Pointer to the payload buffer that is dispatched in the * message. * * \param flag Control scheduler priority, memory management properties of * payload. Check message_types.h * * \param dst_node_addr Destination node address * * \return SOS_OK on success, -ENOMEM on failure * * Other than directing the message the radio, this message is the same as * sys_post * */#define sys_post_net(dst_mod_id, type, size, data, flag, dst_node_addr) sys_post_link((dst_mod_id), (type), (size), (data), ((flag) | SOS_MSG_RADIO_IO), (dst_node_addr))/** * Post a message with payload over UART * * \param dst_mod_id ID of the destination module * * \param type Unique message identifier. Kernel message types are defined in * message_types.h * * \param size Size of the payload (in bytes) that is being dispatched as a * part of the message * * \param *data Pointer to the payload buffer that is dispatched in the * message. * * \param flag Control scheduler priority, memory management properties of * payload. Check message_types.h * * \param dst_node_addr Destination node address * * \return SOS_OK on success, -ENOMEM on failure * * Other than directing the message the UART, this message is the same as * sys_post * */#define sys_post_uart(dst_mod_id, type, size, data, flag, dst_node_addr) sys_post_link((dst_mod_id), (type), (size), (data), ((flag) | SOS_MSG_UART_IO), (dst_node_addr))/** * Post a message with payload over I2C * * \param dst_mod_id ID of the destination module * * \param type Unique message identifier. Kernel message types are defined in * message_types.h * * \param size Size of the payload (in bytes) that is being dispatched as a * part of the message * * \param *data Pointer to the payload buffer that is dispatched in the * message. * * \param flag Control scheduler priority, memory management properties of * payload. Check message_types.h * * \param dst_node_addr Destination node address * * \return SOS_OK on success, -ENOMEM on failure * * Other than directing the message the the I2C, this message is the same as * sys_post * */#define sys_post_i2c(dst_mod_id, type, size, data, flag, dst_node_addr) sys_post_link((dst_mod_id), (type), (size), (data), ((flag) | SOS_MSG_I2C_IO), (dst_node_addr))/// \cond NOTYPEDEF typedef int8_t (* sys_post_value_ker_func_t)( sos_pid_t dst_mod_id, uint8_t type, uint32_t data, uint16_t flag );/// \endcond/** * Post up to 4 bytes by value * * \param dst_mod_id ID of the destination module * * \param type Unique message identifier. Kernel message types are defined in * message_types.h * * \param data Data to send directly in the message * * \param flag Control scheduler priority, memory management properties of * payload. Check message_types.h * * \return SOS_OK on success, -ENOMEM on failure * * \note This call is used to dispatch messages which have a very small * payloads by value. Single values can be passed directily (with a type * cast). Multiple small values can be passed, but the end user must pack and * unpack this data by hand. * */static inline int8_t sys_post_value( sos_pid_t dst_mod_id, uint8_t type, uint32_t data, uint16_t flag ){#ifdef SYS_JUMP_TBL_START return ((sys_post_value_ker_func_t)(SYS_JUMP_TBL_START+SYS_JUMP_TBL_SIZE*10))( dst_mod_id, type, data, flag );#else return ker_sys_post_value( dst_mod_id, type, data, flag );#endif}/* @} *//** * \ingroup system_api * \defgroup nodeInfo Node Info * Functions that provide information about a node. * @{ *//// \cond NOTYPEDEF typedef uint16_t (* sys_hw_type_ker_func_t)( void ); /// \endcond /** * Node hardware type * * \return ID of hardware type * * Returns an ID describing the hardware type of the node. Common hardware * types include: * * * \li Mica2 -> 1 * * \li MicaZ -> 2 * * \li Tmote -> 6 * * * The detailed listing of hardware types is available in sos_info.h * */static inline uint16_t sys_hw_type( void ) {#ifdef SYS_JUMP_TBL_START return ((sys_hw_type_ker_func_t)(SYS_JUMP_TBL_START+SYS_JUMP_TBL_SIZE*11))( ); #else return ker_hw_type();#endif} /// \cond NOTYPEDEF typedef uint16_t (* sys_id_ker_func_t)( void ); /// \endcond /** * * Node ID * * \return ID of the node * * Returns the node's ID. This ID, much like an IP address, is the identifier * for the node in the network. A node's ID is set at compile time by * specifying: * * \verbatim make mica2 install ADDRESS=<node_address> \endverbatim * * when building the image for the node. The address is explicitly set in the * binary loaded onto the node using $(ROOTDIR)/tools/admin/set-mote-id * utility. * */static inline uint16_t sys_id( void ){#ifdef SYS_JUMP_TBL_START return ((sys_id_ker_func_t)(SYS_JUMP_TBL_START+SYS_JUMP_TBL_SIZE*12))( );#else return ker_id();#endif}/* @} *//** * \ingroup system_api * \defgroup random Random Numbers * Functions to generate random numbers. * @{ *//// \cond NOTYPEDEFtypedef uint16_t (* sys_rand_ker_func_t)( void );/// \endcond/** * * Random number * * \return Pseudo-random number * * Very simple random number generator. * */static inline uint16_t sys_rand( void ){#ifdef SYS_JUMP_TBL_START return ((sys_rand_ker_func_t)(SYS_JUMP_TBL_START+SYS_JUMP_TBL_SIZE*13))();#else return ker_rand();#endif}/* @} *//** * \ingroup system_api * \defgroup sysTime System Time * Functions to access the node system time * @{ *//// \cond NOTYPEDEFtypedef uint32_t (* sys_time32_ker_func_t)( void );/// \endcond/** * * Get CPU "time" * * \return Current CPU clock value * */static inline uint32_t sys_time32( void ) {#ifdef SYS_JUMP_TBL_START return ((sys_time32_ker_func_t)(SYS_JUMP_TBL_START+SYS_JUMP_TBL_SIZE*14))( );#else return ker_systime32();#endif}/* @} *//** * \ingroup system_api * \defgroup sensing Sensing * Function to sample sensor readings * * @{ *//// \cond NOTYPEDEFtypedef int8_t (* sys_sensor_get_data_ker_func_t)( uint8_t sensor_id );/// \endcond/** * Get sensor readings * \return SOS_OK for success. The reading will appear as message typed MSG_DATA_READY. */static inline int8_t sys_sensor_get_data( uint8_t sensor_id ){#ifdef SYS_JUMP_TBL_START return ((sys_sensor_get_data_ker_func_t)(SYS_JUMP_TBL_START+SYS_JUMP_TBL_SIZE*15))( sensor_id );#else return ker_sys_sensor_get_data( sensor_id );#endif}/* @} *//** * \ingroup system_api * \defgroup leds LED functions * * @{ *//// \cond NOTYPEDEF/** * Function for setting leds for debugging */typedef void (* sys_led_ker_func_t)( uint8_t op );/// \endcond/** * * LEDs * * \param op Bitmask used to turn on and off LEDs. * \return Zero * * Legal values of op on the mica2 node incnlude: * * \li LED_RED_ON * \li LED_GREEN_ON * \li LED_YELLOW_ON * \li LED_RED_OFF * \li LED_GREEN_OFF * \li LED_YELLOW_OFF * \li LED_RED_TOGGLE * \li LED_GREEN_TOGGLE * \li LED_YELLOW_TOGGLE * * */static inline void sys_led( uint8_t op ){#ifdef SYS_JUMP_TBL_START ((sys_led_ker_func_t)(SYS_JUMP_TBL_START+SYS_JUMP_TBL_SIZE*16))( op );#else ker_led( op );#endif}/* @} *//** * \ingroup system_api * \defgroup modst Module State * * @{ *//// \cond NOTYPEDEFtypedef void* (* sys_get_module_state_func_t)( void );/// \endcond/** * Get module specific state * This is mainly used in dynamic functions */static inline void* sys_get_state( void ){#ifdef SYS_JUMP_TBL_START return ((sys_get_module_state_func_t)(SYS_JUMP_TBL_START+SYS_JUMP_TBL_SIZE*17))( );#else return ker_sys_get_module_state();#endif}/* @} *//** * \ingroup system_api * \ingroup dymfunc * @{ *//// \cond NOTYPEDEFtypedef int8_t (* sys_fntable_subscribe_func_t)( sos_pid_t pub_pid, uint8_t fid, uint8_t table_index );/// \endcondstatic inline int8_t sys_fntable_subscribe( sos_pid_t pub_pid, uint8_t fid, uint8_t table_index ){#ifdef SYS_JUMP_TBL_START return ((sys_fntable_subscribe_func_t)(SYS_JUMP_TBL_START+SYS_JUMP_TBL_SIZE*18))(pub_pid, fid, table_index);#else return ker_sys_fntable_subscribe( pub_pid, fid, table_index );#endif}/* @} */typedef int8_t (* sys_change_own_func_t)( void* ptr );static inline int8_t sys_change_own( void* ptr ){#ifdef SYS_JUMP_TBL_START return ((sys_change_own_func_t)(SYS_JUMP_TBL_START+SYS_JUMP_TBL_SIZE*19))(ptr);#else return ker_sys_change_own( ptr );#endif}typedef int8_t (* sys_codemem_read_func_t)(codemem_t h, void *buf, uint16_t nbytes, uint16_t offset);static inline int8_t sys_codemem_read(codemem_t h, void *buf, uint16_t nbytes, uint16_t offset){#ifdef SYS_JUMP_TBL_START return ((sys_codemem_read_func_t)(SYS_JUMP_TBL_START+SYS_JUMP_TBL_SIZE*21))(h, buf, nbytes, offset);#else return ker_sys_codemem_read(h, buf, nbytes, offset);#endif}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -