Subversion Repositories Code-Repo

Rev

Rev 255 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 255 Rev 261
Line 177... Line 177...
177
 
177
 
178
    ETHCON2bits.RXBUF_SZ = 0x7F;    // Set RX data buffer size to 2032 bytes
178
    ETHCON2bits.RXBUF_SZ = 0x7F;    // Set RX data buffer size to 2032 bytes
179
 
179
 
180
    ETHIENbits.TXBUSEIE = 1;    // Enable interrupt on transmit BVCI bus error
180
    ETHIENbits.TXBUSEIE = 1;    // Enable interrupt on transmit BVCI bus error
181
    ETHIENbits.RXBUSEIE = 1;    // Enable interrupt on receive BVCI bus error
181
    ETHIENbits.RXBUSEIE = 1;    // Enable interrupt on receive BVCI bus error
182
//    ETHIENbits.RXDONEIE = 1;    // Enable interrupt on packet received
182
    ETHIENbits.RXDONEIE = 1;    // Enable interrupt on packet received
183
    ETHIENbits.PKTPENDIE = 1;   // Enable interrupt on packet pending
183
//    ETHIENbits.PKTPENDIE = 1;   // Enable interrupt on packet pending
184
//    ETHIENbits.RXACTIE = 1;
184
//    ETHIENbits.RXACTIE = 1;
185
    ETHIENbits.TXDONEIE = 1;    // Enable interrupt on packet sent
185
    ETHIENbits.TXDONEIE = 1;    // Enable interrupt on packet sent
186
    ETHIENbits.TXABORTIE = 1;   // Enable interrupt on packet send aborted
186
    ETHIENbits.TXABORTIE = 1;   // Enable interrupt on packet send aborted
187
 
187
 
188
    IPC12bits.ETHIP = 2;        // Set interrupt priority to 2
188
    IPC12bits.ETHIP = 1;        // Set interrupt priority to 2
189
    IPC12bits.ETHIS = 2;        // Set intererupt sub-priority to 2
189
    IPC12bits.ETHIS = 1;        // Set intererupt sub-priority to 2
190
    IEC1bits.ETHIE = 1;         // Enable ethernet interrupts
190
    IEC1bits.ETHIE = 1;         // Enable ethernet interrupts
191
 
191
 
192
    EMAC1SUPPbits.RESETRMII = 0;    // Bring the RMII module out of reset
192
    EMAC1SUPPbits.RESETRMII = 0;    // Bring the RMII module out of reset
193
    ETHCON1bits.RXEN = 1;       // Start receive logic
193
    ETHCON1bits.RXEN = 1;       // Start receive logic
194
    ETHCON1bits.ON = 1;             // Enable the ethernet module
194
    ETHCON1bits.ON = 1;             // Enable the ethernet module
Line 231... Line 231...
231
                (eth_data->RX_ED_table.descriptor[descriptor_index].SOP == 1) &&
231
                (eth_data->RX_ED_table.descriptor[descriptor_index].SOP == 1) &&
232
                (eth_data->RX_ED_table.descriptor[descriptor_index].EOP == 1)) {
232
                (eth_data->RX_ED_table.descriptor[descriptor_index].EOP == 1)) {
233
 
233
 
234
            // Read the packet data values into the buffer
234
            // Read the packet data values into the buffer
235
            size = eth_data->RX_ED_table.descriptor[descriptor_index].BYTE_COUNT - 18;
235
            size = eth_data->RX_ED_table.descriptor[descriptor_index].BYTE_COUNT - 18;
236
            *length = size;
-
 
237
            for (j = 0; j < size - 18; j++) {
236
            for (j = 0; j < size; j++) {
238
                buffer[j] = eth_data->RX_ED_buffer[descriptor_index][j+14];
237
                buffer[j] = eth_data->RX_ED_buffer[descriptor_index][j+14];
239
            }
238
            }
-
 
239
            *length = size;
240
 
240
 
241
            // Reset the descriptors
241
            // Reset the descriptors
242
            eth_data->RX_ED_table.descriptor[descriptor_index].SOP = 0;
242
            eth_data->RX_ED_table.descriptor[descriptor_index].SOP = 0;
243
            eth_data->RX_ED_table.descriptor[descriptor_index].EOP = 0;
243
            eth_data->RX_ED_table.descriptor[descriptor_index].EOP = 0;
244
            eth_data->RX_ED_table.descriptor[descriptor_index].EOWN = 1;
244
            eth_data->RX_ED_table.descriptor[descriptor_index].EOWN = 1;
Line 305... Line 305...
305
    
305
    
306
    return 0;
306
    return 0;
307
}
307
}
308
 
308
 
309
void __ISR(_ETH_VECTOR, ipl1) __ETH_Interrupt_Handler(void) {
309
void __ISR(_ETH_VECTOR, ipl1) __ETH_Interrupt_Handler(void) {
310
    uint32_t value = ETHIRQ;
310
//    uint32_t value = ETHIRQ;
311
    if (ETHIRQbits.TXBUSE) {
311
    if (ETHIRQbits.TXBUSE) {
312
 
312
 
313
        ETHIRQbits.TXBUSE = 0;
313
        ETHIRQbits.TXBUSE = 0;
314
    }
314
    }
315
    if (ETHIRQbits.RXBUSE) {
315
    if (ETHIRQbits.RXBUSE) {
316
 
316
 
317
        ETHIRQbits.RXBUSE = 0;
317
        ETHIRQbits.RXBUSE = 0;
318
    }
318
    }
319
//    if (ETHIRQbits.RXDONE) {
319
    if (ETHIRQbits.RXDONE) {
320
//        ETHIRQbits.RXDONE = 0;
-
 
321
//    }
-
 
322
    if (ETHIRQbits.PKTPEND) {
-
 
323
        if (eth_data->rx_callback != NULL)
320
        if (eth_data->rx_callback != NULL)
324
            (*eth_data->rx_callback)();
321
            (*eth_data->rx_callback)();
325
        ETHIRQbits.PKTPEND = 0;
322
        ETHIRQbits.RXDONE = 0;
326
    }
323
    }
-
 
324
//    if (ETHIRQbits.PKTPEND) {
-
 
325
//
-
 
326
//        ETHIRQbits.PKTPEND = 0;
-
 
327
//    }
327
    if (ETHIRQbits.TXDONE) {
328
    if (ETHIRQbits.TXDONE) {
328
        if (eth_data->tx_callback != NULL)
329
        if (eth_data->tx_callback != NULL)
329
            (*eth_data->tx_callback)();
330
            (*eth_data->tx_callback)();
330
        ETHIRQbits.TXDONE = 0;
331
        ETHIRQbits.TXDONE = 0;
331
    }
332
    }