可以看到作为继承于object的子类,rt_thread类基本上重写了object相关的所有函数,现在来逐一分析每个函数所做的操作: 一、首先是rt_thread_init()以及rt_thread_create() rt_thread_init()与rt_thread_create()的差异同样是在一个是静态线程的初始化,一个是动态的创建线程,函数内部的差异仅仅是在rt_thread_create(...
RT_ASSERT(rx_fifo != RT_NULL); rt_ringbuffer_putchar(&(rx_fifo->rb), UART_GET_RDR(&uart->handle, stm32_uart_get_mask(uart->handle.Init.WordLength, uart->handle.Init.Parity))); rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND); } /* If the Transmit data register is empty an...
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) { /** 参数检查 */ RT_ASSERT(thread != RT_NULL); RT_ASSERT(stack_start !
tid = rt_thread_create("main", main_thread_entry, RT_NULL, RT_MAIN_THREAD_STACK_SIZE, RT_THREAD_PRIORITY_MAX /3,20); RT_ASSERT(tid != RT_NULL); #else rt_err_tresult; tid = &main_thread; result = rt_thread_init(tid,"main", main_thread_entry, RT_NULL, main_stack,sizeof(ma...
RT_ASSERT(buffer != RT_NULL); RT_ASSERT(size != 0); /* initialize delta tick */ tick_delta = 0; /* get current thread */ thread = rt_thread_self();//获得当前线程 RT_OBJECT_HOOK_CALL(rt_object_trytake_hook, (&(mq->parent.parent))); ...
RT_ASSERT(rx_fifo != RT_NULL); /* disable interrupt */ level = rt_hw_interrupt_disable(); len = _serial_fifo_calc_data_len(rx_fifo); if ((len == 0) && // non-blocking io mode (serial->parent.open_flag & RT_DEVICE_OFLAG_NONBLOCKING) == RT_DEVICE_OFLAG_NONBLOCKING) { ...
thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter, (void *)((char *)thread->stack_addr + thread->stack_size - 4), (void *)rt_thread_exit); RT_ASSERT(priority < RT_THREAD_PRIORITY_MAX); thread->init_priority = priority; ...
LWIP_ASSERT("Should not happen!n",0); } } } 3.2 数据发送 当协议栈需要发送数据时,调用netif的linkoutput接口,在linkoutput中,将数据封装成消息发送给etx线程,最终通过eth_device的eth_tx接口将数据发送出去。 static void eth_tx_thread_entry(void* parameter) ...
return RT_NULL; RT_ASSERT(m != RT_NULL); RT_ASSERT(rt_object_get_type(&m->parent) == RT_Object_Class_Memory); RT_ASSERT(rt_object_is_systemobject(&m->parent)); if (size != RT_ALIGN(size, RT_ALIGN_SIZE)) { RT_DEBUG_LOG(RT_DEBUG_MEM, ("malloc size %d, but align to %...
RT_ASSERT((rt_uint8_t *)mem < (rt_uint8_t *)m->heap_end); /* 判断 mem 的下一块内存块是否可以合并 */ nmem = (struct rt_small_mem_item *)&m->heap_ptr[mem->next]; if (mem != nmem && !MEM_ISUSED(nmem) && (rt_uint8_t *)nmem != (rt_uint8_t *)m->heap_end...