A PicoTCP driver for the lpc1768 mbed board in polling mode, to allow usage with the legacy PicoTCP API
Dependents: ZeroMQ_PicoTCP_Publisher_demo
Fork of lpc1768-picotcp-eth by
Diff: pico_dev_mbed_emac.cpp
- Revision:
- 5:50ba2a185f35
- Parent:
- 4:296b82a1b4b2
- Child:
- 6:32c8501737cd
diff -r 296b82a1b4b2 -r 50ba2a185f35 pico_dev_mbed_emac.cpp --- a/pico_dev_mbed_emac.cpp Sat Jun 15 18:44:39 2013 +0000 +++ b/pico_dev_mbed_emac.cpp Sun Jun 16 02:32:33 2013 +0000 @@ -28,7 +28,7 @@ #include "PicoCondition.h" #include "proxy_endpoint.h" -static PicoCondition rx_condition; +//static PicoCondition rx_condition; /******************************* * Local structs and typedefs * @@ -103,6 +103,8 @@ static inline unsigned int _emac_clockselect(); static int _pico_emac_poll(struct pico_device *dev, int loop_score); +struct pico_device *interrupt_mbdev; + /***************** * CMSIS defines * *****************/ @@ -134,7 +136,8 @@ if(intStatus & INT_RX_DONE) { - rx_condition.unlock(); + picotcp_async_interrupt(interrupt_mbdev); + //rx_condition.unlock(); } @@ -143,7 +146,7 @@ } static int _emac_poll(struct pico_device_mbed_emac * mbdev); - +/* void rxThreadCore(void const *arg) { struct pico_device_mbed_emac *dev = (struct pico_device_mbed_emac *)arg; @@ -152,9 +155,10 @@ while(true) { rx_condition.lock(); _emac_poll(dev); - picotcp_async_interrupt(); + } } +*/ @@ -181,11 +185,12 @@ return NULL; } - pico_queue_protect(((struct pico_device *)mbdev)->q_in); + //pico_queue_protect(((struct pico_device *)mbdev)->q_in); // Set function pointers mbdev->dev.send = _emac_send_frame; //mbdev->dev.poll = _pico_emac_poll; /* IRQ MODE */ + mbdev->dev.dsr = _pico_emac_poll; mbdev->dev.destroy = _emac_destroy; // Init EMAC and PHY @@ -195,7 +200,7 @@ osTimerId phy_timer = osTimerCreate(osTimer(_emac_phy_status), osTimerPeriodic, (void *)mbdev); osTimerStart(phy_timer, 100); - Thread *rxThread = new Thread(rxThreadCore, (void*)mbdev); + //Thread *rxThread = new Thread(rxThreadCore, (void*)mbdev); //rxThread->set_priority(osPriorityLow); @@ -393,6 +398,8 @@ // Enable the interrupt. NVIC_EnableIRQ(ENET_IRQn); + // Associate the interrupt to this device + interrupt_mbdev = (struct pico_device *)mbdev; } @@ -569,6 +576,7 @@ return data_sent; } + /* polls for new data returns amount of bytes received -- 0 when no new data arrived */ static int _emac_poll(struct pico_device_mbed_emac * mbdev) @@ -615,8 +623,7 @@ return retval; } -/* - ** UNCOMMENT FOR POLLING ** + static int _pico_emac_poll(struct pico_device *dev, int loop_score) { struct pico_device_mbed_emac *mb = (struct pico_device_mbed_emac *) dev; @@ -631,7 +638,7 @@ } return loop_score; } -*/ + /* Read PHY status */ static uint8_t _emac_update_phy_status(uint32_t linksts)