• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ rt_memset函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中rt_memset函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_memset函数的具体用法?C++ rt_memset怎么用?C++ rt_memset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了rt_memset函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: stm32f4xx_sdio_init

rt_int32_t stm32f4xx_sdio_init(void)
{
    struct rt_mmcsd_host *host;
    NVIC_InitTypeDef NVIC_InitStructure;

    host = mmcsd_alloc_host();
    if (!host)
    {
        return -RT_ERROR;
    }

    stm32f4_sdio = rt_malloc(sizeof(struct stm32f4xx_sdio));
    if (!stm32f4_sdio)
    {
        rt_kprintf("alloc stm32f4_sdio failed\n");
        goto err;
    }

    rt_memset(stm32f4_sdio, 0, sizeof(struct stm32f4xx_sdio));

    host->ops = &ops;
    host->freq_min = 375000;
    host->freq_max = 25000000;
    host->valid_ocr = VDD_32_33 | VDD_33_34;
    host->flags = MMCSD_BUSWIDTH_4 | MMCSD_MUTBLKWRITE;
    host->max_seg_size = 65535;
    host->max_dma_segs = 2;
    host->max_blk_size = 512;
    host->max_blk_count = 4096;

    stm32f4_sdio->host = host;

    SDIO_StructInit(&SDIO_InitStructure);
    /* SDIO Peripheral Low Level Init */
    SD_LowLevel_Init();

    NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);

    host->private_data = stm32f4_sdio;

    mmcsd_change(host);

    return 0;

err:
    mmcsd_free_host(host);

    return -RT_ENOMEM;
}
开发者ID:CHINAoneBOY,项目名称:rt-thread-stm32f405-enc28j60-,代码行数:53,代码来源:stm32f4xx_sd.c


示例2: lzo

int lzo(char *srcfile, char *destfile)
{
	int result;
	int fd;
	struct stat s;
	lzo_bytep in;
	lzo_bytep out;
	lzo_uint in_len, out_len;

	rt_memset(&s, 0, sizeof(struct stat));
	stat(srcfile, &s);
	in_len = s.st_size; 
	
	in = rt_malloc(in_len); 
	if (in == RT_NULL) return -1;
	out = rt_malloc(LZO1X_WORST(in_len));
	if (out == RT_NULL)	return -1;

	fd = open(srcfile, O_RDONLY, 0);
	if(fd < 0) 
	{
		result = -1;
		goto _exit;
	}
	read(fd, in, in_len); 
	close(fd);

	result = lzo1x_1_compress(in, in_len, out, &out_len, wrkmem);
	if(result != LZO_E_OK)
	{
		rt_kprintf("internal error - compression failed: \nerr_code:(%d) %s, %s.\n", 
			result, parse_lzo_error_code(result), "Please use the binary access");
		goto _exit;
	}

	fd = open(destfile, O_WRONLY | O_BINARY | O_CREAT, 0);
	if(fd < 0)
	{
		result = -1;
		goto _exit;
	}
	
	write(fd, &in_len, sizeof(lzo_uint));	/* source file len */
	write(fd, out, out_len); 
	close(fd);
	rt_kprintf("compress lzo ok!\n");
	result = 0;

_exit:
	rt_free(in);
	rt_free(out);
	return result;
}
开发者ID:634351070,项目名称:rt-thread,代码行数:53,代码来源:lzo.c


示例3: pthread_mutex_destroy

int pthread_mutex_destroy(pthread_mutex_t *mutex)
{
	if (!mutex || mutex->attr == -1) return EINVAL;

	/* it's busy */
	if (mutex->lock.owner != RT_NULL) return EBUSY;

	rt_memset(mutex, 0, sizeof(pthread_mutex_t));
	mutex->attr = -1;

	return 0;
}
开发者ID:CollinsLiu,项目名称:rt-thread-pc,代码行数:12,代码来源:pthread_mutex.c


示例4: calculate_array

