/*TASK*----------------------------------------------------- * * Task Name : hello_task * Comments : * This task prints " Hello World " * *END*-----------------------------------------------------*/ static void hello_task ( uint_32 initial_data ) { printf("\n\nUSER PRIVILEGE MODE TEST\n"); str[0] = 0; _task_create(0, USR_TASK_DEF, (uint_32)&g_udef); printf("global user default access task: %s\n", str); str[0] = 0; _task_create(0, USR_TASK_RW, (uint_32)&g_urw); printf("global user rw task: %s\n", str); str[0] = 0; _task_create(0, USR_TASK_RO, (uint_32)&g_uro); printf("global user read only task: %s\n", str); str[0] = 0; _task_create(0, USR_TASK_NO_R, (uint_32)&g_uno); printf("global user no access - read task: %s\n", str); str[0] = 0; _task_create(0, USR_TASK_NO_W, (uint_32)&g_uno); printf("global user no access - write task: %s\n", str); printf("\n\nEND\n"); _task_block(); }
void main_task ( uint_32 initial_data ) { MUTEX_ATTR_STRUCT mutexattr; char* string1 = "Hello from Print task 1\n"; char* string2 = "Print task 2 is alive\n"; /* Initialize mutex attributes */ if (_mutatr_init(&mutexattr) != MQX_OK) { printf("Initialize mutex attributes failed.\n"); _task_block(); } /* Initialize the mutex */ if (_mutex_init(&print_mutex, &mutexattr) != MQX_OK) { printf("Initialize print mutex failed.\n"); _task_block(); } /* Create the print tasks */ _task_create(0, PRINT_TASK, (uint_32)string1); _task_create(0, PRINT_TASK, (uint_32)string2); _task_block(); }
void init_task(uint_32 initial_data) { _task_id task_id; printf("\n Initialize IO \n"); InitializeIO(); task_id = _task_create(0, LED1_TASK, 0); if (task_id == MQX_NULL_TASK_ID) { printf("\n Could not create LED1_TASK\n"); } else { printf("\n LED1_TASK created \n"); } task_id = _task_create(0, LED2_TASK, 0); if (task_id == MQX_NULL_TASK_ID) { printf("\n Could not create LED2_TASK\n"); } else { printf("\n LED2_TASK created \n"); } task_id = _task_create(0, LED3_TASK, 0); if (task_id == MQX_NULL_TASK_ID) { printf("\n Could not create LED3_TASK\n"); } else { printf("\n LED3_TASK created \n"); } task_id = _task_create(0, LED4_TASK, 0); if (task_id == MQX_NULL_TASK_ID) { printf("\n Could not create LED4_TASK\n"); } else { printf("\n LED4_TASK created \n"); } task_id = task_create(0,RTC_TASK,0); if (task_id == MQX_NULL_TASK_ID) { printf("\n Could not create RTC_TASK\n"); } else { printf("\n RTC_TASK created \n"); } }
/*FUNCTION*---------------------------------------------------------------- * * Function Name : main (Main_Task if using MQX) * Returned Value : none * Comments : * Execution starts here * *END*--------------------------------------------------------------------*/ void Main_Task ( uint32_t param ) { /* Body */ USB_STATUS status = USB_OK; /* _usb_otg_init needs to be done with interrupts disabled */ _int_disable(); _int_install_unexpected_isr(); _usb_host_driver_install(USBCFG_DEFAULT_HOST_CONTROLLER); /* ** It means that we are going to act like host, so we initialize the ** host stack. This call will allow USB system to allocate memory for ** data structures, it uses later (e.g pipes etc.). */ status = _usb_host_init ( USBCFG_DEFAULT_HOST_CONTROLLER, /* Use value in header file */ &host_handle); /* Returned pointer */ if (status != USB_OK) { printf("\nUSB Host Initialization failed. STATUS: %x", status); fflush(stdout); } /* ** Since we are going to act as the host driver, register the driver ** information for wanted class/subclass/protocols */ status = _usb_host_driver_info_register ( host_handle, DriverInfoTable ); if (status != USB_OK) { printf("\nDriver Registration failed. STATUS: %x", status); fflush(stdout); } _int_enable(); printf("\n MQX USB Audio Speaker Host Demo\n"); fflush(stdout); /* Creat lwevents*/ if (MQX_OK !=_lwevent_create(&USB_Keyboard_Event, LWEVENT_AUTO_CLEAR)){ printf("\n_lwevent_create USB_Keyboard_Event failed.\n"); } if (MQX_OK !=_lwevent_create(&USB_Audio_FU_Request, LWEVENT_AUTO_CLEAR)){ printf("\n_lwevent_create USB_Audio_FU_Request failed.\n"); } if (MQX_OK !=_lwevent_create(&SD_Card_Event, LWEVENT_AUTO_CLEAR)){ printf("\n_lwevent_create SD_Card_Event failed.\n"); } _task_create(0, AUDIO_TASK, (uint32_t) host_handle); _task_create(0, HID_KEYB_TASK, (uint32_t) host_handle); _task_create(0, SDCARD_TASK, (uint32_t) host_handle); _task_create(0, SHELL_TASK, (uint32_t) host_handle); /* The main task has done its job, so exit */ } /* Endbody */
void Main_Task ( uint_32 param ) { /* Body */ USB_STATUS status = USB_OK; /* _usb_otg_init needs to be done with interrupts disabled */ _int_disable(); _int_install_unexpected_isr(); if (MQX_OK != _usb_host_driver_install(USBCFG_DEFAULT_HOST_CONTROLLER)) { printf("\n Driver installation failed"); _task_block(); } /* ** It means that we are going to act like host, so we initialize the ** host stack. This call will allow USB system to allocate memory for ** data structures, it uses later (e.g pipes etc.). */ status = _usb_host_init (USBCFG_DEFAULT_HOST_CONTROLLER, &host_handle); if (status != USB_OK) { printf("\nUSB Host Initialization failed. STATUS: %x", status); fflush(stdout); } /* ** since we are going to act as the host driver, register the driver ** information for wanted class/subclass/protocols */ status = _usb_host_driver_info_register ( host_handle, DriverInfoTable ); if (status != USB_OK) { printf("\nDriver Registration failed. STATUS: %x", status); fflush(stdout); } _int_enable(); printf("\nMQX USB HID Keyboard + Mouse Demo"); fflush(stdout); _task_create(0, MOUSE_TASK, (uint_32) host_handle); _task_create(0, KEYBOARD_TASK, (uint_32) host_handle); /* The main task has done its job, so exit */ } /* Endbody */
void Main_Task(uint_32 initial_data) { HTTPD_STRUCT * server; int_32 error; SEC_Initialize(); _task_create(0, IO_TASK, 0); // start io task SEC_InitializeNetworking(5, 6, 4, DEMOCFG_ENABLE_DHCP); /* Set up Trival File System to server webpages */ if ((error = _io_tfs_install("tfs:", tfs_data))) { printf("\nTFS install returned: %08x\n", error); } server = httpd_server_init((HTTPD_ROOT_DIR_STRUCT*)root_dir, "\\mqx.html"); HTTPD_SET_PARAM_CGI_TBL(server, (HTTPD_CGI_LINK_STRUCT*)cgi_lnk_tbl); #if HTTPDCFG_POLL_MODE while (1) { /* Poll Webserver */ httpd_server_poll(server, -1); } #else httpd_server_run(server); _task_block(); #endif }
void Sender ( uint_32 parameter ) { _mqx_uint msg[MSG_SIZE]; _task_id created_task; created_task = _task_create(0, RESPONDER, 0); if (created_task == MQX_NULL_TASK_ID) { /* task creation failed */ } /* * Service the message queue - Sender_Queue */ _lwmsgq_receive((pointer)sender_queue, msg, LWMSGQ_RECEIVE_BLOCK_ON_EMPTY, 0, 0); _lwmsgq_send((pointer)responder_queue, msg, LWMSGQ_SEND_BLOCK_ON_FULL); /* ** LOOP - */ while ( TRUE ) { /* * Service the message queue - Sender_Queue */ _lwmsgq_receive((pointer)sender_queue, msg, LWMSGQ_RECEIVE_BLOCK_ON_EMPTY, 0, 0); _time_delay_ticks(3); _lwmsgq_send((pointer)responder_queue, msg, LWMSGQ_SEND_BLOCK_ON_FULL); putchar('.'); } /* endwhile */ } /*end of task*/
static void privilege_task(uint_32 initial_data) { _mqx_uint msg[MSG_SIZE]; _lwmem_pool_id mem_pool_id; LWMEM_POOL_STRUCT mem_pool; pointer mem_pool_start; LWMEM_POOL_STRUCT_PTR usr_pool_ptr; pointer usr_pool_start; /* memory pool: Read-Only for User tasks */ mem_pool_start = _mem_alloc(1024); mem_pool_id = _lwmem_create_pool(&mem_pool, mem_pool_start, 1024); _mem_set_pool_access(mem_pool_id, POOL_USER_RO_ACCESS); /* message queue to communicate between this task and User tasks */ que = (uint_32*)_mem_alloc_from(mem_pool_id, sizeof(LWMSGQ_STRUCT) + NUM_MESSAGES * MSG_SIZE * sizeof(_mqx_uint)); _usr_lwmsgq_init((pointer)que, NUM_MESSAGES, MSG_SIZE); /* memory pool: Read-Write for user tasks */ usr_pool_ptr = _usr_mem_alloc(sizeof(LWMEM_POOL_STRUCT)); usr_pool_start = _mem_alloc(1024); usr_pool_id = _lwmem_create_pool(usr_pool_ptr, usr_pool_start, 1024); _mem_set_pool_access(usr_pool_id, POOL_USER_RW_ACCESS); /* create the user "main" task, whcih then creates the others */ _task_create(0, USR_MAIN_TASK, USR_TASK_CNT); /* receive messages from user tasks and print */ while (1) { _lwmsgq_receive((pointer)que, msg, LWMSGQ_RECEIVE_BLOCK_ON_EMPTY, 0, 0); printf(" %c \n", msg[0]); } }
void server_task ( uint_32 param ) { SERVER_MESSAGE_PTR msg_ptr; _mqx_uint i; _queue_id server_qid; boolean result; _task_id task_id; /* open a message queue */ server_qid = _msgq_open(SERVER_QUEUE, 0); if (server_qid == 0) { printf("\nCould not open the server message queue\n"); _mqx_exit(0); } /* create a message pool */ message_pool = _msgpool_create(sizeof(SERVER_MESSAGE), NUM_CLIENTS, 0, 0); if (message_pool == MSGPOOL_NULL_POOL_ID) { printf("\nCount not create a message pool\n"); _mqx_exit(0); } /* create the client tasks */ for (i = 0; i < NUM_CLIENTS; i++) { task_id = _task_create(0, CLIENT_TASK, (uint_32)i); if (task_id == 0) { printf("\nCould not create a client task\n"); _mqx_exit(0); } } while (TRUE) { msg_ptr = _msgq_receive(server_qid, 0); if (msg_ptr == NULL) { printf("\nCould not receive a message\n"); _mqx_exit(0); } printf(" %c \n", msg_ptr->DATA[0]); /* return the message */ msg_ptr->HEADER.TARGET_QID = msg_ptr->HEADER.SOURCE_QID; msg_ptr->HEADER.SOURCE_QID = server_qid; result = _msgq_send(msg_ptr); if (result != TRUE) { printf("\nCould not send a message\n"); _mqx_exit(0); } } }
void world_task ( uint_32 initial_data ) { _task_id hello_task_id; hello_task_id = _task_create(0, HELLO_TASK, 0); if (hello_task_id == MQX_NULL_TASK_ID) { printf ("\n Could not create hello_task\n"); } else { printf(" World \n"); } /* Start CR 1764 */ /* ** This example uses polled serial I/O by default. Should it be modified ** to use interrupt driven serial drivers, you will need to uncomment the ** following delay code to insure serial communication completes before ** _mqx_exit() disables all interrupts. */ // _time_delay(200); /* End CR 1764 */ _mqx_exit(0); }
/* ** =================================================================== ** Method : Init (component OS_Task) ** ** Description : ** The method creates and starts task defined by OS_Task ** component. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ osa_status_t TX_Init(void) { _task_id task_id = _task_create(0, TX_TASK, (uint32_t)(NULL)); if (task_id == MQX_NULL_TASK_ID) { return kStatus_OSA_Error; } return kStatus_OSA_Success; }
/* ** =================================================================== ** Method : Init (component OS_Task) ** ** Description : ** The method creates and starts task defined by OS_Task ** component. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ osa_status_t statusUpdate_Init(void) { _task_id task_id = _task_create(0, STATUSUPDATE_TASK, (uint32_t)(NULL)); if (task_id == MQX_NULL_TASK_ID) { return kStatus_OSA_Error; } return kStatus_OSA_Success; }
/* ** =================================================================== ** Method : Init (component OS_Task) ** ** Description : ** The method creates and starts task defined by OS_Task ** component. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ osa_status_t dd_monitor_Init(void) { _task_id task_id = _task_create(0, DD_MONITOR_TASK, (uint32_t)(NULL)); if (task_id == MQX_NULL_TASK_ID) { return kStatus_OSA_Error; } return kStatus_OSA_Success; }
void main_task ( uint32_t initial_data ) { _task_id task_id; _mqx_uint i; fifo.READ_INDEX = 0; fifo.WRITE_INDEX = 0; /* Create the semaphores */ if (_sem_create_component(3,1,6) != MQX_OK) { printf("\nCreate semaphore component failed"); _task_block(); } if (_sem_create("sem.write", ARRAY_SIZE, 0) != MQX_OK) { printf("\nCreating write semaphore failed"); _task_block(); } if (_sem_create("sem.read", 0, 0) != MQX_OK) { printf("\nCreating read semaphore failed"); _task_block(); } if (_sem_create("sem.index", 1, 0) != MQX_OK) { printf("\nCreating index semaphore failed"); _task_block(); } /* Create the tasks */ for (i = 0; i < NUM_WRITERS; i++) { task_id = _task_create(0, WRITE_TASK, (uint32_t)i); printf("\nwrite_task created, id 0x%lx", task_id); } task_id = _task_create(0,READ_TASK, 0); printf("\nread_task created, id 0x%lX", task_id); _task_block(); }
void main_task ( uint_32 initial_data ) { _task_id test_task; _lwsem_create(&shutdown_sem, 0); test_task = _task_create(0, TEST_TASK,0); _lwsem_wait(&shutdown_sem); _task_destroy(test_task); printf("\nWatchdog expired"); _task_block(); }
void read_task ( uint32_t initial_data ) { _task_id task_id; _mqx_uint result; _mqx_uint i; /* Create the lightweight semaphores */ result = _lwsem_create(&fifo.READ_SEM, 0); if (result != MQX_OK) { printf("\nCreating read_sem failed: 0x%X", result); _task_block(); } result = _lwsem_create(&fifo.WRITE_SEM, 1); if (result != MQX_OK) { printf("\nCreating write_sem failed: 0x%X", result); _task_block(); } /* Create the write tasks */ for (i = 0; i < NUM_WRITERS; i++) { task_id = _task_create(0, WRITE_TASK, (uint32_t)('A' + i)); printf("\nwrite_task created, id 0x%lX", task_id); } while(TRUE) { result = _lwsem_wait(&fifo.READ_SEM); if (result != MQX_OK) { printf("\n_lwsem_wait failed: 0x%X", result); _task_block(); } putchar('\n'); putchar(fifo.DATA); _lwsem_post(&fifo.WRITE_SEM); } }
void service_task ( uint32_t initial_data ) { void *event_ptr; _task_id second_task_id; /* Set up an event group */ if (_event_create("event.global") != MQX_OK) { printf("\nMake event failed"); _task_block(); } if (_event_open("event.global", &event_ptr) != MQX_OK) { printf("\nOpen event failed"); _task_block(); } /* Create the ISR task */ second_task_id = _task_create(0, ISR_TASK, 0); if (second_task_id == MQX_NULL_TASK_ID) { printf("Could not create simulated_ISR_task \n"); _task_block(); } while (TRUE) { if (_event_wait_all_ticks(event_ptr, 0x01, 0) != MQX_OK) { printf("\nEvent Wait failed"); _task_block(); } if (_event_clear(event_ptr,0x01) != MQX_OK) { printf("\nEvent Clear failed"); _task_block(); } printf(" Tick \n"); } }
kii_task_code_t task_create_cb (const char* name, KII_TASK_ENTRY entry, void* param, unsigned char* stk_start, unsigned int stk_size, unsigned int priority) { int ret = 0; _data_t* data = NULL; uint_32 task = KII_TASK1; data = (_data_t*)malloc(sizeof(_data_t)); data->name = name; data->entry = entry; data->param = param; if (use_task1 == 1) { task = KII_TASK2; } else { use_task1 = 1; } _task_create(0, task,(uint_32) data); if(ret == 0) { return KII_TASKC_OK; } else { return KII_TASKC_FAIL; } }
void watering_system_pump_water(uint32_t pumping_time){ if (_task_get_id_from_name("watering_pump_task") == MQX_NULL_TASK_ID) _task_create(0, WATERING_PUMP, pumping_time); }
/*TASK*----------------------------------------------------------------- * * Function Name : main_task * Returned Value : void * Comments : * *END------------------------------------------------------------------*/ void main_task(uint_32 temp) { int_32 error; HTTPD_STRUCT *server[BSP_ENET_DEVICE_COUNT]; extern const HTTPD_CGI_LINK_STRUCT cgi_lnk_tbl[]; extern const TFS_DIR_ENTRY tfs_data[]; HTTPD_PARAMS_STRUCT *params[BSP_ENET_DEVICE_COUNT]; _enet_address address[BSP_ENET_DEVICE_COUNT]; uint_32 phy_addr[BSP_ENET_DEVICE_COUNT]; uint_32 ip_addr[BSP_ENET_DEVICE_COUNT]; uint_32 i = 0; char* indexes[BSP_ENET_DEVICE_COUNT]; uint_8 n_devices = BSP_ENET_DEVICE_COUNT; #if DEMOCFG_USE_WIFI ENET_ESSID ssid; uint_32 mode;// = DEMOCFG_NW_MODE; uint_32 sectype;// = DEMOCFG_SECURITY; ENET_MEDIACTL_PARAM param; #endif #if RTCSCFG_ENABLE_IP6 IPCFG6_GET_ADDR_DATA data[RTCSCFG_IP6_IF_ADDRESSES_MAX]; char prn_addr6[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"]; uint_32 n = 0; uint_32 j = 0; #endif _int_install_unexpected_isr(); /*---------------- Initialize devices and variables ----------------------*/ _RTCSPCB_init = 4; _RTCSPCB_grow = 2; _RTCSPCB_max = 8; _RTCSTASK_stacksize = 4500; /*--------------------------- Init end -----------------------------------*/ PORT_PCR_REG(PORTC_BASE_PTR, 3) = PORT_PCR_MUX(5); // SIM_SOPT2 |= 3<<5; // 1k LPO error = RTCS_create(); if (error != RTCS_OK) { printf("RTCS failed to initialize, error = 0x%X\n", error); _task_block(); } _IP_forward = TRUE; for (i = 0; (i < n_devices) && (n_devices != 0); i++) { IPCFG_IP_ADDRESS_DATA ip_data; phy_addr[i] = i; ip_addr[i] = IPADDR(A,B,C+i,D); ENET_get_mac_address (phy_addr[i], ip_addr[i], address[i]); /* Init ENET device */ error = ipcfg_init_device (phy_addr[i], address[i]); if (error != RTCS_OK) { printf("IPCFG: Device n.%d init failed. Error = 0x%X\n", i, error); _task_set_error(MQX_OK); n_devices--; i--; continue; } #if RTCSCFG_ENABLE_IP4 ip_data.ip = ip_addr[i]; ip_data.mask = ENET_IPMASK; ip_data.gateway = 0; /* Bind IPv4 address */ //error = ipcfg_bind_staticip (phy_addr[i], &ip_data); error = ipcfg_bind_autoip (phy_addr[i], &ip_data); if (error != RTCS_OK) { printf("\nIPCFG: Failed to bind IP address. Error = 0x%X", error); _task_block(); } #endif /* RTCSCFG_ENABLE_IP4 */ indexes[i] = (char*) _mem_alloc(sizeof("\\index_x.html")); } error = _io_tfs_install("tfs:", tfs_data); #if DEBUG__MESSAGES printf("Preparing http servers...\n"); #endif for (i = 0; i < n_devices; i++) { params[i] = httpd_default_params(NULL); params[i]->af = HTTP_INET_AF; //IPv4+IPv6, set connection family from config.h #if RTCSCFG_ENABLE_IP6 params[i]->if_scope_id = HTTP_SCOPE_ID; // set interface number here. 0 is any . #endif if (params[i]) { sprintf(indexes[i], "\\index.html", i); params[i]->root_dir = (HTTPD_ROOT_DIR_STRUCT*)root_dir; params[i]->index_page = indexes[i]; printf("Starting http server No.%d on IP", i); /* ** If there is only one interface listen on any IP address ** so address can change in runtime (DHCP etc.) */ #if RTCSCFG_ENABLE_IP4 if ((i == 0) && (n_devices == 1)) { params[i]->address = INADDR_ANY; } else { params[i]->address = ip_addr[i]; } /* Print active ip addresses */ printf(" %d.%d.%d.%d", IPBYTES(ip_addr[i])); #endif #if RTCSCFG_ENABLE_IP6 while(!ipcfg6_get_addr_info_n(i, n, &data[n])) { n++; } while(j < n) { if(inet_ntop(AF_INET6, &data[j++].ip_addr, prn_addr6, sizeof(prn_addr6))) { /* Print active ip addresses */ #if RTCSCFG_ENABLE_IP4 printf("%s %s", (HTTP_INET_AF & AF_INET) ? " and" : "", prn_addr6); #else printf(" %s", prn_addr6); #endif } } #endif #if PSP_MQX_CPU_IS_MCF5223X params[i]->max_ses = 1; #else params[i]->max_ses = _RTCS_socket_part_max - 1; #endif server[i] = httpd_init(params[i]); } HTTPD_SET_PARAM_CGI_TBL(server[i], (HTTPD_CGI_LINK_STRUCT*)cgi_lnk_tbl); #if HTTPD_SEPARATE_TASK || !HTTPDCFG_POLL_MODE printf("..."); error = httpd_server_run(server[i]); if (error) { printf("[FAIL]\n"); } else { printf("[OK]\n"); } #endif } /* user stuff come here */ #if HTTPD_SEPARATE_TASK || !HTTPDCFG_POLL_MODE _task_create(0, SHELL_TASK, 0); _task_block(); #else printf("Servers polling started.\n") while (1) { for (i = 0; i < n_devices; i++) { httpd_server_poll(server[i], 1); } /* user stuff come here - only non blocking calls */ } #endif }
_mqx_int _io_pcb_mqxa_ioctl ( /* [IN] the file handle for the device */ FILE_DEVICE_STRUCT_PTR fd_ptr, /* [IN] the ioctl command */ _mqx_uint cmd, /* [IN] the ioctl parameters */ pointer param_ptr ) { /* Body */ TASK_TEMPLATE_STRUCT input_tt = { 0, _io_pcb_mqxa_read_task, IO_PCB_MQXA_STACK_SIZE, 0, "io_pcb_mqxa_read_task", 0, 0, 0}; TASK_TEMPLATE_STRUCT output_tt = { 0, _io_pcb_mqxa_write_task, IO_PCB_MQXA_STACK_SIZE, 0, "io_pcb_mqxa_write_task", 0, 0, 0}; IO_PCB_MQXA_INFO_STRUCT_PTR info_ptr; IO_PCB_STRUCT_PTR pcb_ptr; _mqx_uint result = MQX_OK; _psp_code_addr old_value; _psp_code_addr_ptr pc_ptr = (_psp_code_addr_ptr)param_ptr; _psp_data_addr_ptr pd_ptr = (_psp_data_addr_ptr)param_ptr; boolean _PTR_ bool_param_ptr; info_ptr = (IO_PCB_MQXA_INFO_STRUCT_PTR)fd_ptr->DEV_DATA_PTR; switch (cmd) { case IO_PCB_IOCTL_ENQUEUE_READQ: pcb_ptr = (IO_PCB_STRUCT_PTR)*pd_ptr; _queue_enqueue((QUEUE_STRUCT_PTR)&info_ptr->READ_QUEUE, (QUEUE_ELEMENT_STRUCT_PTR)&pcb_ptr->QUEUE); _lwsem_post(&info_ptr->READ_LWSEM); break; case IO_PCB_IOCTL_READ_CALLBACK_SET: old_value = (_psp_code_addr)info_ptr->READ_CALLBACK_FUNCTION; /* Start CR 398 */ info_ptr->CALLBACK_FD = fd_ptr; /* End CR */ info_ptr->READ_CALLBACK_FUNCTION = (void (_CODE_PTR_)( FILE_DEVICE_STRUCT_PTR, IO_PCB_STRUCT_PTR))*pc_ptr; *pc_ptr = old_value; break; case IO_PCB_IOCTL_SET_INPUT_POOL: old_value = (_psp_code_addr)info_ptr->READ_PCB_POOL; info_ptr->READ_PCB_POOL = (_io_pcb_pool_id)*pc_ptr; *pc_ptr = old_value; break; case IO_PCB_IOCTL_START: if (info_ptr->INPUT_TASK == MQX_NULL_TASK_ID) { input_tt.TASK_PRIORITY = info_ptr->INIT.INPUT_TASK_PRIORITY; input_tt.CREATION_PARAMETER = (uint_32)info_ptr; output_tt.TASK_PRIORITY = info_ptr->INIT.OUTPUT_TASK_PRIORITY; output_tt.CREATION_PARAMETER = (uint_32)info_ptr; info_ptr->INPUT_TASK = _task_create(0, 0, (uint_32)&input_tt); if (info_ptr->INPUT_TASK == MQX_NULL_TASK_ID){ return(_task_get_error()); } /* Endif */ info_ptr->OUTPUT_TASK = _task_create(0, 0, (uint_32)&output_tt); if (info_ptr->OUTPUT_TASK == MQX_NULL_TASK_ID){ return(_task_get_error()); } /* Endif */ }/* Endif */ break; case IO_PCB_IOCTL_UNPACKED_ONLY: bool_param_ptr = (boolean _PTR_)param_ptr; *bool_param_ptr = TRUE; break; default: result = _io_ioctl(info_ptr->FD, cmd, param_ptr); break; } /* Endswitch */ return result; } /* Endbody */
void LogInit(void) { _lwsem_create(&Logging_init_sem,0); _task_create(0, LOGGING_TASK, 0); _lwsem_wait(&Logging_init_sem); }
/*TASK*----------------------------------------------------------------- * * Function Name : localPlay_init_task * Returned Value : void * Comments : * *END------------------------------------------------------------------*/ void localPlay_init_task ( uint_32 temp ) { MQX_TICK_STRUCT time; _mqx_int errcode = 0; /* Install MQX default unexpected ISR routines */ _int_install_unexpected_isr(); if(_lwevent_create(&player_event, 0)!= MQX_OK) { printf("\nMake event failed"); } /* Setup time */ printf("Setting up time......................"); time.TICKS[0] = 0L; time.TICKS[1] = 0L; time.HW_TICKS = 0; _time_set_ticks(&time); printf("[OK]\n"); /* Init GPIOs */ lwgpio_init(&btn_next, BSP_SW1, LWGPIO_DIR_INPUT, LWGPIO_VALUE_NOCHANGE); lwgpio_set_functionality(&btn_next,BSP_SW1_MUX_GPIO); lwgpio_set_attribute(&btn_next, LWGPIO_ATTR_PULL_UP, LWGPIO_AVAL_ENABLE); lwgpio_int_init(&btn_next, LWGPIO_INT_MODE_RISING); _int_install_isr(lwgpio_int_get_vector(&btn_next), int_service_routine_btn_pause, (void *) &btn_next); hmi_init(); sgtl5000_power_on(); hmi_install(1, int_service_routine_btn_prev); _bsp_int_init(lwgpio_int_get_vector(&btn_next), BTN_ISR_PRIORITY, 0, TRUE); lwgpio_init(&btn_prev, BSP_SW2, LWGPIO_DIR_INPUT, LWGPIO_VALUE_NOCHANGE); lwgpio_set_functionality(&btn_prev, BSP_SW2_MUX_GPIO); lwgpio_set_attribute(&btn_prev, LWGPIO_ATTR_PULL_UP, LWGPIO_AVAL_ENABLE); #ifdef SD_DETECT_POLLING lwgpio_int_init(&btn_prev, LWGPIO_INT_MODE_RISING); _int_install_isr(lwgpio_int_get_vector(&btn_prev), int_service_routine_btn_stop, (void *) &btn_prev); _bsp_int_init(lwgpio_int_get_vector(&btn_prev), BTN_ISR_PRIORITY, 0, TRUE); #endif hmi_install(2, int_service_routine_btn_next); hmi_install(3, int_service_routine_vol_up); hmi_install(4, int_service_routine_vol_down); #if 0 /* Initialize audio codec */ printf("Initializing audio codec............."); if (errcode != 0) { printf("[FAIL]\n"); printf(" Error 0x%X\n", errcode); } else { printf("[OK]\n"); } //#else /* Initialize audio driver and codec */ /************************************************/ if ((errcode = msi_snd_init()) != 0) { printf("Initializing audio driver and codec........[FAIL]\n"); printf(" Error 0x%X\n", errcode); return; } else { printf("Initializing audio driver and codec........[OK]\n"); } /************************************************/ #endif /* Create tasks */ errcode = _task_create(0, SDCARD_TASK, 0); printf("Creating SD card task................"); if (errcode == MQX_NULL_TASK_ID) { printf("[FAIL]\n"); printf(" Error 0x%X.\n"); } else { printf("[OK]\n"); } #ifdef SD_PLAYER_SHELL_SUPPORTED printf("Creating shell task.................."); errcode = _task_create(0, SHELL_TASK, 0); if (errcode == MQX_NULL_TASK_ID) { printf("[FAIL]\n"); printf(" Error 0x%X.\n"); } else { printf("[OK]\n"); } #endif lwgpio_int_enable(&btn_next, TRUE); #ifdef SD_DETECT_POLLING lwgpio_int_enable(&btn_prev, TRUE); #endif _task_abort(MQX_NULL_TASK_ID); }
/*TASK*----------------------------------------------------------------- * * Function Name : Sdcard_task * Returned Value : void * Comments : * *END------------------------------------------------------------------*/ void Sdcard_task ( uint_32 temp ) { boolean inserted = TRUE, last = FALSE; _mqx_int error_code; MQX_FILE_PTR com_handle; //#if defined BSP_SDCARD_GPIO_DETECT // LWGPIO_STRUCT sd_detect; //#endif #if defined BSP_SDCARD_GPIO_PROTECT LWGPIO_STRUCT sd_protect; #endif #ifdef BSP_SDCARD_GPIO_CS LWGPIO_STRUCT sd_cs; SPI_CS_CALLBACK_STRUCT callback; #endif _task_id player_task_id, sd_walker_id; _mqx_int sd_event_value; _mqx_uint wait_state; #ifdef USB_ACCESSORY_PLAY connect_msg_t msg; int delaySetp = 0; #endif if (MQX_OK !=_lwevent_create(&(sddetect_event), LWEVENT_AUTO_CLEAR)) { printf("\n_lwevent_create sddetect_event failed\n"); _task_block(); } /* Open low level communication device */ com_handle = fopen (SDCARD_COM_CHANNEL, NULL); if (NULL == com_handle) { printf("Error installing communication handle.\n"); _task_block(); } #ifdef BSP_SDCARD_GPIO_CS /* Open GPIO file for SPI CS signal emulation */ error_code = lwgpio_init(&sd_cs, BSP_SDCARD_GPIO_CS, LWGPIO_DIR_OUTPUT, LWGPIO_VALUE_NOCHANGE); if (!error_code) { printf("Initializing GPIO with associated pins failed.\n"); _task_block(); } lwgpio_set_functionality(&sd_cs,BSP_SDCARD_CS_MUX_GPIO); lwgpio_set_attribute(&sd_cs, LWGPIO_ATTR_PULL_UP, LWGPIO_AVAL_ENABLE); /* Set CS callback */ callback.MASK = BSP_SDCARD_SPI_CS; callback.CALLBACK = set_CS; callback.USERDATA = &sd_cs; if (SPI_OK != ioctl (com_handle, IO_IOCTL_SPI_SET_CS_CALLBACK, &callback)) { printf ("Setting CS callback failed.\n"); _task_block(); } #endif #if defined BSP_SDCARD_GPIO_DETECT /* Init GPIO pins for other SD card signals */ error_code = lwgpio_init(&sd_detect, BSP_SDCARD_GPIO_DETECT, LWGPIO_DIR_INPUT, LWGPIO_VALUE_NOCHANGE); if (!error_code) { printf("Initializing GPIO with sdcard detect pin failed.\n"); _task_block(); } /*Set detect and protect pins as GPIO Function */ lwgpio_set_functionality(&sd_detect,BSP_SDCARD_DETECT_MUX_GPIO); lwgpio_set_attribute(&sd_detect, LWGPIO_ATTR_PULL_UP, LWGPIO_AVAL_ENABLE); #ifndef SD_DETECT_POLLING // init sd detcet pin interrupt lwgpio_int_init(&sd_detect,LWGPIO_INT_MODE_RISING | LWGPIO_INT_MODE_FALLING /* LWGPIO_INT_MODE_HIGH*/); /* falling,raising mode = 3 */ /* install gpio interrupt service routine */ _int_install_isr(lwgpio_int_get_vector(&sd_detect), EXT_SDDETECT_ISR, (void *) &sd_detect); _bsp_int_init(lwgpio_int_get_vector(&sd_detect), 5, 0, TRUE); lwgpio_int_enable(&sd_detect, TRUE); #endif #endif #if defined BSP_SDCARD_GPIO_PROTECT /* Init GPIO pins for other SD card signals */ error_code = lwgpio_init(&sd_protect, BSP_SDCARD_GPIO_PROTECT, LWGPIO_DIR_INPUT, LWGPIO_VALUE_NOCHANGE); if (!error_code) { printf("Initializing GPIO with sdcard protect pin failed.\n"); _task_block(); } /*Set detect and protect pins as GPIO Function */ lwgpio_set_functionality(&sd_protect,BSP_SDCARD_PROTECT_MUX_GPIO); lwgpio_set_attribute(&sd_protect, LWGPIO_ATTR_PULL_UP, LWGPIO_AVAL_ENABLE); #endif /* Install SD card device */ error_code = _io_sdcard_install("sdcard:", (pointer)&_bsp_sdcard0_init, com_handle); if ( error_code != MQX_OK ) { printf("Error installing SD card device (0x%x)\n", error_code); _task_block(); } _lwevent_set(&sddetect_event,SD_ATTACHED_EVENT); // set attached event at mode manager _time_delay(1000); /* wait otg main task ready */ printf("start sd card task\n"); // use sd detect interrupt for (;;) { #ifdef SD_DETECT_POLLING wait_state = _lwevent_wait_ticks(&sddetect_event,SD_EVENT_MASK, FALSE, 4/* 0*/); #else wait_state = _lwevent_wait_ticks(&sddetect_event,SD_EVENT_MASK, FALSE, 0); #endif //if (wait_state == LWEVENT_WAIT_TIMEOUT/* MQX_OK*/) { if (wait_state != MQX_OK ) { #ifndef SD_DETECT_POLLING printf("waiting sddetect_event fail\n"); // _task_block(); // _lwevent_destroy(&sddetect_event); //-goto wait_timeout; continue; #else _lwevent_set(&sddetect_event,SD_ATTACHED_EVENT); #endif } //else sd_event_value = _lwevent_get_signalled(); if (sd_event_value == SD_ATTACHED_EVENT ) { _time_delay (200); inserted = !lwgpio_get_value(&sd_detect); if(!inserted) // mount sd fs ,must attached sd card ! continue; // printf("mount sd card...\n"); // mount_sdcard(); #ifndef USB_ACCESSORY_PLAY /* create player and sd_walker task*/ player_task_id = _task_create(0, PLAYER_TASK, 0); printf("Creating sd player task................"); if (player_task_id == MQX_NULL_TASK_ID) { printf("[FAIL]\n"); } else { printf("[OK]\n"); } sd_walker_id = _task_create(0, SD_WALKER_TASK, 0); printf("Creating sd walker task................"); if (sd_walker_id == MQX_NULL_TASK_ID) { printf("[FAIL]\n"); } else { printf("[OK]\n"); } #else msg.conct_source = mp_for_TF; msg.conct_action = mp_plugIn; /* post message, TFcard plug in*/ if (LWMSGQ_FULL == _lwmsgq_send(connect_taskq, (uint_32 *) &msg, 0)) { printf("Could not inform about TFCard device attached\n"); } //_time_delay (1); // give mode manager task some times to cancel play ,if sd task high than mode task #endif // _lwevent_set(&player_event, PLAYER_EVENT_MSK_SD_FS_MOUNTED); //auto play event last = inserted; } // SD_ATTACHED_EVENT else if (sd_event_value == SD_DETTACHED_EVENT ) { // _time_delay (100); //inserted = !lwgpio_get_value(&sd_detect); //if(inserted) // continue; #ifndef USB_ACCESSORY_PLAY _lwevent_set(&player_event, PLAYER_EVENT_MSK_SD_FS_UNMOUNTED); _lwevent_wait_ticks(&player_event, PLAYER_EVENT_MSK_PLAYER_TASK_KILLED, TRUE, 0); _lwevent_clear(&player_event, PLAYER_EVENT_MSK_PLAYER_TASK_KILLED); /* And the destroy play_task and sd_walker task */ _task_destroy(sd_walker_id); _task_destroy(player_task_id); #else /* post message, TFcard plug out*/ msg.conct_source = mp_for_TF; msg.conct_action = mp_plugOut; /* post message, TFcard plug out*/ if (LWMSGQ_FULL == _lwmsgq_send(connect_taskq, (uint_32 *) &msg, 0)) { printf("Could not inform about TFCard device de-attached\n"); } //_time_delay (1); // give mode manager task some times to cancel play ,if sd task high than mode task #endif // printf("unmount sd card...\n"); // unmount_sdcard(); // printf ("SD card uninstalled.\n"); } } }
_mqx_uint _timer_create_component ( /* [IN] the task priority of the timer task */ _mqx_uint timer_task_priority, /* [IN] the stack size for the timer task */ _mqx_uint timer_task_stack_size ) { /* Body */ KERNEL_DATA_STRUCT_PTR kernel_data; TIMER_COMPONENT_STRUCT_PTR timer_component_ptr; TASK_TEMPLATE_STRUCT timer_tt; _GET_KERNEL_DATA(kernel_data); _KLOGE2(KLOG_timer_create_component, timer_task_priority); #if MQX_CHECK_ERRORS if (kernel_data->IN_ISR) { _KLOGX2(KLOG_timer_create_component, MQX_CANNOT_CALL_FUNCTION_FROM_ISR); return(MQX_CANNOT_CALL_FUNCTION_FROM_ISR); } /* Endif */ #endif _lwsem_wait((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); if (kernel_data->KERNEL_COMPONENTS[KERNEL_TIMER] != NULL) { _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); _KLOGX2(KLOG_timer_create_component, MQX_OK); return(MQX_OK); } /* Endif */ /* Get the timer component data structure */ timer_component_ptr = _mem_alloc_system_zero( (_mem_size)sizeof(TIMER_COMPONENT_STRUCT)); #if MQX_CHECK_MEMORY_ALLOCATION_ERRORS if (timer_component_ptr == NULL) { _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); _KLOGX2(KLOG_timer_create_component, MQX_OUT_OF_MEMORY); return(MQX_OUT_OF_MEMORY); } /* Endif */ #endif _mem_set_type(timer_component_ptr, MEM_TYPE_TIMER_COMPONENT); _QUEUE_INIT(&timer_component_ptr->ELAPSED_TIMER_ENTRIES, 0); _QUEUE_INIT(&timer_component_ptr->KERNEL_TIMER_ENTRIES, 0); timer_tt.TASK_TEMPLATE_INDEX = 0; timer_tt.TASK_ADDRESS = _timer_task; if (timer_task_stack_size == 0) { timer_tt.TASK_STACKSIZE = TIMER_DEFAULT_STACK_SIZE; } else { timer_tt.TASK_STACKSIZE = timer_task_stack_size; } /* Endif */ if (timer_task_priority == 0) { timer_tt.TASK_PRIORITY = TIMER_DEFAULT_TASK_PRIORITY; } else { timer_tt.TASK_PRIORITY = timer_task_priority; } /* Endif */ timer_tt.TASK_NAME = "Timer Task"; timer_tt.TASK_ATTRIBUTES = 0; timer_tt.DEFAULT_TIME_SLICE = 0; kernel_data->KERNEL_COMPONENTS[KERNEL_TIMER] = timer_component_ptr; timer_component_ptr->TIMER_TID = _task_create(0, 0, (uint_32)&timer_tt); #if MQX_CHECK_ERRORS if (timer_component_ptr->TIMER_TID == MQX_NULL_TASK_ID) { _mqx_uint result; kernel_data->KERNEL_COMPONENTS[KERNEL_TIMER] = NULL; timer_component_ptr->VALID = 0; result = _task_get_error(); if (result == MQX_OK) { result = MQX_OUT_OF_MEMORY; } /* Endif */ _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); _mem_free(timer_component_ptr); _KLOGX2(KLOG_timer_create_component, result); return(result); }/* Endif */ #endif #if MQX_COMPONENT_DESTRUCTION kernel_data->COMPONENT_CLEANUP[KERNEL_EVENTS] = _timer_cleanup; #endif _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); _KLOGX2(KLOG_timer_create_component, MQX_OK); return(MQX_OK); } /* Endbody */
void main_task ( uint_32 parameter ) { MESSAGE_HEADER_STRUCT_PTR msg_ptr; _task_id created_task; _mqx_uint log_result; _mqx_uint event_result; _mqx_uint sem_result; _int_install_unexpected_isr(); printf("\nMQX %s\n",_mqx_version); printf("Hello from main_task().\n"); /* create the log component */ log_result = _log_create_component(); if (log_result != MQX_OK) { /* log component could not be created */ } /* endif */ /* Create the mutex component */ if (_mutex_create_component() != MQX_OK) { /* an error has been detected */ } /* create the event component */ event_result = _event_create_component(EVENT_INITIAL_NUMBER, EVENT_GROWTH, EVENT_MAXIMUM); if (event_result != MQX_OK) { /* event component could not be created */ printf("Error: Cannot create event component\n"); _task_block(); } /* endif */ /* create the semaphore component */ sem_result = _sem_create_component(SEM_INITIAL_NUMBER, SEM_GROWTH, SEM_MAXIMUM); if (sem_result != MQX_OK) { /* semaphore component could not be created */ printf("Error: Cannot create semaphore component\n"); _task_block(); } /* endif */ MsgPool_pool_id = _msgpool_create ( 8, 10, 0, 0); if (MsgPool_pool_id == MSGPOOL_NULL_POOL_ID) { /* _msgpool_create did not succeed */ printf("Error: Cannot create message pool\n"); _task_block(); } Main_Queue_qid = _msgq_open( MSGQ_FREE_QUEUE, SIZE_UNLIMITED); if (Main_Queue_qid == (_queue_id)0){ /* queue could not be opened */ printf("Error: Cannot open message pool\n"); _task_block(); } created_task = _task_create(0, SENDER, 0); if (created_task == MQX_NULL_TASK_ID) { /* task creation failed */ printf("Error: Cannot create task\n"); _task_block(); } created_task = _task_create(0, MUTEXA, 0); if (created_task == MQX_NULL_TASK_ID) { /* task creation failed */ printf("Error: Cannot create task\n"); _task_block(); } created_task = _task_create(0, MUTEXB, 0); if (created_task == MQX_NULL_TASK_ID) { /* task creation failed */ printf("Error: Cannot create task\n"); _task_block(); } created_task = _task_create(0, SEMA, 0); if (created_task == MQX_NULL_TASK_ID) { /* task creation failed */ printf("Error: Cannot create task\n"); _task_block(); } created_task = _task_create(0, SEMB, 0); if (created_task == MQX_NULL_TASK_ID) { /* task creation failed */ printf("Error: Cannot create task\n"); _task_block(); } created_task = _task_create(0, EVENTA, 0); if (created_task == MQX_NULL_TASK_ID) { /* task creation failed */ printf("Error: Cannot create task\n"); _task_block(); } created_task = _task_create(0, EVENTB, 0); if (created_task == MQX_NULL_TASK_ID) { /* task creation failed */ printf("Error: Cannot create task\n"); _task_block(); } #if MQX_KERNEL_LOGGING /* create log number 0 */ log_result = _klog_create(200, 0); if (log_result != MQX_OK) { /* log 0 could not be created */ printf("Error: Cannot create kernel log\n"); _task_block(); } /* endif */ /* define kernel logging */ _klog_control(0xFFFFFFFF, FALSE); _klog_control( KLOG_ENABLED | KLOG_FUNCTIONS_ENABLED | KLOG_INTERRUPTS_ENABLED | KLOG_SYSTEM_CLOCK_INT_ENABLED | KLOG_CONTEXT_ENABLED | KLOG_TASKING_FUNCTIONS | KLOG_ERROR_FUNCTIONS | KLOG_MESSAGE_FUNCTIONS | KLOG_INTERRUPT_FUNCTIONS | KLOG_MEMORY_FUNCTIONS | KLOG_TIME_FUNCTIONS | KLOG_EVENT_FUNCTIONS | KLOG_NAME_FUNCTIONS | KLOG_MUTEX_FUNCTIONS | KLOG_SEMAPHORE_FUNCTIONS | KLOG_WATCHDOG_FUNCTIONS, TRUE ); #endif /* ** LOOP - */ while ( TRUE ) { msg_ptr = _msg_alloc((_pool_id) MsgPool_pool_id ); if (msg_ptr == NULL) { /* No available message buffer */ } msg_ptr->SIZE = sizeof(MESSAGE_HEADER_STRUCT); msg_ptr->SOURCE_QID = msg_ptr->TARGET_QID; msg_ptr->TARGET_QID = Sender_Queue_qid; _msgq_send(msg_ptr); /* * Service the message queue - Main_Queue */ msg_ptr = _msgq_receive_ticks(Main_Queue_qid, NO_TIMEOUT); /* process message End_msg */ _msg_free(msg_ptr); } /* endwhile */ } /*end of task*/
static void Clock_server_task ( pointer unused1, pointer unused2 ) { sockaddr_in laddr, raddr={0}; uint_32 sock, listensock; uint_32 error; uint_16 rlen; /* Clock server services port 999 */ laddr.sin_family = AF_INET; laddr.sin_port = 999; laddr.sin_addr.s_addr = INADDR_ANY; /* Listen on TCP port */ listensock= socket(PF_INET, SOCK_STREAM, 0); if (listensock == RTCS_HANDLE_ERROR) { printf("\nCreate stream socket failed"); _task_block(); } error = bind(listensock, &laddr, sizeof(laddr)); if (error != RTCS_OK) { printf("\nStream bind failed - 0x%lx", error); _task_block(); } error = listen(listensock, 0); if (error != RTCS_OK) { printf("\nListen failed - 0x%lx", error); _task_block(); } printf("\nClock Server active on port 999\n"); for (;;) { /* Connection requested; accept it */ rlen = sizeof(raddr); printf("Clock server: Waiting on accept\n"); sock = accept(listensock, &raddr, &rlen); if (sock == RTCS_HANDLE_ERROR) { printf("\n\n*** Clock server: Accept failed, error 0x%lx *** \n\n\n", RTCS_geterror(listensock)); } else { printf("Clock server: Connection from %ld.%ld.%ld.%ld, port %d, socket %x\n", (raddr.sin_addr.s_addr >> 24) & 0xFF, (raddr.sin_addr.s_addr >> 16) & 0xFF, (raddr.sin_addr.s_addr >> 8) & 0xFF, raddr.sin_addr.s_addr & 0xFF, raddr.sin_port, sock); /* Create a task to look after it */ printf("Clock server: detaching socket %x\n",sock); #if USE_RTCS_ATTACH_DETACH RTCS_detachsock(sock); #endif printf("Clock server: spawning child task\n"); #if CREATE_WITH_RTCS RTCS_task_create("Clock_child", SHELL_CLOCK_CHILD_PRIO, SHELL_CLOCK_CHILD_STACK, Clock_child_task, (pointer) sock); #else { TASK_TEMPLATE_STRUCT task_template = {0}; task_template.TASK_NAME = "Clock_child"; task_template.TASK_PRIORITY = SHELL_CLOCK_CHILD_PRIO; task_template.TASK_STACKSIZE = SHELL_CLOCK_CHILD_STACK; task_template.TASK_ADDRESS = Clock_child_task; task_template.CREATION_PARAMETER = (uint_32)sock; if (_task_create(0, 0, (uint_32)&task_template) == MQX_NULL_TASK_ID) { printf("Clock server: failed to spawn child task\n"); } } #endif } } } /* Endbody */