HOLDINGS API

First, the information management API

osal_msg_allocate () Function Prototype: task is assigned a message buffer, or when the task calls the function is called, the space is filled with information or call information transmission function osal_msg_send () to send information to other tasks buffer space, the buffer space if not is allocated, the empty set msg_ptr = NULL;
         uint8 * osal_msg_allocate (UInt16 len), a pointer is returned, if returned is empty, the cache space allocation failure message.

   Note: This function does not () confused with osal_mem_alloc, osal_mem_alloc () function is used to allocate a buffer to transmit information between tasks. This function can be assigned a storage space.

2.osal_msg_deallocate () information processing allocation cache. This function finishes processing the information received through a call to a task.

        uint8 osal_msg_deallocate( uint8 *msg_ptr )

msg_ptr point needs the cached information pointer assignment process

Success; invalid information pointer; the cache is queued.
 
 
 3. osal_msg_send () sends a command or task to another task or data processing element.

uint8 osal_msg_send(uint8 destination_task, uint8 *msg_ptr )


 

4.osal_msg_receive () accepts a task order information call the function

           uint8 *osal_msg_receive(uint8 task_id )

Return value is a pointer to a buffer containing the message or NULL if there is no received message.

5. osal_msg_find( )

osal_event_hdr_t *osal_msg_find(uint8 task_id, uint8 event)

This function searches for an existing OSAL message matching the task_id and event parameters

Second, the task synchronization API: allows a task waiting for an event to occur and returns control during the wait

作用:set events for a task and notify the task once any event is set

1.osal_set_event( ) :set the event flags for a task

uint8 osal_set_event(uint8 task_id, uint16 event_flag ) 其中event_flag is a 2-byte bitmap ,每位对应一个事件
 There is only one system event (SYS_EVENT_MSG), the rest of the events/bits are defined by the receiving task


Third, the time management API
This API allows the timer to be used inside and outside the task, having a start and stop a timer function of the timer can be ,, 1 millisecond increments.
1.osal_start_timerEx () to start the timer
uint8 osal_start_timerEx (uint8 taskID, uint16 event_id , uint16 timeout_value);
 


Osal_start_reload_timer 2. ()
uint8 osal_start_reload_timer (uint8 taskID, UInt16 the event_id, UInt16 to timeout_value);
  setting set an event bit and automatically reload counter


3.osal_stop_timerEx () has been activated to stop the timer
uint8 osal_stop_timerEx (uint8 task_id, uint16 event_id );

4.osal_GetSystemClock () reads the system clock
uint32 osal_GetSystemClock (void);
Return Value: The system clock in milliseconds.
Fourth, interrupt management API: task and the external interrupt interface that allows a specified task assigned to each interrupt service routine
1. osal_int_enable () allows interrupt
uint8 osal_int_enable (uint8 interrupt_id)

2. osal_int_disable () prohibits an interrupt
 uint8 osal_int_disable (uint8 interrupt_id)
 

 V. Task Manager API: Tasks for adding and managing osal in each task by the initialization function and event handlers composition.
The OSAL Calls osalInitTasks () [file application Supplied] to the initialize The Tasks and the OSAL uses A Task Table (const pTaskEventHandlerFn tasksArr []) to Call The Event Processor for each Task (Also file application Supplied).
Example of A Task Table Implementation: 
 
const pTaskEventHandlerFn tasksArr [] =  

  macEventLoop, 
  nwk_event_loop, 
  Hal_ProcessEvent, 
  MT_ProcessEvent, 
  APS_event_loop, 
  ZDApp_event_loop, 
};  
const = uint8 tasksCnt the sizeof (tasksArr) / the sizeof (tasksArr [0]); calculated number of array elements
1.osal_init_system () initializes osal system: in It must be called before starting any OSAL

uint8 osal_init_system (void) Returns the value of "SUCCESS"

The main loop function 2. osal_start_system () task system

void osal_start_system( void )

3.osal_run_system( ) :void osal_run_system( void )

4.osal_self () returns the currently running task ID number: uint8 osal_self (void)


 Sixth, memory management API: simple storage allocation system. Allow dynamic memory allocation

1.osal_mem_alloc () function is a simple memory allocation, if a cache points to the successful implementation of the returned pointer

void * osal_mem_alloc (uint16 size); untyped pointer to a new cache area is allocated

2. osal_mem_free () releases the storage space allocated to prepare again used, only the storage space is released () allocated osal_mem_alloc

void osal_mem_free( void *ptr );

Seven, power management API: When OSPL safety shut-off receiver and external hardware, and the processor to sleep mode, to provide a method to inform the event to the application / task

osal_pwrmgr_device(), osal_pwrmgr_task_state( PWRMGR_HOLD )

1. osal_pwrmgr_init (): void osal_pwrmgr_init (void); Do not call this function, as it has been called in osal_init_system () in

2. osal_pwrmgr_powerconserve (): void osal_pwrmgr_powerconserve (void); enter power-down mode

Do not call this function, it is already called in the OSAL main loop [osal_start_system()].

3.osal_pwrmgr_device( ) :void osal_pwrmgr_device( uint8 pwrmgr_device );

Function when the power supply state or the power supply needs to change to call, the device may be provided for power management ON / OFF state, the control function should be a difference in the call center such ZDO.