void calculate_array(uint8_t num)
{ 
	uint16_t k = 0;
	uint16_t *p ;
	float sum = 0.0f;
	if(num >= scheme_max ) num = scheme_max - 1;
	
	rt_memset(array_buf, 0, array_num*2);//将数组清0
	p = array_buf;
	
	linear_offset( p , 0,
		program_data[num].percent[0], 
		program_data[num].t[0]*2);
	p += program_data[num].t[0]*2;
	for(k = 0; k < 15; k++)//0-14
	{	
		linear_offset( p , program_data[num].percent[k] ,
		program_data[num].percent[k+1], 
		(program_data[num].t[k+1] - program_data[num].t[k])*2);
		p += (program_data[num].t[k+1] - program_data[num].t[k])*2;//50us间隔

	}
	for(k = 0; k <array_num; k++ )
	{
		pwm_struct[num].p_array[k] = (float)array_buf[k]/1000; 
	}
	
	pwm_struct[num].p_array[499] = 0.0f;//数组最后一字节为0;
	
	for(k = 499; k > 0; k--)
	{
		if(pwm_struct[num].p_array[k] > 0.0f)
		{
			pwm_struct[num].positive_pulse = k+1;
			break;
		}
//		pwm_struct[num].positive_pulse = 500;
	}
	
//	pwm_struct[num].negative_pulse = 20;
	for(k = 0; k < 500; k++)
	{
		sum += pwm_struct[num].p_array[k] * program_data[num].current_max ;//usSRegHoldBuf[current_peak];
	}
	pwm_struct[num].negative_pulse = (uint16_t)(sum/12.5f) + 20;
	usSRegHoldBuf[frq_max] = 200000/(pwm_struct[num].negative_pulse + pwm_struct[num].positive_pulse);
	if(usSRegHoldBuf[frq_max] >1000)
	{
		usSRegHoldBuf[frq_max] = 1000;
	}
	pwm_struct[num].negative_pulse = 200000/usSRegHoldBuf[frq_max] - pwm_struct[num].positive_pulse;
	pwm_struct[num].mode = program_data[num].feedback_mode; 
}
开发者ID:dlts200466,项目名称:lamp,代码行数:53,代码来源:functions.c


示例5: sdio_io_send_op_cond

rt_int32_t sdio_io_send_op_cond(struct rt_mmcsd_host *host, rt_uint32_t ocr, rt_uint32_t 
*cmd5_resp)
{
	struct rt_mmcsd_cmd cmd;
	rt_int32_t i, err = 0;

	RT_ASSERT(host != RT_NULL);

	rt_memset(&cmd, 0, sizeof(struct rt_mmcsd_cmd));

	cmd.cmd_code = SD_IO_SEND_OP_COND;
	cmd.arg = ocr;
	cmd.flags = RESP_SPI_R4 | RESP_R4 | CMD_BCR;

	for (i = 100; i; i--) 
	{
		err = mmcsd_send_cmd(host, &cmd, 0);
		if (err)
			break;

		/* if we're just probing, do a single pass */
		if (ocr == 0)
			break;

		/* otherwise wait until reset completes */
		if (controller_is_spi(host)) 
		{
			/*
			 * Both R1_SPI_IDLE and MMC_CARD_BUSY indicate
			 * an initialized card under SPI, but some cards
			 * (Marvell's) only behave when looking at this
			 * one.
			 */
			if (cmd.resp[1] & CARD_BUSY)
				break;
		} 
		else 
		{
			if (cmd.resp[0] & CARD_BUSY)
				break;
		}

		err = -RT_ETIMEOUT;

		mmcsd_delay_ms(10);
	}

	if (cmd5_resp)
		*cmd5_resp = cmd.resp[controller_is_spi(host) ? 1 : 0];

	return err;
}
开发者ID:AlexL871,项目名称:rt-thread-stm32f4discovery,代码行数:52,代码来源:sdio.c


示例6: finsh_wait_auth

static void finsh_wait_auth(void)
{
    char ch;
    rt_bool_t input_finish = RT_FALSE;
    char password[FINSH_PASSWORD_MAX] = { 0 };
    rt_size_t cur_pos = 0;
    /* password not set */
    if (rt_strlen(finsh_get_password()) == 0) return;
    
    while (1)
    {
        rt_kprintf("Password for login: ");
        while (!input_finish)
        {
            while (1)
            {
                /* read one character from device */
                ch = finsh_getchar();

                if (ch >= ' ' && ch <= '~' && cur_pos < FINSH_PASSWORD_MAX)
                {
                    /* change the printable characters to '*' */
                    rt_kprintf("*");
                    password[cur_pos++] = ch;
                }
                else if (ch == '\b' && cur_pos > 0)
                {
                    /* backspace */
                    password[cur_pos] = '\0';
                    cur_pos--;
                    rt_kprintf("\b \b");
                }
                else if (ch == '\r' || ch == '\n')
                {
                    rt_kprintf("\n");
                    input_finish = RT_TRUE;
                    break;
                }
            }
        }
        if (!rt_strncmp(shell->password, password, FINSH_PASSWORD_MAX)) return;
        else
        {
            /* authentication failed, delay 2S for retry */
            rt_thread_delay(2 * RT_TICK_PER_SECOND);
            rt_kprintf("Sorry, try again.\n");
            cur_pos = 0;
            input_finish = RT_FALSE;
            rt_memset(password, '\0', FINSH_PASSWORD_MAX);
        }
    }
}
开发者ID:onelife,项目名称:rt-thread,代码行数:52,代码来源:shell.c


