Ignore:
Timestamp:
Apr 5, 2019, 9:26:53 PM (5 years ago)
Author:
coas-nagasima
Message:

mbed関連を更新
シリアルドライバをmbedのHALを使うよう変更
ファイルディスクリプタの処理を更新

Location:
asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/targets/TARGET_RENESAS/TARGET_RZA1XX
Files:
1 added
1 copied

Legend:

Unmodified
Added
Removed
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/targets/TARGET_RENESAS/TARGET_RZA1XX/ethernet_api.c

    r373 r374  
    2020#include "mbed_toolchain.h"
    2121#include "mbed_error.h"
    22 #include "ether_iodefine.h"
     22#include "iodefine.h"
    2323#include "ethernetext_api.h"
     24
     25#if DEVICE_ETHERNET
    2426
    2527/* Descriptor info */
     
    135137static uint32_t           phy_id            = 0;
    136138static uint32_t           start_stop        = 1;  /* 0:stop  1:start */
     139static uint32_t           tsu_ten_tmp       = 0;
     140
     141volatile struct st_ether_from_tsu_adrh0*  ETHER_FROM_TSU_ADRH0_ARRAY[ ETHER_FROM_TSU_ADRH0_ARRAY_COUNT ] =
     142    /* ->MISRA 11.3 */ /* ->SEC R2.7.1 */
     143    ETHER_FROM_TSU_ADRH0_ARRAY_ADDRESS_LIST;
     144    /* <-MISRA 11.3 */ /* <-SEC R2.7.1 */
    137145
    138146/* function */
     
    276284}
    277285
     286void ethernetext_add_multicast_group(const uint8_t *addr) {
     287    uint32_t cnt;
     288    uint32_t tmp_data_h;
     289    uint32_t tmp_data_l;
     290
     291    if (tsu_ten_tmp == 0xFFFFFFFF) {
     292        ethernetext_set_all_multicast(1);
     293    } else {
     294        tmp_data_h = ((uint32_t)addr[0] << 24) | ((uint32_t)addr[1] << 16) | ((uint32_t)addr[2] << 8) | ((uint32_t)addr[3]);
     295        tmp_data_l = ((uint32_t)addr[4] << 8) | ((uint32_t)addr[5]);
     296
     297        for (cnt = 0; cnt < 32; cnt++) {
     298            if ((tsu_ten_tmp & (0x80000000 >> cnt)) == 0) {
     299                while ((ETHERTSU_ADSBSY & 0x00000001) != 0) {
     300                    ;
     301                }
     302                ETHER_FROM_TSU_ADRH0_ARRAY[cnt]->TSU_ADRH0 = tmp_data_h;
     303                while ((ETHERTSU_ADSBSY & 0x00000001) != 0) {
     304                    ;
     305                }
     306                ETHER_FROM_TSU_ADRH0_ARRAY[cnt]->TSU_ADRL0 = tmp_data_l;
     307                if ((ETHERECMR0 & 0x00002000) != 0) {
     308                    ETHERTSU_TEN |= (0x80000000 >> cnt);
     309                }
     310                tsu_ten_tmp  |= (0x80000000 >> cnt);
     311                break;
     312            }
     313        }
     314    }
     315}
     316
     317void ethernetext_remove_multicast_group(const uint8_t *addr) {
     318    uint32_t cnt;
     319    uint32_t tmp_data_h;
     320    uint32_t tmp_data_l;
     321
     322    tmp_data_h = ((uint32_t)addr[0] << 24) | ((uint32_t)addr[1] << 16) | ((uint32_t)addr[2] << 8) | ((uint32_t)addr[3]);
     323    tmp_data_l = ((uint32_t)addr[4] << 8) | ((uint32_t)addr[5]);
     324
     325    for (cnt = 0; cnt< 32; cnt++) {
     326        if ((ETHER_FROM_TSU_ADRH0_ARRAY[cnt]->TSU_ADRH0  == tmp_data_h) &&
     327            (ETHER_FROM_TSU_ADRH0_ARRAY[cnt]->TSU_ADRL0  == tmp_data_l)) {
     328            while ((ETHERTSU_ADSBSY & 0x00000001) != 0) {
     329                ;
     330            }
     331            ETHER_FROM_TSU_ADRH0_ARRAY[cnt]->TSU_ADRH0 = 0;
     332            while ((ETHERTSU_ADSBSY & 0x00000001) != 0) {
     333                ;
     334            }
     335            ETHER_FROM_TSU_ADRH0_ARRAY[cnt]->TSU_ADRL0 = 0;
     336
     337            ETHERTSU_TEN &= ~(0x80000000 >> cnt);
     338            tsu_ten_tmp  &= ~(0x80000000 >> cnt);
     339            break;
     340        }
     341    }
     342}
     343
     344void ethernetext_set_all_multicast(int all) {
     345    if (all != 0) {
     346        ETHERECMR0 &= ~(0x00002000);
     347        ETHERTSU_TEN = 0x00000000;
     348    } else {
     349        ETHERECMR0 |= 0x00002000;
     350        ETHERTSU_TEN = tsu_ten_tmp;
     351    }
     352}
     353
     354
    278355int ethernet_init() {
    279356    ethernet_cfg_t ethcfg;
     
    575652        ETHERECMR0 &= ~0x00000002;      /* Set to half-duplex mode */
    576653    }
     654    ETHERECMR0     |=  0x00002000;      /* MCT = 1 */
    577655
    578656    /* Interrupt-related */
     
    584662        /*InterruptHandlerRegister(ETHERI_IRQn, INT_Ether);  /* Ethernet interrupt handler registration */
    585663        GIC_SetPriority(ETHERI_IRQn, Interrupt_priority);  /* Ethernet interrupt priority */
     664        GIC_SetConfiguration(ETHERI_IRQn, 1);
    586665        GIC_EnableIRQ(ETHERI_IRQn);                        /* Enables the E-DMAC interrupt */
    587666    }
     
    713792    }
    714793}
     794#endif /* DEVICE_ETHERNET */
Note: See TracChangeset for help on using the changeset viewer.