Пример #1
0
/*============================
 *  post a mutex to thread
 *     信号量的释放
 *===========================*/
acoral_u32 acoral_mutex_post(acoral_evt_t *evt)
{
    acoral_sr             cpu_sr;
    acoral_u8             ownerPrio;
    acoral_u8             highPrio;
    acoral_u32            index;
    acoral_thread_t      *thread;
    acoral_list_t        *head;
    acoral_thread_t      *cur;

    HAL_ENTER_CRITICAL();
    acoral_spin_lock(&evt->spin_lock);

    if ( NULL == evt )
    {
        acoral_printerr("mutex NULL\n");
        acoral_spin_unlock(&evt->spin_lock);
        HAL_EXIT_CRITICAL();
        return MUTEX_ERR_NULL;   /*error*/
    }

    highPrio  = (acoral_u8)(evt->count >> 8);
    ownerPrio = (acoral_u8)(evt->count & MUTEX_L_MASK);
    cur=acoral_cur_thread;
    if (highPrio!=0&&cur->prio != highPrio && cur->prio != ownerPrio )
    {
        acoral_printerr("mutex prio err\n");
        acoral_spin_unlock(&evt->spin_lock);
        HAL_EXIT_CRITICAL();
        return MUTEX_ERR_UNDEF;
    }
    cur->evt=NULL;
    if (cur->prio != ownerPrio)
    {
        /* 提升过优先级,进行优先级复原*/
        acoral_change_prio_self(ownerPrio);
    }

    thread =acoral_evt_high_thread(evt);
    if (thread==NULL) {
        evt->count |= MUTEX_AVAI;
        evt->data = NULL;
        acoral_spin_unlock(&evt->spin_lock);
        HAL_EXIT_CRITICAL();
        return MUTEX_SUCCED;
    }
    timeout_queue_del(thread);
    acoral_evt_queue_del(thread);
#ifdef CFG_TEST
    acoral_print("%d post %d\n",cur->prio,thread->prio);
#endif
    evt->count &= MUTEX_U_MASK;
    evt->count |= thread->prio;
    evt->data = thread;
    acoral_rdy_thread(thread);
    acoral_spin_unlock(&evt->spin_lock);
    HAL_EXIT_CRITICAL();
    acoral_sched();
    return MUTEX_SUCCED;
}
Пример #2
0
/**
 * In this function, the hardware should be initialized.
 * Called from ethernetif_init().
 *
 * @param netif the already initialized lwip network interface structure
 *        for this ethernetif
 */
static void
low_level_init(struct netif *netif)
{
	/* set MAC hardware address length */
	netif->hwaddr_len = ETHARP_HWADDR_LEN;

	/* set MAC hardware address */
	/* MAC地址 */
	netif->hwaddr[0] = 0x00;
	netif->hwaddr[1] = 0x11;
	netif->hwaddr[2] = 0x22;
	netif->hwaddr[3] = 0x33;
	netif->hwaddr[4] = 0x44;     
	netif->hwaddr[5] = 0x55;

	/* maximum transfer unit */
	/* 最大传输单元 */
	netif->mtu = 1500;
  
	/* device capabilities */
	/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
	netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
 
	/* Do whatever else is needed to initialize interface. */
	/* 初始化enc28j60 */
	
	// pegasus0809
	// hw_init(netif->hwaddr);
		
	net_dev_id = acoral_dev_open("netdev");
	if (net_dev_id == ACORAL_DEV_ERR_ID)
	{
		acoral_printerr("Not Found Net Device\n");
		return;
	}
	acoral_dev_config(net_dev_id, NET_DEV_INIT, netif->hwaddr, 0);
}