示例7: _rt_thread_init

static rt_err_t _rt_thread_init(struct rt_thread *thread,
                                const char       *name,
                                void (*entry)(void *parameter),
                                void             *parameter,
                                void             *stack_start,
                                rt_uint32_t       stack_size,
                                rt_uint8_t        priority,
                                rt_uint32_t       tick)
{
    /* init thread list */
    rt_list_init(&(thread->tlist));

    thread->entry = (void *)entry;
    thread->parameter = parameter;

    /* stack init */
    thread->stack_addr = stack_start;
    thread->stack_size = (rt_uint16_t)stack_size;

    /* init thread stack */
    rt_memset(thread->stack_addr, '#', thread->stack_size);
    thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter,
        (void *)((char *)thread->stack_addr + thread->stack_size - 4),
        (void *)rt_thread_exit);

    /* priority init */
    RT_ASSERT(priority < RT_THREAD_PRIORITY_MAX);
    thread->init_priority    = priority;
    thread->current_priority = priority;

    /* tick init */
    thread->init_tick      = tick;
    thread->remaining_tick = tick;

    /* error and flags */
    thread->error = RT_EOK;
    thread->stat  = RT_THREAD_INIT;

    /* initialize cleanup function and user data */
    thread->cleanup   = 0;
    thread->user_data = 0;

    /* init thread timer */
    rt_timer_init(&(thread->thread_timer),
                  thread->name,
                  rt_thread_timeout,
                  thread,
                  0,
                  RT_TIMER_FLAG_ONE_SHOT);

    return RT_EOK;
}
开发者ID:1847123212,项目名称:SFUD,代码行数:52,代码来源:thread.c


示例8: tcp_senddata

void tcp_senddata(const char* url, int port, int length)
{
	struct hostent *host;
	int sock, err, result, timeout, index;
	struct sockaddr_in server_addr;
	rt_uint8_t *buffer_ptr;

	/* 通过函数入口参数url获得host地址(如果是域名,会做域名解析) */
	host = gethostbyname(url);
	/* 创建一个socket,类型是SOCKET_STREAM,TCP类型 */
	if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
	{
		/* 创建socket失败 */
		rt_kprintf("Socket error\n");
		return;
	}

	/* 神奇内存 */
	buffer_ptr = rt_malloc(length);
	/* 构造发生数据 */
	for (index = 0; index < length; index ++)
		buffer_ptr[index] = index & 0xff;

	timeout = 100;
	/* 设置发送超时时间100ms */
	lwip_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout));
	/* 初始化预连接的服务端地址 */
	server_addr.sin_family = AF_INET;
	server_addr.sin_port = htons(port);
	server_addr.sin_addr = *((struct in_addr *)host->h_addr);
	rt_memset(&(server_addr.sin_zero), 0, sizeof(server_addr.sin_zero));

	/* 连接到服务端 */
	err = connect(sock, (struct sockaddr *)&server_addr, sizeof(struct sockaddr));
	rt_kprintf("TCP thread connect error code: %d\n", err);

	while(1)
	{
		/* 发送数据到sock连接 */
		result = send(sock, buffer_ptr, length, MSG_DONTWAIT);
		if(result == -1) //数据发送错误处理
		{
			rt_kprintf("TCP thread send error: %d\n", result);
			lwip_close(sock);	//关闭连接,重新创建连接
			rt_thread_delay(10);
			if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
				rt_kprintf("TCP Socket error:%d\n",sock);
			err = connect(sock, (struct sockaddr *)&server_addr, sizeof(struct sockaddr));
			rt_kprintf("TCP thread connect error code: %d\n", err);
		}
	}
}
开发者ID:634351070,项目名称:rt-thread,代码行数:52,代码来源:tcpsendpacket.c


示例9: disk_ioctl

