本文整理汇总了C++中rt_memcpy函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_memcpy函数的具体用法?C++ rt_memcpy怎么用?C++ rt_memcpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rt_memcpy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: si_update_wl_collect_data
/*
* 如果已缓存, 则更新;否则,当有空闲空间时,插入新数据;其他情况返回失败
* */
int si_update_wl_collect_data(char *sn, union sinkinfo_ptc_ctc_st *data, rt_tick_t time_stamp)
{
struct sinkinfo_wl_data_item_st *p;
rt_err_t ret;
if (NULL==sn || NULL==data) {
printf_syn("func:%s(), param is NULL\n", __FUNCTION__);
return FAIL;
}
if (NULL == sink_wl_collect_data) {
printf_syn("func:%s(), sink_wl_collect_data is NULL\n", __FUNCTION__);
return FAIL;
}
ret = rt_sem_take(&sink_wl_data_sem, RT_WAITING_FOREVER);
if (RT_EOK != ret) {
printf_syn("take sink_wl_data_sem fail(%d)\n", ret);
return SIE_FAIL;
}
sinki_debug_data(("func:%s(), line:%d, sn:%s\n", __FUNCTION__, __LINE__, sn));
p = si_lookup_item_in_wl_data(sn);
if (NULL != p) {
#if 0
enum sink_data_dev_type_e dev_type;
dev_type = si_get_dev_type(sn);
if (SDDT_PT == dev_type) {
rt_memcpy(&p->item.ptc_data, &data->ptc_data, sizeof(p->item.ptc_data));
} else if (SDDT_PT == dev_type) {
rt_memcpy(&p->item.ctc_data, &data->ctc_data, sizeof(p->item.ctc_data));
} else {
/* mark by David */
}
#else
rt_memcpy(&p->item, data, sizeof(p->item));
#endif
p->time_stamp = time_stamp;
} else {
si_insert_item_to_wl_data(sn, data, time_stamp);
}
rt_sem_release(&sink_wl_data_sem);
return SUCC;
}
示例2: rt_tetris_update_brick
static rt_err_t rt_tetris_update_brick(rt_tetris_t* thiz)
{
int index;
RT_ASSERT(thiz != RT_NULL);
index = (int)(7.0 * rand()/(RAND_MAX + 1.0));
rt_memcpy(thiz->brick, thiz->next_brick, 4 * sizeof(rt_uint32_t));
rt_memcpy(thiz->next_brick, g_brick[index], 4 * sizeof(rt_uint32_t));
/* update next brick on view */
thiz->view->update_next_brick(thiz->view, thiz);
return RT_EOK;
}
示例3: framebuffer_draw_raw_hline
/* draw raw hline */
static void framebuffer_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y)
{
rt_uint8_t *dst;
dst = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint8_t);
rt_memcpy(dst, pixels, (x2 - x1) * (rtgui_graphic_get_device()->bits_per_pixel/8));
}
示例4: rt_mq_recv
rt_err_t rt_mq_recv (rt_mq_t *mq, void* buffer, rt_size_t size)
{
rt_err_t r;
struct rt_mq_message *msg;
/* mq is empty */
if (mq->entry == 0)
{
return -RT_ETIMEOUT;
}
/* get message from queue */
msg = (struct rt_mq_message*) mq->head;
/* move message queue head */
mq->head = msg->next;
/* reach queue tail, set to NULL */
if (mq->tail == msg) mq->tail = RT_NULL;
/* decrease message entry */
mq->entry --;
/* copy message */
rt_memcpy(buffer, msg + 1, size > mq->msg_size ? (mq->msg_size) : size);
/* put message to free list */
msg->next = (struct rt_mq_message*)mq->free;
mq->free = msg;
return RT_EOK;
}
示例5: miniStm32_oled_control
/***************************************************************************//**
* @brief
* Configure OLED device
*
* @details
*
* @note
*
* @param[in] dev
* Pointer to device descriptor
*
* @param[in] cmd
* IIC control command
*
* @param[in] args
* Arguments
*
* @return
* Error code
******************************************************************************/
static rt_err_t miniStm32_oled_control(rt_device_t dev, int cmd, void *args)
{
switch (cmd)
{
case RTGRAPHIC_CTRL_RECT_UPDATE:
// miniStm32_oled_update((struct rt_device_rect_info *)args);
oled_debug("OLED: update\n");
break;
case RTGRAPHIC_CTRL_POWERON:
break;
case RTGRAPHIC_CTRL_POWEROFF:
break;
case RTGRAPHIC_CTRL_GET_INFO:
{
struct rt_device_graphic_info oled_info = {
RTGRAPHIC_PIXEL_FORMAT_MONO, // pixel_format
1, // bits_per_pixel
0, // reserved
MINISTM32_OLED_WIDTH, // width
MINISTM32_OLED_HEIGHT, // height
RT_NULL // framebuffer
};
rt_memcpy(args, &oled_info, sizeof(oled_info));
break;
}
case RTGRAPHIC_CTRL_SET_MODE:
break;
}
return RT_EOK;
}
示例6: rt_stm32_eth_tx
/* transmit packet. */
rt_err_t rt_stm32_eth_tx( rt_device_t dev, struct pbuf* p)
{
rt_err_t ret;
struct pbuf *q;
uint32_t l = 0;
u8 *buffer ;
if (( ret = rt_sem_take(&tx_wait, netifGUARD_BLOCK_TIME) ) == RT_EOK)
{
buffer = (u8 *)(DMATxDescToSet->Buffer1Addr);
for(q = p; q != NULL; q = q->next)
{
//show_frame(q);
rt_memcpy((u8_t*)&buffer[l], q->payload, q->len);
l = l + q->len;
}
if( ETH_Prepare_Transmit_Descriptors(l) == ETH_ERROR )
rt_kprintf("Tx Error\n");
//rt_sem_release(xTxSemaphore);
rt_sem_release(&tx_wait);
//rt_kprintf("Tx packet, len = %d\n", l);
}
else
{
rt_kprintf("Tx Timeout\n");
return ret;
}
/* Return SUCCESS */
return RT_EOK;
}
示例7: rt_memcpy
struct rtgui_dc *rtgui_dc_buffer_create_from_dc(struct rtgui_dc* dc)
{
struct rtgui_dc_buffer *buffer;
if (dc == RT_NULL)
return RT_NULL;
if (dc->type == RTGUI_DC_BUFFER)
{
struct rtgui_dc_buffer *d = (struct rtgui_dc_buffer*) dc;
/* buffer clone */
buffer = (struct rtgui_dc_buffer*)rtgui_dc_buffer_create_pixformat(d->pixel_format,
d->width,
d->height);
if (buffer != RT_NULL)
{
rt_memcpy(buffer->pixel, d->pixel, d->pitch * d->height);
return RTGUI_DC(buffer);
}
}
return RT_NULL;
}
示例8: rtgui_recv_filter
rt_err_t rtgui_recv_filter(rt_uint32_t type, rtgui_event_t *event, rt_size_t event_size)
{
rtgui_event_t *e;
struct rtgui_app *app;
RT_ASSERT(event != RT_NULL);
RT_ASSERT(event_size != 0);
app = (struct rtgui_app *)(rt_thread_self()->user_data);
if (app == RT_NULL)
return -RT_ERROR;
e = (rtgui_event_t*)&app->event_buffer[0];
while (rt_mq_recv(app->mq, e, sizeof(union rtgui_event_generic), RT_WAITING_FOREVER) == RT_EOK)
{
if (e->type == type)
{
rt_memcpy(event, e, event_size);
return RT_EOK;
}
else
{
if (RTGUI_OBJECT(app)->event_handler != RT_NULL)
{
RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), e);
}
}
}
return -RT_ERROR;
}
示例9: si_insert_item_to_wl_data
/*
* 将新数据插入到下标最小的空位置
* */
static int si_insert_item_to_wl_data(char *sn, union sinkinfo_ptc_ctc_st *data, rt_tick_t time_stamp)
{
int i;
struct sinkinfo_wl_data_item_st *p;
/* 查找是否已存储到缓冲区 */
p = sink_wl_collect_data;
for (i=0; i<SINKINFO_WL_DATA_ITEM_MAX_NO; ++i) {
if ('\0' == p->pt_ct_sn[0])
break;
++p;
}
if (i < SINKINFO_WL_DATA_ITEM_MAX_NO) {
rt_strncpy(p->pt_ct_sn, sn, sizeof(p->pt_ct_sn));
rt_memcpy(&p->item, data, sizeof(p->item));
p->time_stamp = time_stamp;
sinki_debug_data(("func:%s(), inser data sn:%s\n", __FUNCTION__, sn));
} else {
printf_syn("func:%s(), wl-data-buffer is full\n", __FUNCTION__);
return FAIL;
}
return SUCC;
}
示例10: SendNullPacket
/**
* @brief This function tells firmware to send a NULL data packet.
*
* @param priv A pointer to wlan_private structure
* @param flags Trasnit Pkt Flags
* @return n/a
*/
int SendNullPacket(WlanCard *cardinfo, struct pbuf *packet, u8 flags)
{
WlanCard *card = cardinfo;
TxPD txpd;
int ret = WLAN_STATUS_SUCCESS;
u8 *ptr = card->TmpTxBuf;
if (card->MediaConnectStatus == WlanMediaStateDisconnected)
{
ret = WLAN_STATUS_FAILURE;
WlanDebug(WlanErr,"NULL packet wlan did not connect\r\n");
goto done;
}
rt_memset(&txpd, 0, sizeof(TxPD));
txpd.TxControl = card->PktTxCtrl;
txpd.Flags = flags;
txpd.Priority = WMM_HIGHEST_PRIORITY;
txpd.TxPacketLocation = sizeof(TxPD);
rt_memcpy(ptr, &txpd, sizeof(TxPD));
ret = sbi_host_to_card(card, MVMS_DAT, card->TmpTxBuf, sizeof(TxPD));
if (ret != 0)
{
WlanDebug(WlanErr,"TX Error: SendNullPacket failed!\n");
goto done;
}
WlanDebug(WlanMsg,"Null data => FW\n");
done:
return ret;
}
示例11: wlan_get_Mac_Address
int wlan_get_Mac_Address(WlanCard *cardinfo)
{
WlanCard *card = cardinfo;
HostCmd_DS_COMMAND *CmdPtr = NULL;
HostCmd_DS_GET_HW_SPEC *hwspec;
int ret = WLAN_STATUS_SUCCESS;
rt_memset(card->MyMacAddress, 0xff, MRVDRV_ETH_ADDR_LEN);
CmdPtr = rt_malloc(sizeof(HostCmd_DS_COMMAND));
if (CmdPtr == NULL)
{
WlanDebug(WlanErr,"memory allocate failed for Get Mac\r\n");
return WLAN_STATUS_FAILURE;
}
/* Set sequence number, command and INT option */
card->SeqNum++;
CmdPtr->SeqNum = card->SeqNum;
CmdPtr->Command = HostCmd_CMD_GET_HW_SPEC;
CmdPtr->Result = 0;
hwspec = &CmdPtr->params.hwspec;
CmdPtr->Size = sizeof(HostCmd_DS_GET_HW_SPEC) + S_DS_GEN;
rt_memcpy(hwspec->PermanentAddr, card->MyMacAddress, MRVDRV_ETH_ADDR_LEN);
ret = WlanExecuteCommand(cardinfo, CmdPtr);
if (ret)
{
WlanDebug(WlanErr,"Falure for Get Mac\r\n");
ret = WLAN_STATUS_FAILURE;
}
rt_free(CmdPtr);
return ret;
}
示例12: si_get_item_in_wl_data
int si_get_item_in_wl_data(char *sn, union sinkinfo_ptc_ctc_st *item, rt_tick_t *time_stamp)
{
rt_err_t sem_ret;
struct sinkinfo_wl_data_item_st *p;
int ret = SUCC;
if (NULL==sn || NULL==item || NULL==time_stamp) {
printf_syn("func:%s(), param is NULL\n", __FUNCTION__);
return FAIL;
}
sem_ret = rt_sem_take(&sink_wl_data_sem, RT_WAITING_FOREVER);
if (RT_EOK != sem_ret) {
printf_syn("take sink_wl_data_sem fail(%d)\n", ret);
return FAIL;
}
p = si_lookup_item_in_wl_data(sn);
if (NULL == p) {
ret = FAIL;
} else {
rt_memcpy(item, &p->item, sizeof(*item));
*time_stamp = p->time_stamp;
}
rt_sem_release(&sink_wl_data_sem);
return ret;
}
示例13: rt_dram_write
static rt_size_t rt_dram_write (rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
{
uint8_t *p;
p = (uint8_t*)((uint32_t)DRAMStartAddr + pos * RAM_SECTOR_SIZE);
rt_memcpy(p, buffer, size * RAM_SECTOR_SIZE);
return size;
}
示例14: make_int32
int make_int32(char* ptr)
{
int ret = 0;
int temp = 0;//(short)*ptr;
rt_memcpy((char*)&temp,(char*)ptr,4);
ret = (int)ntohl((u_int)temp);
return ret;
}
示例15: make_int16
short make_int16(char* ptr)
{
short ret = 0;
short temp = 0;//(short)*ptr;
rt_memcpy((char*)&temp,(char*)ptr,2);
ret = (short)ntohs((u_short)temp);
return ret;
}