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:
- 3:8689b9c62672
- Parent:
- 2:a8d9cf10e65a
- Child:
- 4:296b82a1b4b2
--- a/pico_dev_mbed_emac.cpp Sun Jun 09 16:27:08 2013 +0000 +++ b/pico_dev_mbed_emac.cpp Tue Jun 11 19:09:55 2013 +0000 @@ -25,6 +25,9 @@ #include "LPC17xx.h" #include <string.h> } +#include "PicoCondition.h" + +static PicoCondition rx_condition; /******************************* * Local structs and typedefs * @@ -129,12 +132,27 @@ if(intStatus & INT_RX_DONE) { + rx_condition.unlock(); } // Clears _ALL_ EMAC interrupt flags LPC_EMAC->IntClear = intStatus; } +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; + printf("rx Thread started.\n"); + + while(true) { + rx_condition.lock(); + _emac_poll(dev); + } +} + + struct pico_device *pico_emac_create(char *name) { @@ -163,7 +181,7 @@ // Set function pointers mbdev->dev.send = _emac_send_frame; - mbdev->dev.poll = _pico_emac_poll; + //mbdev->dev.poll = _pico_emac_poll; /* IRQ MODE */ mbdev->dev.destroy = _emac_destroy; // Init EMAC and PHY @@ -172,6 +190,9 @@ // Create periodic PHY status update thread osTimerId phy_timer = osTimerCreate(osTimer(_emac_phy_status), osTimerPeriodic, (void *)mbdev); osTimerStart(phy_timer, 100); + + Thread *rxThread = new Thread(rxThreadCore, (void*)mbdev); + //rxThread->set_priority(osPriorityLow); //printf("ETH> Device %s created.\r\n", mbdev->dev.name); @@ -589,7 +610,8 @@ 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; @@ -604,6 +626,7 @@ } return loop_score; } +*/ /* Read PHY status */ static uint8_t _emac_update_phy_status(uint32_t linksts)