/* Miscellaneous Functions */
DRESULT disk_ioctl(BYTE drv, BYTE ctrl, void *buff)
{
	rt_device_t device = disk[drv];

	if (device == RT_NULL)
		return RES_ERROR;

	if (ctrl == GET_SECTOR_COUNT)
	{
		struct rt_device_blk_geometry geometry;

		rt_memset(&geometry, 0, sizeof(geometry));
		rt_device_control(device, RT_DEVICE_CTRL_BLK_GETGEOME, &geometry);

		*(DWORD *)buff = geometry.sector_count;
		if (geometry.sector_count == 0)
			return RES_ERROR;
	}
	else if (ctrl == GET_SECTOR_SIZE)
	{
		struct rt_device_blk_geometry geometry;

		rt_memset(&geometry, 0, sizeof(geometry));
		rt_device_control(device, RT_DEVICE_CTRL_BLK_GETGEOME, &geometry);

		*(WORD *)buff = geometry.bytes_per_sector;
	}
	else if (ctrl == GET_BLOCK_SIZE) /* Get erase block size in unit of sectors (DWORD) */
	{
		struct rt_device_blk_geometry geometry;

		rt_memset(&geometry, 0, sizeof(geometry));
		rt_device_control(device, RT_DEVICE_CTRL_BLK_GETGEOME, &geometry);

		*(DWORD *)buff = geometry.block_size/geometry.bytes_per_sector;
	}

	return RES_OK;
}
开发者ID:comrid1987,项目名称:jb3500,代码行数:40,代码来源:dfs_elm.c


示例10: _rtgui_listctrl_get_scrollbar_rect

static void _rtgui_listctrl_get_scrollbar_rect(struct rtgui_listctrl* ctrl, rtgui_rect_t* rect)
{
	rtgui_widget_get_rect(RTGUI_WIDGET(ctrl), rect);
	if (ctrl->items_count > rtgui_rect_height(*rect)/rtgui_theme_get_selected_height())
	{
		rect->x1 = rect->x2 - 8;
	}
	else
	{
		/* no scrollbar */
		rt_memset(rect, 0, sizeof(rtgui_rect_t));
	}
}
开发者ID:lyyyuna,项目名称:rtt_ex,代码行数:13,代码来源:listctrl.c


示例11: lua_msh

static  void lua_msh(int argc, char **argv)
{
	rt_thread_t lua_thread;
	const char* device_name = finsh_get_device();
	rt_device_t device = rt_device_find(device_name);
	if (device == RT_NULL)
	{
		rt_kprintf("%s not find\n", device_name);
		return;
	}
	dev4lua.device = device;

	/*prepare parameters*/
	struct para *parameters = rt_malloc(sizeof(struct para));
	if ( parameters == NULL ){
		rt_kprintf("malloc failed at file: %s,line: %d", __FILE__, __LINE__);
		return;
	}
	//parameters->argc = 2;
	parameters->argc = argc;
	char **arg = parameters->argv;

	arg[0] = "lua";
	if (argc > 1){
		rt_size_t len = strnlen(argv[1], 50);
		arg[1] = rt_malloc(len + 1);
		if (arg[1] == NULL ){
			rt_kprintf("malloc failed at file: %s,line: %d", __FILE__, __LINE__);
			return;
		}
		rt_memset(arg[1], 0, len+1);
		strncpy(arg[1], argv[1], len);
	}else{
		arg[1] = NULL;
	}
	arg[2] = NULL;

	
	/* Run lua interpreter in separate thread */
	lua_thread = rt_thread_create("lua_msh",
			(void (*)(void *))(finsh_lua),
			(void*)parameters,
			10240,
			rt_thread_self()->current_priority + 1,
			20);
	if (lua_thread != RT_NULL)
	{
		rt_thread_startup(lua_thread);
	}
	return;
}
开发者ID:bbw2008good,项目名称:rt-thread,代码行数:51,代码来源:lua_in_finsh.c


示例12: fd_put

/**
 * @ingroup Fd
 *
 * This function will put the file descriptor.
 */
void fd_put(struct dfs_fd *fd)
{
	RT_ASSERT(fd != RT_NULL);

	dfs_lock();
	fd->ref_count --;

	/* clear this fd entry */
	if (fd->ref_count == 0)
	{
		rt_memset(fd, 0, sizeof(struct dfs_fd));
	}
	dfs_unlock();
};
开发者ID:dlts200466,项目名称:PowerSupply,代码行数:19,代码来源:dfs.c


