本文整理汇总了C++中osal_memset函数的典型用法代码示例。如果您正苦于以下问题:C++ osal_memset函数的具体用法?C++ osal_memset怎么用?C++ osal_memset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了osal_memset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: zllSampleLight_SceneStoreCB
/*********************************************************************
* @fn zllSampleLight_SceneStoreCB
*
* @brief Callback from the ZCL General Cluster Library when
* it received a Scene Store Request Command for
* this application.
* Stores current attributes in the scene's extension fields.
* Extension field sets =
* {{Cluster ID 1, length 1, {extension field set 1}}, {{Cluster ID 2,
* length 2, {extension field set 2}}, ...}
*
* @param pReq - pointer to a request holding scene data
*
* @return TRUE if extField is filled out, FALSE if not filled
* and there is no need to save the scene
*/
static uint8 zllSampleLight_SceneStoreCB( zclSceneReq_t *pReq )
{
uint8 *pExt;
pReq->scene->extLen = SAMPLELIGHT_SCENE_EXT_FIELD_SIZE;
pExt = pReq->scene->extField;
// Build an extension field for On/Off cluster
*pExt++ = LO_UINT16( ZCL_CLUSTER_ID_GEN_ON_OFF );
*pExt++ = HI_UINT16( ZCL_CLUSTER_ID_GEN_ON_OFF );
*pExt++ = sizeof(zllSampleLight_OnOff); // length
// Store the value of onOff attribute
*pExt++ = zllSampleLight_OnOff;
#ifdef ZCL_LEVEL_CTRL
// Build an extension field for Level Control cluster
*pExt++ = LO_UINT16( ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL );
*pExt++ = HI_UINT16( ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL );
*pExt++ = sizeof(zclLevel_CurrentLevel); // length
// Store the value of currentLevel attribute
*pExt++ = zclLevel_CurrentLevel;
#endif //ZCL_LEVEL_CTRL
#ifdef ZCL_COLOR_CTRL
// Build an extension field for Color Control cluster
*pExt++ = LO_UINT16( ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL );
*pExt++ = HI_UINT16( ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL );
*pExt++ = COLOR_SCN_X_Y_ATTRS_SIZE + COLOR_SCN_HUE_SAT_ATTRS_SIZE + COLOR_SCN_LOOP_ATTRS_SIZE; // length
// Restored color mode is determined by whether stored currentX, currentY values are 0.
if ( zclColor_ColorMode == COLOR_MODE_CURRENT_X_Y )
{
*pExt++ = LO_UINT16( zclColor_CurrentX );
*pExt++ = HI_UINT16( zclColor_CurrentX );
*pExt++ = LO_UINT16( zclColor_CurrentY );
*pExt++ = HI_UINT16( zclColor_CurrentY );
pExt += COLOR_SCN_HUE_SAT_ATTRS_SIZE + COLOR_SCN_LOOP_ATTRS_SIZE; // ignore other parameters
}
else
{
// nullify currentX and currentY to mark hue/sat color mode
osal_memset( pExt, 0x00, COLOR_SCN_X_Y_ATTRS_SIZE );
pExt += COLOR_SCN_X_Y_ATTRS_SIZE;
*pExt++ = LO_UINT16( zclColor_EnhancedCurrentHue );
*pExt++ = HI_UINT16( zclColor_EnhancedCurrentHue );
*pExt++ = zclColor_CurrentSaturation;
*pExt++ = zclColor_ColorLoopActive;
*pExt++ = zclColor_ColorLoopDirection;
*pExt++ = LO_UINT16( zclColor_ColorLoopTime );
*pExt++ = HI_UINT16( zclColor_ColorLoopTime );
}
#endif //ZCL_COLOR_CTRL
// Add more clusters here
return ( TRUE );
}
示例2: MT_UtilBindAddEntry
/***************************************************************************************************
* @fn MT_UtilBindAddEntry
*
* @brief Add Binding Entry into Local Table.
*
* @param pBuf - pointer to the received buffer
*
* @return void
***************************************************************************************************/
static void MT_UtilBindAddEntry(uint8 *pBuf)
{
uint8 srcEp;
zAddrType_t dstAddr;
uint8 dstEp;
uint8 numClusterIds;
uint16 *clusterIds;
uint8 buf[sizeof(BindingEntry_t)];
uint8 cmdId = pBuf[MT_RPC_POS_CMD1];
pBuf += MT_RPC_FRAME_HDR_SZ;
// Initialize the return buffer
osal_memset( buf, 0xFF, sizeof(BindingEntry_t) );
buf[2] = 0xFE; // set the default value of INVALID_NODE_ADDR
buf[3] = 0xFF; // set the default value of INVALID_NODE_ADDR
srcEp = *pBuf++;
// Destination Address mode
dstAddr.addrMode = *pBuf++;
// Destination Address
if ( dstAddr.addrMode == Addr64Bit )
{
uint8 *ptr; // Use this additional pointer because *pBuf is incremented later for both cases
ptr = pBuf;
osal_cpyExtAddr( dstAddr.addr.extAddr, ptr );
}
else
{
dstAddr.addr.shortAddr = BUILD_UINT16( pBuf[0], pBuf[1] );
}
// The short address occupies LSB two bytes
pBuf += Z_EXTADDR_LEN;
// DstEPInt
dstEp = *pBuf++;
numClusterIds = *pBuf++;
if ( numClusterIds > 0 )
{
// copy list of clusters
clusterIds = (uint16 *)osal_mem_alloc( numClusterIds * sizeof(uint16) );
osal_memcpy( clusterIds, pBuf, numClusterIds * sizeof(uint16));
if ( clusterIds != NULL )
{
// The response to MT interface has to be pack into buf
packBindEntry_t( buf, bindAddEntry( srcEp, &dstAddr, dstEp, numClusterIds, clusterIds ));
osal_mem_free( clusterIds );
}
}
MT_BuildAndSendZToolResponse( ( (uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_UTIL ),
cmdId, sizeof(BindingEntry_t), buf );
}
示例3: Wechat_Init
/*********************************************************************
* @fn Wechat_Init
*
* @brief Initialization function for the BLE wechat App Task.
* This is called during initialization and should contain
* any application specific initialization (ie. hardware
* initialization/setup, table initialization, power up
* notificaiton ... ).
*
* @param none
*
* @return none
*/
uint8 Wechat_Init( void )
{
uint8 stat = SUCCESS;
osal_memset( wechatStoreAuth, 0, (sizeof(attHandleValueInd_t) * WECHAT_AUTH_STORE_MAX) );
Wechat_state_reset();
stat = Wechat_get_md5();
return stat;
}
示例4: timeAppDiscStart
/*********************************************************************
* @fn timeAppDiscStart()
*
* @brief Start service discovery.
*
*
* @return New discovery state.
*/
uint8 timeAppDiscStart( void )
{
// Clear handle cache
osal_memset( timeAppHdlCache, 0, sizeof(timeAppHdlCache) );
// Start discovery with first service
return timeAppDiscGattMsg( DISC_CURR_TIME_START, NULL );
}
示例5: glucoseDiscStart
/*********************************************************************
* @fn glucoseDiscStart()
*
* @brief Start service discovery.
*
*
* @return New discovery state.
*/
uint8 glucoseDiscStart( void )
{
// Clear handle cache
osal_memset( glucoseHdlCache, 0, sizeof(glucoseHdlCache) );
// Start discovery with first service
return glucoseDiscGattMsg( DISC_GLUCOSE_START, NULL );
}
示例6: softCmdDiscStart
/*********************************************************************
* @fn softCmdDiscStart()
*
* @brief Start service discovery.
*
*
* @return New discovery state.
*/
static uint8 softCmdDiscStart( void )
{
// Clear handle cache
osal_memset( softCmdHdlCache, 0, sizeof(softCmdHdlCache) );
// Start discovery with first service
return softCmdDiscGenCtrl( DISC_GEN_CTRL_START, NULL );
}
示例7: osal_mem_free
/*********************************************************************
* @fn osal_mem_free
*
* @brief Implementation of the de-allocator functionality.
*
* @param ptr - pointer to the memory to free.
*
* @return void
*/
void osal_mem_free( void *ptr )
{
osalMemHdr_t *currHdr;
halIntState_t intState;
#if ( OSALMEM_GUARD )
// Try to protect against premature use by HAL / OSAL.
if ( ready != OSALMEM_READY )
{
osal_mem_init();
}
#endif
HAL_ENTER_CRITICAL_SECTION( intState ); // Hold off interrupts.
OSALMEM_ASSERT( ptr );
currHdr = (osalMemHdr_t *)ptr - 1;
// Has this block already been freed?
OSALMEM_ASSERT( *currHdr & OSALMEM_IN_USE );
*currHdr &= ~OSALMEM_IN_USE;
#if ( OSALMEM_PROFILER )
{
uint16 size = *currHdr;
byte idx;
for ( idx = 0; idx < OSALMEM_PROMAX; idx++ )
{
if ( size <= proCnt[idx] )
{
break;
}
}
proCur[idx]--;
}
#endif
#if ( OSALMEM_METRICS )
memAlo -= *currHdr;
blkFree++;
#endif
if ( ff1 > currHdr )
{
ff1 = currHdr;
}
#if ( OSALMEM_PROFILER )
osal_memset( (byte *)currHdr+HDRSZ, OSALMEM_REIN, (*currHdr - HDRSZ) );
#endif
HAL_EXIT_CRITICAL_SECTION( intState ); // Re-enable interrupts.
}
示例8: znpTestRF
/**************************************************************************************************
* @fn znpTestRF
*
* @brief This function initializes and checks the ZNP RF Test Mode NV items. It is designed
* to be invoked before/instead of MAC radio initialization.
*
* input parameters
*
* None.
*
* output parameters
*
* None.
*
* @return None.
*/
void znpTestRF(void)
{
uint8 rfTestParms[4] = { 0, 0, 0, 0 };
if ((SUCCESS != osal_nv_item_init(ZNP_NV_RF_TEST_PARMS, 4, rfTestParms)) ||
(SUCCESS != osal_nv_read(ZNP_NV_RF_TEST_PARMS, 0, 4, rfTestParms)) ||
(rfTestParms[0] == 0))
{
return;
}
// Settings from SmartRF Studio
MDMCTRL0 = 0x85;
RXCTRL = 0x3F;
FSCTRL = 0x5A;
FSCAL1 = 0x2B;
AGCCTRL1 = 0x11;
ADCTEST0 = 0x10;
ADCTEST1 = 0x0E;
ADCTEST2 = 0x03;
FRMCTRL0 = 0x43;
FRMCTRL1 = 0x00;
MAC_RADIO_RXTX_OFF();
MAC_RADIO_SET_CHANNEL(rfTestParms[1]);
MAC_RADIO_SET_TX_POWER(rfTestParms[2]);
TX_PWR_TONE_SET(rfTestParms[3]);
switch (rfTestParms[0])
{
case 1: // Rx promiscuous mode.
MAC_RADIO_RX_ON();
break;
case 2: // Un-modulated Tx.
TX_PWR_MOD__SET(1);
// no break;
case 3: // Modulated Tx.
// Modulated is default register setting, so no special action.
// Now turn on Tx power for either mod or un-modulated Tx test.
MAC_RADIO_TX_ON();
break;
default: // Not expected.
break;
}
// Clear the RF test mode.
(void)osal_memset(rfTestParms, 0, 4);
(void)osal_nv_write(ZNP_NV_RF_TEST_PARMS, 0, 4, rfTestParms);
while (1); // Spin in RF test mode until a hard reset.
}
示例9: lock_init
void lock_init(void)
{
uint8 read_tmp[6] = {0};
uint8 use_lock_times[2] = {0};
uint8 ret8;
osal_memset(read_tmp, '0', sizeof(read_tmp));
ret8 = osal_snv_write(admin_flash_start_addr, sizeof(read_tmp), read_tmp);
if(ret8 == NV_OPER_FAILED)
return;
osal_memset(read_tmp, '1', sizeof(read_tmp));
ret8 = osal_snv_write(user_flash_start_addr, sizeof(read_tmp), read_tmp);
if(ret8 == NV_OPER_FAILED)
return;
osal_memcpy(read_tmp, ssid, 6);
ret8 = osal_snv_write(ssid_flash_start_addr, sizeof(read_tmp), read_tmp);
if(ret8 == NV_OPER_FAILED)
return;
osal_memcpy(scanRspData + 2, read_tmp, 6);
osal_memcpy(attDeviceName, read_tmp, 6);
GAP_UpdateAdvertisingData( simpleBLEPeripheral_TaskID, FALSE, sizeof( scanRspData ), scanRspData );
GGS_SetParameter( GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName );
osal_memset(read_tmp, '0', sizeof(read_tmp));
ret8 = osal_snv_write(dead_date_flash_start_addr, sizeof(read_tmp), read_tmp);
if(ret8 == NV_OPER_FAILED)
return;
osal_memset(read_tmp, '0', sizeof(read_tmp));
ret8 = osal_snv_write(carlock_id_flash_start_addr, sizeof(read_tmp), read_tmp);
if(ret8 == NV_OPER_FAILED)
return;
osal_memset(use_lock_times, 0, sizeof(use_lock_times));
ret8 = osal_snv_write(use_lock_times_start_addr, sizeof(use_lock_times), use_lock_times);
if(ret8 == NV_OPER_FAILED)
return;
HAL_SYSTEM_RESET();//reset
}
示例10: zclCCServer_SendLeaveReq
/*********************************************************************
* @fn zclCCServer_SendLeaveReq
*
* @brief Send out a Leave Request command.
*
* @param void
*
* @return ZStatus_t
*/
static ZStatus_t zclCCServer_SendLeaveReq( void )
{
NLME_LeaveReq_t leaveReq;
// Set every field to 0
osal_memset( &leaveReq, 0, sizeof( NLME_LeaveReq_t ) );
// Send out our leave
return ( NLME_LeaveReq( &leaveReq ) );
}
示例11: zdo_MTCB_MgmtRtgRspCB
/*********************************************************************
* @fn zdo_MTCB_MgmtRtgRspCB()
*
* @brief
*
* Called to send MT callback response for Management Network
* Discover response
*
* @param SrcAddr - Source address
* @param Status - response status
*
* @return none
*/
void zdo_MTCB_MgmtRtgRspCB( uint16 SrcAddr, byte Status,
byte RtgCount, byte StartIndex,
byte RtgListCount, rtgItem_t *pList )
{
byte *msgPtr;
byte *msg;
byte len;
byte x;
/*Allocate a message of size equivalent to the corresponding SPI message
(plus a couple of bytes for MT use)so that the same buffer can be sent by
MT to the test tool by simply setting the header bytes.*/
/*In order to allocate the message , we need to know the length and this
has to be calculated before we allocate the message*/
len = 2 + 1 + 1 + 1 + 1 + (ZDP_RTG_DISCRIPTOR_SIZE * ZDO_MAX_RTG_ITEMS);
// SrcAddr + Status + RtgCount + StartIndex + RtgListCount
// + (maximum entries * size of struct)
msgPtr = osal_mem_alloc( len );
if ( msgPtr )
{
msg = msgPtr;
//Fill up the data bytes
*msg++ = HI_UINT16( SrcAddr );
*msg++ = LO_UINT16( SrcAddr );
*msg++ = Status;
*msg++ = RtgCount;
*msg++ = StartIndex;
*msg++ = RtgListCount;
osal_memset( msg, 0, (ZDP_RTG_DISCRIPTOR_SIZE * ZDO_MAX_RTG_ITEMS) );
for ( x = 0; x < ZDO_MAX_RTG_ITEMS; x++ )
{
if ( x < RtgListCount )
{
*msg++ = HI_UINT16( pList->dstAddress );
*msg++ = LO_UINT16( pList->dstAddress );
*msg++ = HI_UINT16( pList->nextHopAddress );
*msg++ = LO_UINT16( pList->nextHopAddress );
*msg++ = pList->status;
pList++;
}
}
MT_BuildAndSendZToolCB( SPI_CB_ZDO_MGMT_RTG_RSP, len, msgPtr );
osal_mem_free( msgPtr );
}
}
示例12: Thermometer_Init
/*********************************************************************
* @fn Thermometer_Init
*
* @brief Initialization function for the Thermometer App Task.
* This is called during initialization and should contain
* any application specific initialization (ie. hardware
* initialization/setup, table initialization, power up
* notificaiton ... ).
*
* @param task_id - the ID assigned by OSAL. This ID should be
* used to send messages and set timers.
*
* @return none
*/
void Thermometer_Init(uint8 task_id)
{
struct ther_info *ti = &ther_info;
osal_memset(ti, 0, sizeof(struct ther_info));
ti->task_id = task_id;
ti->power_mode = PM_ACTIVE;
osal_set_event(ti->task_id, TH_POWER_ON_EVT);
}
示例13: osalInitTasks
/*********************************************************************
* @fn osalInitTasks
*
* @brief This function invokes the initialization function for each task.
*
* @param void
*
* @return none
*/
void osalInitTasks( void )
{
uint8 taskID = 0;
tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);
osal_memset( tasksEvents, 0, (sizeof( uint16 ) * tasksCnt));
Hal_Init(taskID++); // HAL should be a higher priority than any ZNP task.
zapInit(taskID++); // ZAP APP should be the highest priority ZNP task.
pulseAppInit(taskID); //MHMS registers endpoint and other initialization stuff
}
示例14: _stp_dbg_disable
static INT32 _stp_dbg_disable (MTKSTP_DBG_T *stp_dbg)
{
osal_lock_unsleepable_lock(&(stp_dbg->logsys->lock));
stp_dbg->pkt_trace_no = 0;
/* [FIXME][George] DANGEROUS CODING to MEMSET A STRUCTURE in a NON-INIT
* or a NON-DEINIT CONTEXT!!!
*/
#if 0
osal_memset(stp_dbg->logsys,0,osal_sizeof(MTKSTP_LOG_SYS_T));
#else
osal_memset(&stp_dbg->logsys->queue[0], 0x0, sizeof(stp_dbg->logsys->queue));
stp_dbg->logsys->size = 0;
stp_dbg->logsys->in = 0;
stp_dbg->logsys->out = 0;
#endif
stp_dbg->is_enable = 0;
osal_unlock_unsleepable_lock(&(stp_dbg->logsys->lock));
return 0;
}
示例15: zclCCServer_UseStartupParameters
/*********************************************************************
* @fn zclCCServer_UseStartupParameters
*
* @brief Set the network parameters to the current Startup Parameters.
*
* @param none
*
* @return none
*/
static void zclCCServer_UseStartupParameters( void )
{
if ( zclCCServer_StartUpControl == CC_STARTUP_CONTROL_OPTION_1 )
{
uint8 networkKey[SEC_KEY_LEN];
// Form the Commissioning network and become the Coordinator for that network
// Required attributes: Extended PAN ID
osal_nv_write( ZCD_NV_EXTENDED_PAN_ID, 0, Z_EXTADDR_LEN,
zclCCServer_ExtendedPanId );
osal_nv_write( ZCD_NV_APS_USE_EXT_PANID, 0, Z_EXTADDR_LEN,
zclCCServer_ExtendedPanId );
// Optional attributes: PAN ID, Channel Mask, Network Manager Address,
// Network Key, Network Key Type (only KEY_TYPE_NWK is currently supported),
// and Trust Center Address (which is used with Preconfigured Link Key).
osal_nv_write( ZCD_NV_PANID, 0, sizeof( zclCCServer_PanId ),
&zclCCServer_PanId );
osal_nv_write( ZCD_NV_CHANLIST, 0, sizeof( zclCCServer_ChannelMask ),
&zclCCServer_ChannelMask );
osal_nv_write( ZCD_NV_NWKMGR_ADDR, 0, sizeof( zclCCServer_NwkManagerAddr ),
&zclCCServer_NwkManagerAddr );
osal_nv_read( ZCD_NV_SAS_CURR_NWK_KEY, 0, SEC_KEY_LEN, networkKey );
if ( !nullKey( networkKey ) )
{
// Save the Network Key as the Pre-Configured Key in NV
osal_nv_write( ZCD_NV_PRECFGKEY, 0, SEC_KEY_LEN, networkKey );
// Clear copy of key in RAM
osal_memset( networkKey, 0x00, SEC_KEY_LEN );
}
}
else if ( zclCCServer_StartUpControl == CC_STARTUP_CONTROL_OPTION_3 )
{
// Join the Commissioning network
// Required attributes: none
// Optional attributes: Extended PAN ID, Channel Mask, and
// Preconfigured Link Key
osal_nv_write( ZCD_NV_EXTENDED_PAN_ID, 0, Z_EXTADDR_LEN,
zclCCServer_ExtendedPanId );
osal_nv_write( ZCD_NV_CHANLIST, 0, sizeof( zclCCServer_ChannelMask ),
&zclCCServer_ChannelMask );
zclCCServer_SavePreconfigLinkKey();
}
}