4.osal_pwrmgr_task_state (): uint8 osal_pwrmgr_task_state (uint8 task_id, uint8 state);
is called for each task, whether the task requires energy-saving declaration, when the task is created, the default energy-saving mode, if the total need for energy conservation, you do not need to call the function.
state:

Return value
eight, a nonvolatile memory managing the API: the API Non-Volatile Memory
NV function is designed to read the entry of any user-defined data types such as a queue structure or composition, flash or EEPROM


NV Each entry has a unique ID number, but there are regulations and restrictions
 1.osal_nv_item_init (): initialize a mesh. This function checks an existing entry, if it does not exist, it is created and initialized with the data carried in the call osal_nv_read for each entry () or osal_nv_write before (), this function must be called

uint8 osal_nv_item_init (uint16 id, uint16 len, void * buf); initialization data entry pointer


2.osal_nv_read (): uint8 osal_nv_read (uint16 id, uint16 offset, uint16 len, void * buf);
read data from nv. read an entire item from NV or an element of an item by indexing into the item with an offset. Copy the data to read * buf buffer
 


 3.osal_nv_write (): write data to the NV. uint8 osal_nv_write (uint16 id, uint16 offset, uint16 len, void * buf);

write an entire item to NV or an element of an item by indexing into the item with an offset


4.osal_nv_delete (): Delete the entry from nv. uint8 osal_nv_delete (uint16 id, uint16 len );
This function checks an existing entry, if it exists, and its length matches the length provided in the function call , the entry is removed from nv. 

5.osal_nv_item_len (): uint16 osal_nv_item_len (uint16 id); get an entry in the NV length

6.osal_offsetof (): This macro calculates the size of a structure is defined in memory offset (byte) osal_offsetof (type, Member)
 Calculating Parameter The offset is useful in NV API function.
Nine, simply NV storage API:
. Like at The OSAL NV Memory System, at The the Simple NV Memory System the Provides A Way for Applications to Store Information INTO at The Device's Memory persistently the On at The OTHER Hand, that Unlike at The OSAL NV Memory System, at The the Simple NV Memory SIMPLER much to the Provides the API System the Drive file application code size and code size Down Stack the AS AS the Well the code size of 
the OSAL the Simple System Implementation NV. the user may read but can not write an entire entry part of the entry.

 1.osal_snv_read (): uint8 osal_snv_read (osalSnvId_t id, osalSnvLen_t len, void * pBuf); read data from the nv

 2.osal_snv_write (): write data to Nv: uint8 osal_snv_write (osalSnvId_t id, osalSnvLen_t len, void * pBuf);

 Ten, OSAL clock system: to provide a method and apparatus for maintaining the date time, This system will keep the number of seconds since 0 hrs, 0 minutes, 0 seconds on 1 January 2000 UTC, two data types are defined in the structure or OSAL_Clock .h in
typedef UInt32 either UTCTime; // Used with the To BE, the in Addition, the this does Not Maintain Feature Sleeping Time Devices for
typedef struct 

  uint8 seconds the; // 0-59 
  uint8 minutes; // 0-59 
  uint8 hour; // 0-23 
  uint8 Day; // 0-30 
  uint8 month the; // 0-11 
  UInt16 year; // 2000+ 
} UTCTimeStruct;
 1.osalTimeUpdate (): from osal_run_system () to update the run time, void osalTimeUpdate (void);
this function reads the number of MAC 320usec ticks to maintain the OSAL Clock time. Do not call this function anywhere else
2.osal_setClock (): initialize the device time. osal_setClock void (UTCTime NewTime)
3.osal_getClock (): call this function to get the current time of the device. UTCTime osal_getClock (void);

4.osal_ConvertUTCTime (): a function to convert UTCTime of UTCTimeStruct

void osal_ConvertUTCTime( UTCTimeStruct * tm, UTCTime secTime );

5.osal_ConvertUTCSecs (): UTCTimeStruct converted into a function UTCTime

UTCTime osal_ConvertUTCSecs( UTCTimeStruct * tm );

Eleven, OSAL Misc Miscellaneous:

This section describes miscellaneous OSAL functions that do not fit into the previous OSAL categories

OSAL previously described is not suitable for diverse types of OSAL function.

1.osal_rand (): returns a 16-bit random number uint16 osal_rand (void);

2. osal_memcmp (): compare memory section.

uint8 osal_memcmp( const void GENERIC *src1, const void GENERIC *src2, unsigned int len );

Return Values: TRUE - same, FALSE - different

3.osal_memset( ):void *osal_memset( void *dest, uint8 value, int len );

功能Sets a buffer to a specific value,返回值Pointer to where in the buffer this function stopped

4.osal_memcpy( ) :void *osal_memcpy( void *dst, const void GENERIC *src, unsigned int len );

Function Copies one buffer to another buffer, End of Where do you want to return Buffer Pointer
--------------------- 
Author: DreamingCatcher 
Source: CSDN 
Original: https: // blog. csdn.net/derricker406/article/details/74963442 
Disclaimer: This article is a blogger original article, reproduced, please attach Bowen link!

Published 25 original articles · won praise 4 · views 20000 +

Guess you like

Origin blog.csdn.net/zhou8400/article/details/90408210
API