示例13: rt_malloc

/**
 * This function will contiguously allocate enough space for count objects
 * that are size bytes of memory each and returns a pointer to the allocated
 * memory.
 *
 * The allocated memory is filled with bytes of value zero.
 *
 * @param count number of objects to allocate
 * @param size size of the objects to allocate
 *
 * @return pointer to allocated memory / NULL pointer if there is an error
 */
void *rt_calloc(rt_size_t count, rt_size_t size)
{
    void *p;

    RT_DEBUG_NOT_IN_INTERRUPT;

    /* allocate 'count' objects of size 'size' */
    p = rt_malloc(count * size);

    /* zero the memory */
    if (p) rt_memset(p, 0, count * size);

    return p;
}
开发者ID:comrid1987,项目名称:jb3500,代码行数:26,代码来源:mem.c


示例14: rtgui_touch_hw_init

void rtgui_touch_hw_init(void)
{
	rt_err_t result = RT_FALSE;
	rt_device_t device = RT_NULL;
	struct rt_device_graphic_info info;

	touch = (struct rtgui_touch_device *)rt_malloc(sizeof(struct rtgui_touch_device));
	if (touch == RT_NULL)
		return; /* no memory yet */

	/* clear device structure */
	rt_memset(&(touch->parent), 0, sizeof(struct rt_device));
	touch->calibrating = RT_FALSE;
	touch->min_x = X_MIN;
	touch->max_x = X_MAX;
	touch->min_y = Y_MIN;
	touch->max_y = Y_MAX;
	touch->eventpost_func  = RT_NULL;
	touch->eventpost_param = RT_NULL;

	/* init device structure */
	touch->parent.type = RT_Device_Class_Unknown;
	touch->parent.init = rtgui_touch_init;
	touch->parent.control = rtgui_touch_control;
	touch->parent.user_data = RT_NULL;

	device = rt_device_find("lcd");
	if (device == RT_NULL)
		return; /* no this device */	

	/* get graphic device info */
	result = rt_device_control(device, RTGRAPHIC_CTRL_GET_INFO, &info);
	if (result != RT_EOK)
	{

		/* get device information failed */

		return;
	}

	touch->width = info.width;
	touch->height = info.height;
	
	/* create 1/8 second timer */
	touch->poll_timer = rt_timer_create("touch", touch_timer_fire, RT_NULL,
	                                    RT_TICK_PER_SECOND/8, RT_TIMER_FLAG_PERIODIC);

	/* register touch device to RT-Thread */
	rt_device_register(&(touch->parent), "touch", RT_DEVICE_FLAG_RDWR);
}
开发者ID:lgnq,项目名称:mini2440,代码行数:50,代码来源:touch.c


示例15: uffs_setup_storage

void uffs_setup_storage(struct uffs_StorageAttrSt *attr,
                        struct rt_mtd_nand_device *nand)
{
    rt_memset(attr, 0, sizeof(struct uffs_StorageAttrSt));

//  attr->total_blocks = nand->end_block - nand->start_block + 1;/* no use */
    attr->page_data_size = nand->page_size;                /* page data size */
    attr->pages_per_block = nand->pages_per_block;         /* pages per block */
    attr->spare_size = nand->oob_size;                     /* page spare size */
    attr->ecc_opt = RT_CONFIG_UFFS_ECC_MODE;               /* ecc option */
    attr->ecc_size = 0;                                    /* ecc size is 0 , the uffs will calculate the ecc size*/
    attr->block_status_offs = attr->ecc_size;              /* indicate block bad or good, offset in spare */
    attr->layout_opt = RT_CONFIG_UFFS_LAYOUT;              /* let UFFS do the spare layout */
}
开发者ID:634351070,项目名称:rt-thread,代码行数:14,代码来源:uffs_nandif.c


示例16: dfs_file_close

/**
 * this function will close a file descriptor.
 * 
 * @param fd the file descriptor to be closed.
 *
 * @return 0 on successful, -1 on failed.
 */
int dfs_file_close(struct dfs_fd* fd)
{
	int result = 0;

	if (fd != RT_NULL && fd->fs->ops->close != RT_NULL) result = fd->fs->ops->close(fd);

	/* close fd error, return */
	if ( result < 0 ) return result; 

	rt_free(fd->path);
	rt_memset(fd, 0, sizeof(struct dfs_fd));

	return result;
}
开发者ID:18337129968,项目名称:-android-source-code,代码行数:21,代码来源:dfs_file.c


示例17: rtgui_xml_create

rtgui_xml_t* rtgui_xml_create(rt_size_t buffer_size, rtgui_xml_event_handler_t handler,
	void* user)
{
	rtgui_xml_t* xml = (rtgui_xml_t*) rtgui_malloc(sizeof(struct rtgui_xml));
	rt_memset(xml, 0, sizeof(rtgui_xml_t));

	xml->event_handler = handler;
	xml->user = user;

	/* create buffer */
	xml->buffer_size = buffer_size;
	xml->buffer = (char*)rtgui_malloc(xml->buffer_size);
	return xml;
}
开发者ID:520lly,项目名称:-android-source-code,代码行数:14,代码来源:rtgui_xml.c


示例18: _vsm_get_local_status

int32_t _vsm_get_local_status(vam_stastatus_t *local)
{
	t_nmea_rmc recvGPS;
	if(recvGPS.isTrue){
		nmea_get(&recvGPS, 1);
		local->pos.latitude = recvGPS.latitude;
		local->pos.longitude = recvGPS.longitude ;
		local->speed = recvGPS.speed ;
	}
	else{
		rt_memset(local,0,sizeof(local));
	}
	return RT_EOK ;
}
开发者ID:gexueyuan,项目名称:cct,代码行数:14,代码来源:cv_vam_lip.c


示例19: mmcsd_send_app_op_cond

rt_err_t mmcsd_send_app_op_cond(struct rt_mmcsd_host *host,
                                rt_uint32_t           ocr,
                                rt_uint32_t          *rocr)
{
    struct rt_mmcsd_cmd cmd;
    rt_uint32_t i;
    rt_err_t err = RT_EOK;

    rt_memset(&cmd, 0, sizeof(struct rt_mmcsd_cmd));

    cmd.cmd_code = SD_APP_OP_COND;
    if (controller_is_spi(host))
        cmd.arg = ocr & (1 << 30); /* SPI only defines one bit */
    else
        cmd.arg = ocr;
    cmd.flags = RESP_SPI_R1 | RESP_R3 | CMD_BCR;

    for (i = 100; i; i--) 
    {
        err = mmcsd_send_app_cmd(host, RT_NULL, &cmd, 3);
        if (err)
            break;

        /* if we're just probing, do a single pass */
        if (ocr == 0)
            break;

        /* otherwise wait until reset completes */
        if (controller_is_spi(host)) 
        {
            if (!(cmd.resp[0] & R1_SPI_IDLE))
                break;
        } 
        else 
        {
            if (cmd.resp[0] & CARD_BUSY)
                break;
        }

        err = -RT_ETIMEOUT;

        mmcsd_delay_ms(10); //delay 10ms
    }

    if (rocr && !controller_is_spi(host))
        *rocr = cmd.resp[0];

    return err;
}
开发者ID:634351070,项目名称:rt-thread,代码行数:49,代码来源:sd.c


示例20: rti_free_hook

void rti_free_hook(void *ptr)
{
    rt_uint32_t index;
    struct rti_memtrace_item *item;

    /* get hash item index */
    index = ((rt_uint32_t)ptr) % MEMTRACE_HASH_SIZE;
    if (item_hash[index] != RT_NULL)
    {
        item = item_hash[index];
        if (item->mb_ptr == ptr)
        {
            /* delete item from list */
            item_hash[index] = item->next;
        }
        else
        {
            /* find ptr in list */
            while (item->next != RT_NULL && item->next->mb_ptr != ptr)
                item = item->next;

            /* delete item from list */
            if (item->next != RT_NULL)
            {
                struct rti_memtrace_item *i;

                i = item->next;
                item->next = item->next->next;

                item = i;
            }
            else
            {
                /* not found */
                return;
            }
        }

        /* reduce allocated size */
        mem_info.allocated_size -= item->mb_len;

        /* clear item */
        rt_memset(item, 0, sizeof(struct rti_memtrace_item));

        /* add item to the free list */
        item->next = item_free;
        item_free = item;
    }
}
开发者ID:Cheong2K,项目名称:rt-thread,代码行数:49,代码来源:rtgui_system.c



注:本文中的rt_memset函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rt_mutex_debug_task_free函数代码示例发布时间:2022-05-30
下一篇:
C++ rt_memcpy函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap