mbed library sources
Fork of mbed-src by
targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/enet/fsl_enet_hal.c@206:00f6ed987803, 2014-05-23 (annotated)
- Committer:
- mbed_official
- Date:
- Fri May 23 05:45:06 2014 +0100
- Revision:
- 206:00f6ed987803
- Parent:
- 204:92d082577917
Synchronized with git revision 62605dfaaae938eb02efb183021248270793666b
Full URL: https://github.com/mbedmicro/mbed/commit/62605dfaaae938eb02efb183021248270793666b/
Signed-off-by: Sergio Scaglia <sergio.scaglia@arm.com>
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 146:f64d43ff0c18 | 1 | /* |
mbed_official | 146:f64d43ff0c18 | 2 | * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. |
mbed_official | 146:f64d43ff0c18 | 3 | * All rights reserved. |
mbed_official | 146:f64d43ff0c18 | 4 | * |
mbed_official | 146:f64d43ff0c18 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 146:f64d43ff0c18 | 6 | * are permitted provided that the following conditions are met: |
mbed_official | 146:f64d43ff0c18 | 7 | * |
mbed_official | 146:f64d43ff0c18 | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
mbed_official | 146:f64d43ff0c18 | 9 | * of conditions and the following disclaimer. |
mbed_official | 146:f64d43ff0c18 | 10 | * |
mbed_official | 146:f64d43ff0c18 | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
mbed_official | 146:f64d43ff0c18 | 12 | * list of conditions and the following disclaimer in the documentation and/or |
mbed_official | 146:f64d43ff0c18 | 13 | * other materials provided with the distribution. |
mbed_official | 146:f64d43ff0c18 | 14 | * |
mbed_official | 146:f64d43ff0c18 | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
mbed_official | 146:f64d43ff0c18 | 16 | * contributors may be used to endorse or promote products derived from this |
mbed_official | 146:f64d43ff0c18 | 17 | * software without specific prior written permission. |
mbed_official | 146:f64d43ff0c18 | 18 | * |
mbed_official | 146:f64d43ff0c18 | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
mbed_official | 146:f64d43ff0c18 | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
mbed_official | 146:f64d43ff0c18 | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 146:f64d43ff0c18 | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
mbed_official | 146:f64d43ff0c18 | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
mbed_official | 146:f64d43ff0c18 | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
mbed_official | 146:f64d43ff0c18 | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
mbed_official | 146:f64d43ff0c18 | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
mbed_official | 146:f64d43ff0c18 | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
mbed_official | 146:f64d43ff0c18 | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 146:f64d43ff0c18 | 29 | */ |
mbed_official | 146:f64d43ff0c18 | 30 | |
mbed_official | 146:f64d43ff0c18 | 31 | #include "fsl_enet_hal.h" |
mbed_official | 146:f64d43ff0c18 | 32 | |
mbed_official | 146:f64d43ff0c18 | 33 | /******************************************************************************* |
mbed_official | 146:f64d43ff0c18 | 34 | * Code |
mbed_official | 146:f64d43ff0c18 | 35 | ******************************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 36 | |
mbed_official | 146:f64d43ff0c18 | 37 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 38 | * |
mbed_official | 146:f64d43ff0c18 | 39 | * Function Name: enet_hal_set_mac_address |
mbed_official | 146:f64d43ff0c18 | 40 | * Description: Set ENET mac physical address. |
mbed_official | 146:f64d43ff0c18 | 41 | * |
mbed_official | 146:f64d43ff0c18 | 42 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 43 | void enet_hal_set_mac_address(uint32_t instance, enetMacAddr hwAddr) |
mbed_official | 146:f64d43ff0c18 | 44 | { |
mbed_official | 146:f64d43ff0c18 | 45 | assert(instance < HW_ENET_INSTANCE_COUNT); |
mbed_official | 146:f64d43ff0c18 | 46 | |
mbed_official | 146:f64d43ff0c18 | 47 | uint32_t address, data; |
mbed_official | 146:f64d43ff0c18 | 48 | |
mbed_official | 146:f64d43ff0c18 | 49 | address = (uint32_t)(((uint32_t)hwAddr[0] << 24U)|((uint32_t)hwAddr[1] << 16U)|((uint32_t)hwAddr[2] << 8U)| (uint32_t)hwAddr[3]) ; |
mbed_official | 146:f64d43ff0c18 | 50 | HW_ENET_PALR_WR(instance,address); /* Set low physical address */ |
mbed_official | 146:f64d43ff0c18 | 51 | address = (uint32_t)(((uint32_t)hwAddr[4] << 24U)|((uint32_t)hwAddr[5] << 16U)) ; |
mbed_official | 146:f64d43ff0c18 | 52 | data = HW_ENET_PAUR_RD(instance) & BM_ENET_PAUR_TYPE; |
mbed_official | 146:f64d43ff0c18 | 53 | HW_ENET_PAUR_WR(instance, (data | address)); /* Set high physical address */ |
mbed_official | 146:f64d43ff0c18 | 54 | } |
mbed_official | 146:f64d43ff0c18 | 55 | |
mbed_official | 146:f64d43ff0c18 | 56 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 57 | * |
mbed_official | 146:f64d43ff0c18 | 58 | * Function Name: enet_hal_set_group_hashtable |
mbed_official | 146:f64d43ff0c18 | 59 | * Description: Set multicast group address hash value to the mac register |
mbed_official | 146:f64d43ff0c18 | 60 | * To join the multicast group address. |
mbed_official | 146:f64d43ff0c18 | 61 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 62 | void enet_hal_set_group_hashtable(uint32_t instance, uint32_t crcValue, enet_special_address_filter_t mode) |
mbed_official | 146:f64d43ff0c18 | 63 | { |
mbed_official | 146:f64d43ff0c18 | 64 | assert(instance < HW_ENET_INSTANCE_COUNT); |
mbed_official | 146:f64d43ff0c18 | 65 | |
mbed_official | 146:f64d43ff0c18 | 66 | switch (mode) |
mbed_official | 146:f64d43ff0c18 | 67 | { |
mbed_official | 146:f64d43ff0c18 | 68 | case kEnetSpecialAddressInit: /* Clear group address register on ENET initialize */ |
mbed_official | 146:f64d43ff0c18 | 69 | HW_ENET_GALR_WR(instance,0); |
mbed_official | 146:f64d43ff0c18 | 70 | HW_ENET_GAUR_WR(instance,0); |
mbed_official | 146:f64d43ff0c18 | 71 | break; |
mbed_official | 146:f64d43ff0c18 | 72 | case kEnetSpecialAddressEnable: /* Enable a multicast group address*/ |
mbed_official | 146:f64d43ff0c18 | 73 | if (!((crcValue >> 31) & 1U)) |
mbed_official | 146:f64d43ff0c18 | 74 | { |
mbed_official | 146:f64d43ff0c18 | 75 | HW_ENET_GALR_SET(instance,(1U << ((crcValue >> 26) & kEnetHashValMask))); |
mbed_official | 146:f64d43ff0c18 | 76 | } |
mbed_official | 146:f64d43ff0c18 | 77 | else |
mbed_official | 146:f64d43ff0c18 | 78 | { |
mbed_official | 146:f64d43ff0c18 | 79 | HW_ENET_GAUR_SET(instance,(1U << ((crcValue >> 26) & kEnetHashValMask))); |
mbed_official | 146:f64d43ff0c18 | 80 | } |
mbed_official | 146:f64d43ff0c18 | 81 | break; |
mbed_official | 146:f64d43ff0c18 | 82 | case kEnetSpecialAddressDisable: /* Disable a multicast group address*/ |
mbed_official | 146:f64d43ff0c18 | 83 | if (!((crcValue >> 31) & 1U)) |
mbed_official | 146:f64d43ff0c18 | 84 | { |
mbed_official | 146:f64d43ff0c18 | 85 | HW_ENET_GALR_CLR(instance,(1U << ((crcValue >> 26) & kEnetHashValMask))); |
mbed_official | 146:f64d43ff0c18 | 86 | } |
mbed_official | 146:f64d43ff0c18 | 87 | else |
mbed_official | 146:f64d43ff0c18 | 88 | { |
mbed_official | 146:f64d43ff0c18 | 89 | HW_ENET_GAUR_CLR(instance,(1U << ((crcValue>>26) & kEnetHashValMask))); |
mbed_official | 146:f64d43ff0c18 | 90 | } |
mbed_official | 146:f64d43ff0c18 | 91 | break; |
mbed_official | 146:f64d43ff0c18 | 92 | default: |
mbed_official | 146:f64d43ff0c18 | 93 | break; |
mbed_official | 146:f64d43ff0c18 | 94 | } |
mbed_official | 146:f64d43ff0c18 | 95 | } |
mbed_official | 146:f64d43ff0c18 | 96 | |
mbed_official | 146:f64d43ff0c18 | 97 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 98 | * |
mbed_official | 146:f64d43ff0c18 | 99 | * Function Name: enet_hal_set_individual_hashtable |
mbed_official | 146:f64d43ff0c18 | 100 | * Description: Set a specific unicast address hash value to the mac register |
mbed_official | 146:f64d43ff0c18 | 101 | * To receive frames with the individual destination address. |
mbed_official | 146:f64d43ff0c18 | 102 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 103 | void enet_hal_set_individual_hashtable(uint32_t instance, uint32_t crcValue, enet_special_address_filter_t mode) |
mbed_official | 146:f64d43ff0c18 | 104 | { |
mbed_official | 146:f64d43ff0c18 | 105 | assert(instance < HW_ENET_INSTANCE_COUNT); |
mbed_official | 146:f64d43ff0c18 | 106 | |
mbed_official | 146:f64d43ff0c18 | 107 | switch (mode) |
mbed_official | 146:f64d43ff0c18 | 108 | { |
mbed_official | 146:f64d43ff0c18 | 109 | case kEnetSpecialAddressInit: /* Clear individual address register on ENET initialize */ |
mbed_official | 146:f64d43ff0c18 | 110 | HW_ENET_IALR_WR(instance,0); |
mbed_official | 146:f64d43ff0c18 | 111 | HW_ENET_IAUR_WR(instance,0); |
mbed_official | 146:f64d43ff0c18 | 112 | break; |
mbed_official | 146:f64d43ff0c18 | 113 | case kEnetSpecialAddressEnable: /* Enable a special address*/ |
mbed_official | 146:f64d43ff0c18 | 114 | if (((crcValue >>31) & 1U) == 0) |
mbed_official | 146:f64d43ff0c18 | 115 | { |
mbed_official | 146:f64d43ff0c18 | 116 | HW_ENET_IALR_SET(instance,(1U << ((crcValue>>26)& kEnetHashValMask))); |
mbed_official | 146:f64d43ff0c18 | 117 | } |
mbed_official | 146:f64d43ff0c18 | 118 | else |
mbed_official | 146:f64d43ff0c18 | 119 | { |
mbed_official | 146:f64d43ff0c18 | 120 | HW_ENET_IAUR_SET(instance,(1U << ((crcValue>>26)& kEnetHashValMask))); |
mbed_official | 146:f64d43ff0c18 | 121 | } |
mbed_official | 146:f64d43ff0c18 | 122 | break; |
mbed_official | 146:f64d43ff0c18 | 123 | case kEnetSpecialAddressDisable: /* Disable a special address*/ |
mbed_official | 146:f64d43ff0c18 | 124 | if (((crcValue >>31) & 1U) == 0) |
mbed_official | 146:f64d43ff0c18 | 125 | { |
mbed_official | 146:f64d43ff0c18 | 126 | HW_ENET_IALR_CLR(instance,(1U << ((crcValue>>26)& kEnetHashValMask))); |
mbed_official | 146:f64d43ff0c18 | 127 | } |
mbed_official | 146:f64d43ff0c18 | 128 | else |
mbed_official | 146:f64d43ff0c18 | 129 | { |
mbed_official | 146:f64d43ff0c18 | 130 | HW_ENET_IAUR_CLR(instance,(1U << ((crcValue>>26)& kEnetHashValMask))); |
mbed_official | 146:f64d43ff0c18 | 131 | } |
mbed_official | 146:f64d43ff0c18 | 132 | break; |
mbed_official | 146:f64d43ff0c18 | 133 | default: |
mbed_official | 146:f64d43ff0c18 | 134 | break; |
mbed_official | 146:f64d43ff0c18 | 135 | } |
mbed_official | 146:f64d43ff0c18 | 136 | } |
mbed_official | 146:f64d43ff0c18 | 137 | |
mbed_official | 146:f64d43ff0c18 | 138 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 139 | * |
mbed_official | 146:f64d43ff0c18 | 140 | * Function Name: enet_hal_config_tx_fifo |
mbed_official | 146:f64d43ff0c18 | 141 | * Description: Configure ENET transmit FIFO. |
mbed_official | 146:f64d43ff0c18 | 142 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 143 | void enet_hal_config_tx_fifo(uint32_t instance, enet_config_tx_fifo_t *thresholdCfg) |
mbed_official | 146:f64d43ff0c18 | 144 | { |
mbed_official | 146:f64d43ff0c18 | 145 | assert(instance < HW_ENET_INSTANCE_COUNT); |
mbed_official | 146:f64d43ff0c18 | 146 | assert(thresholdCfg); |
mbed_official | 146:f64d43ff0c18 | 147 | |
mbed_official | 146:f64d43ff0c18 | 148 | BW_ENET_TFWR_STRFWD(instance, thresholdCfg->isStoreForwardEnabled); /* Set store and forward mode*/ |
mbed_official | 146:f64d43ff0c18 | 149 | if(!thresholdCfg->isStoreForwardEnabled) |
mbed_official | 146:f64d43ff0c18 | 150 | { |
mbed_official | 206:00f6ed987803 | 151 | assert(thresholdCfg->txFifoWrite <= BM_ENET_TFWR_TFWR); |
mbed_official | 146:f64d43ff0c18 | 152 | BW_ENET_TFWR_TFWR(instance, thresholdCfg->txFifoWrite); /* Set transmit FIFO write bytes*/ |
mbed_official | 146:f64d43ff0c18 | 153 | } |
mbed_official | 146:f64d43ff0c18 | 154 | BW_ENET_TSEM_TX_SECTION_EMPTY(instance,thresholdCfg->txEmpty); /* Set transmit FIFO empty threshold*/ |
mbed_official | 146:f64d43ff0c18 | 155 | BW_ENET_TAEM_TX_ALMOST_EMPTY(instance,thresholdCfg->txAlmostEmpty); /* Set transmit FIFO almost empty threshold*/ |
mbed_official | 146:f64d43ff0c18 | 156 | BW_ENET_TAFL_TX_ALMOST_FULL(instance,thresholdCfg->txAlmostFull); /* Set transmit FIFO almost full threshold*/ |
mbed_official | 146:f64d43ff0c18 | 157 | } |
mbed_official | 146:f64d43ff0c18 | 158 | |
mbed_official | 146:f64d43ff0c18 | 159 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 160 | * |
mbed_official | 146:f64d43ff0c18 | 161 | * Function Name: enet_hal_config_rx_fifo |
mbed_official | 146:f64d43ff0c18 | 162 | * Description: Configure ENET receive FIFO. |
mbed_official | 146:f64d43ff0c18 | 163 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 164 | void enet_hal_config_rx_fifo(uint32_t instance,enet_config_rx_fifo_t *thresholdCfg ) |
mbed_official | 146:f64d43ff0c18 | 165 | { |
mbed_official | 146:f64d43ff0c18 | 166 | assert(instance < HW_ENET_INSTANCE_COUNT); |
mbed_official | 146:f64d43ff0c18 | 167 | assert(thresholdCfg); |
mbed_official | 146:f64d43ff0c18 | 168 | if(thresholdCfg->rxFull > 0) |
mbed_official | 146:f64d43ff0c18 | 169 | { |
mbed_official | 146:f64d43ff0c18 | 170 | assert(thresholdCfg->rxFull > thresholdCfg->rxAlmostEmpty); |
mbed_official | 146:f64d43ff0c18 | 171 | } |
mbed_official | 146:f64d43ff0c18 | 172 | |
mbed_official | 146:f64d43ff0c18 | 173 | BW_ENET_RSFL_RX_SECTION_FULL(instance,thresholdCfg->rxFull); /* Set receive FIFO full threshold*/ |
mbed_official | 146:f64d43ff0c18 | 174 | BW_ENET_RSEM_RX_SECTION_EMPTY(instance,thresholdCfg->rxEmpty); /* Set receive FIFO empty threshold*/ |
mbed_official | 146:f64d43ff0c18 | 175 | BW_ENET_RAEM_RX_ALMOST_EMPTY(instance,thresholdCfg->rxAlmostEmpty); /* Set receive FIFO almost empty threshold*/ |
mbed_official | 146:f64d43ff0c18 | 176 | BW_ENET_RAFL_RX_ALMOST_FULL(instance,thresholdCfg->rxAlmostFull); /* Set receive FIFO almost full threshold*/ |
mbed_official | 146:f64d43ff0c18 | 177 | } |
mbed_official | 146:f64d43ff0c18 | 178 | |
mbed_official | 146:f64d43ff0c18 | 179 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 180 | * |
mbed_official | 146:f64d43ff0c18 | 181 | * Function Name: enet_hal_init_rxbds |
mbed_official | 146:f64d43ff0c18 | 182 | * Description: Initialize ENET receive buffer descriptors. |
mbed_official | 146:f64d43ff0c18 | 183 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 184 | void enet_hal_init_rxbds(void *rxBds, uint8_t *buffer, bool isLastBd) |
mbed_official | 146:f64d43ff0c18 | 185 | { |
mbed_official | 146:f64d43ff0c18 | 186 | assert(rxBds); |
mbed_official | 146:f64d43ff0c18 | 187 | assert(buffer); |
mbed_official | 146:f64d43ff0c18 | 188 | |
mbed_official | 146:f64d43ff0c18 | 189 | volatile enet_bd_struct_t *bdPtr = (enet_bd_struct_t *)rxBds; |
mbed_official | 146:f64d43ff0c18 | 190 | |
mbed_official | 146:f64d43ff0c18 | 191 | bdPtr->buffer = (uint8_t *)NTOHL((uint32_t)buffer); /* Set data buffer address */ |
mbed_official | 146:f64d43ff0c18 | 192 | bdPtr->length = 0; /* Initialize data length*/ |
mbed_official | 146:f64d43ff0c18 | 193 | |
mbed_official | 146:f64d43ff0c18 | 194 | /*The last buffer descriptor should be set with the wrap flag*/ |
mbed_official | 146:f64d43ff0c18 | 195 | if (isLastBd) |
mbed_official | 146:f64d43ff0c18 | 196 | { |
mbed_official | 146:f64d43ff0c18 | 197 | bdPtr->control |= kEnetRxBdWrap; |
mbed_official | 146:f64d43ff0c18 | 198 | } |
mbed_official | 146:f64d43ff0c18 | 199 | bdPtr->control |= kEnetRxBdEmpty; /* Initialize bd with empty bit*/ |
mbed_official | 146:f64d43ff0c18 | 200 | bdPtr->controlExtend1 |= kEnetRxBdIntrrupt;/* Enable receive interrupt*/ |
mbed_official | 146:f64d43ff0c18 | 201 | } |
mbed_official | 146:f64d43ff0c18 | 202 | |
mbed_official | 146:f64d43ff0c18 | 203 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 204 | * |
mbed_official | 146:f64d43ff0c18 | 205 | * Function Name: enet_hal_init_txbds |
mbed_official | 146:f64d43ff0c18 | 206 | * Description: Initialize ENET transmit buffer descriptors. |
mbed_official | 146:f64d43ff0c18 | 207 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 208 | void enet_hal_init_txbds(void *txBds, bool isLastBd) |
mbed_official | 146:f64d43ff0c18 | 209 | { |
mbed_official | 146:f64d43ff0c18 | 210 | assert(txBds); |
mbed_official | 146:f64d43ff0c18 | 211 | |
mbed_official | 146:f64d43ff0c18 | 212 | volatile enet_bd_struct_t *bdPtr = (enet_bd_struct_t *)txBds; |
mbed_official | 146:f64d43ff0c18 | 213 | |
mbed_official | 146:f64d43ff0c18 | 214 | bdPtr->length = 0; /* Initialize data length*/ |
mbed_official | 146:f64d43ff0c18 | 215 | |
mbed_official | 146:f64d43ff0c18 | 216 | /*The last buffer descriptor should be set with the wrap flag*/ |
mbed_official | 146:f64d43ff0c18 | 217 | if (isLastBd) |
mbed_official | 146:f64d43ff0c18 | 218 | { |
mbed_official | 146:f64d43ff0c18 | 219 | bdPtr->control |= kEnetTxBdWrap; |
mbed_official | 146:f64d43ff0c18 | 220 | } |
mbed_official | 146:f64d43ff0c18 | 221 | } |
mbed_official | 146:f64d43ff0c18 | 222 | |
mbed_official | 146:f64d43ff0c18 | 223 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 224 | * |
mbed_official | 146:f64d43ff0c18 | 225 | * Function Name: enet_hal_update_rxbds |
mbed_official | 146:f64d43ff0c18 | 226 | * Description: Update ENET receive buffer descriptors. |
mbed_official | 146:f64d43ff0c18 | 227 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 228 | void enet_hal_update_rxbds(void *rxBds, uint8_t *data, bool isbufferUpdate) |
mbed_official | 146:f64d43ff0c18 | 229 | { |
mbed_official | 146:f64d43ff0c18 | 230 | assert(rxBds); |
mbed_official | 146:f64d43ff0c18 | 231 | |
mbed_official | 146:f64d43ff0c18 | 232 | volatile enet_bd_struct_t *bdPtr = (enet_bd_struct_t *)rxBds; |
mbed_official | 146:f64d43ff0c18 | 233 | |
mbed_official | 146:f64d43ff0c18 | 234 | if (isbufferUpdate) |
mbed_official | 146:f64d43ff0c18 | 235 | { |
mbed_official | 146:f64d43ff0c18 | 236 | bdPtr->buffer = (uint8_t *)HTONL((uint32_t)data); |
mbed_official | 146:f64d43ff0c18 | 237 | } |
mbed_official | 146:f64d43ff0c18 | 238 | bdPtr->control &= kEnetRxBdWrap; /* Clear status*/ |
mbed_official | 146:f64d43ff0c18 | 239 | bdPtr->control |= kEnetRxBdEmpty; /* Set rx bd empty*/ |
mbed_official | 146:f64d43ff0c18 | 240 | bdPtr->controlExtend1 |= kEnetRxBdIntrrupt;/* Enable interrupt*/ |
mbed_official | 146:f64d43ff0c18 | 241 | } |
mbed_official | 146:f64d43ff0c18 | 242 | |
mbed_official | 146:f64d43ff0c18 | 243 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 244 | * |
mbed_official | 146:f64d43ff0c18 | 245 | * Function Name: enet_hal_update_txbds |
mbed_official | 146:f64d43ff0c18 | 246 | * Description: Update ENET transmit buffer descriptors. |
mbed_official | 146:f64d43ff0c18 | 247 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 248 | void enet_hal_update_txbds(void *txBds,uint8_t *buffer, uint16_t length, bool isTxtsCfged) |
mbed_official | 146:f64d43ff0c18 | 249 | { |
mbed_official | 146:f64d43ff0c18 | 250 | assert(txBds); |
mbed_official | 146:f64d43ff0c18 | 251 | assert(buffer); |
mbed_official | 146:f64d43ff0c18 | 252 | |
mbed_official | 146:f64d43ff0c18 | 253 | volatile enet_bd_struct_t * bdPtr = (enet_bd_struct_t *)txBds; |
mbed_official | 146:f64d43ff0c18 | 254 | |
mbed_official | 146:f64d43ff0c18 | 255 | bdPtr->length = HTONS(length); /* Set data length*/ |
mbed_official | 146:f64d43ff0c18 | 256 | bdPtr->buffer = (uint8_t *)HTONL((uint32_t)buffer); /* Set data buffer*/ |
mbed_official | 146:f64d43ff0c18 | 257 | bdPtr->control |= kEnetTxBdLast | kEnetTxBdTransmitCrc | kEnetTxBdReady;/* set control */ |
mbed_official | 146:f64d43ff0c18 | 258 | if (isTxtsCfged) |
mbed_official | 146:f64d43ff0c18 | 259 | { |
mbed_official | 146:f64d43ff0c18 | 260 | /* Set receive and timestamp interrupt*/ |
mbed_official | 146:f64d43ff0c18 | 261 | bdPtr->controlExtend1 |= (kEnetTxBdTxInterrupt | kEnetTxBdTimeStamp); |
mbed_official | 146:f64d43ff0c18 | 262 | } |
mbed_official | 146:f64d43ff0c18 | 263 | else |
mbed_official | 146:f64d43ff0c18 | 264 | { |
mbed_official | 146:f64d43ff0c18 | 265 | /* Set receive interrupt*/ |
mbed_official | 146:f64d43ff0c18 | 266 | bdPtr->controlExtend1 |= kEnetTxBdTxInterrupt; |
mbed_official | 146:f64d43ff0c18 | 267 | } |
mbed_official | 146:f64d43ff0c18 | 268 | } |
mbed_official | 146:f64d43ff0c18 | 269 | |
mbed_official | 146:f64d43ff0c18 | 270 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 271 | * |
mbed_official | 146:f64d43ff0c18 | 272 | * Function Name: enet_hal_get_rxbd_control |
mbed_official | 146:f64d43ff0c18 | 273 | * Description: Get receive buffer descriptor control and status region. |
mbed_official | 146:f64d43ff0c18 | 274 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 275 | uint16_t enet_hal_get_rxbd_control(void *curBd) |
mbed_official | 146:f64d43ff0c18 | 276 | { |
mbed_official | 146:f64d43ff0c18 | 277 | assert(curBd); |
mbed_official | 146:f64d43ff0c18 | 278 | |
mbed_official | 146:f64d43ff0c18 | 279 | volatile enet_bd_struct_t *bdPtr = (enet_bd_struct_t *)curBd; |
mbed_official | 146:f64d43ff0c18 | 280 | return bdPtr->control; |
mbed_official | 146:f64d43ff0c18 | 281 | } |
mbed_official | 146:f64d43ff0c18 | 282 | |
mbed_official | 146:f64d43ff0c18 | 283 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 284 | * |
mbed_official | 146:f64d43ff0c18 | 285 | * Function Name: enet_hal_get_txbd_control |
mbed_official | 146:f64d43ff0c18 | 286 | * Description: Get ENET transmit buffer descriptor control and status data. |
mbed_official | 146:f64d43ff0c18 | 287 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 288 | uint16_t enet_hal_get_txbd_control(void *curBd) |
mbed_official | 146:f64d43ff0c18 | 289 | { |
mbed_official | 146:f64d43ff0c18 | 290 | assert(curBd); |
mbed_official | 146:f64d43ff0c18 | 291 | volatile enet_bd_struct_t *bdPtr = (enet_bd_struct_t *)curBd; |
mbed_official | 146:f64d43ff0c18 | 292 | return bdPtr->control; |
mbed_official | 146:f64d43ff0c18 | 293 | } |
mbed_official | 146:f64d43ff0c18 | 294 | |
mbed_official | 146:f64d43ff0c18 | 295 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 296 | * |
mbed_official | 146:f64d43ff0c18 | 297 | * Function Name: enet_hal_get_bd_length |
mbed_official | 146:f64d43ff0c18 | 298 | * Description: Get ENET data length of buffer descriptors. |
mbed_official | 146:f64d43ff0c18 | 299 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 300 | uint16_t enet_hal_get_bd_length(void *curBd) |
mbed_official | 146:f64d43ff0c18 | 301 | { |
mbed_official | 146:f64d43ff0c18 | 302 | assert(curBd); |
mbed_official | 146:f64d43ff0c18 | 303 | uint16_t length; |
mbed_official | 146:f64d43ff0c18 | 304 | |
mbed_official | 146:f64d43ff0c18 | 305 | volatile enet_bd_struct_t *bdPtr = (enet_bd_struct_t *)curBd; |
mbed_official | 146:f64d43ff0c18 | 306 | length = bdPtr->length; |
mbed_official | 146:f64d43ff0c18 | 307 | return NTOHS(length); |
mbed_official | 146:f64d43ff0c18 | 308 | } |
mbed_official | 146:f64d43ff0c18 | 309 | |
mbed_official | 146:f64d43ff0c18 | 310 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 311 | * |
mbed_official | 146:f64d43ff0c18 | 312 | * Function Name: enet_hal_get_bd_buffer |
mbed_official | 146:f64d43ff0c18 | 313 | * Description: Get the buffer address of buffer descriptors. |
mbed_official | 146:f64d43ff0c18 | 314 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 315 | uint8_t* enet_hal_get_bd_buffer(void *curBd) |
mbed_official | 146:f64d43ff0c18 | 316 | { |
mbed_official | 146:f64d43ff0c18 | 317 | assert(curBd); |
mbed_official | 146:f64d43ff0c18 | 318 | |
mbed_official | 146:f64d43ff0c18 | 319 | volatile enet_bd_struct_t *bdPtr = (enet_bd_struct_t *)curBd; |
mbed_official | 146:f64d43ff0c18 | 320 | uint32_t buffer = (uint32_t)(bdPtr->buffer); |
mbed_official | 146:f64d43ff0c18 | 321 | return (uint8_t *)NTOHL(buffer); |
mbed_official | 146:f64d43ff0c18 | 322 | } |
mbed_official | 146:f64d43ff0c18 | 323 | |
mbed_official | 146:f64d43ff0c18 | 324 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 325 | * |
mbed_official | 146:f64d43ff0c18 | 326 | * Function Name: enet_hal_get_bd_timestamp |
mbed_official | 146:f64d43ff0c18 | 327 | * Description: Get the timestamp of buffer descriptors. |
mbed_official | 146:f64d43ff0c18 | 328 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 329 | uint32_t enet_hal_get_bd_timestamp(void *curBd) |
mbed_official | 146:f64d43ff0c18 | 330 | { |
mbed_official | 146:f64d43ff0c18 | 331 | assert(curBd); |
mbed_official | 146:f64d43ff0c18 | 332 | volatile enet_bd_struct_t *bdPtr = (enet_bd_struct_t *)curBd; |
mbed_official | 146:f64d43ff0c18 | 333 | uint32_t timestamp = bdPtr->timestamp; |
mbed_official | 146:f64d43ff0c18 | 334 | return NTOHL(timestamp); |
mbed_official | 146:f64d43ff0c18 | 335 | } |
mbed_official | 146:f64d43ff0c18 | 336 | |
mbed_official | 146:f64d43ff0c18 | 337 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 338 | * |
mbed_official | 146:f64d43ff0c18 | 339 | * Function Name: enet_hal_get_rxbd_control_extend |
mbed_official | 146:f64d43ff0c18 | 340 | * Description: Get ENET receive buffer descriptor extended control region. |
mbed_official | 146:f64d43ff0c18 | 341 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 342 | bool enet_hal_get_rxbd_control_extend(void *curBd,enet_rx_bd_control_extend_t controlRegion) |
mbed_official | 146:f64d43ff0c18 | 343 | { |
mbed_official | 146:f64d43ff0c18 | 344 | assert(curBd); |
mbed_official | 146:f64d43ff0c18 | 345 | |
mbed_official | 146:f64d43ff0c18 | 346 | volatile enet_bd_struct_t *bdPtr = (enet_bd_struct_t *)curBd; |
mbed_official | 146:f64d43ff0c18 | 347 | |
mbed_official | 146:f64d43ff0c18 | 348 | #if SYSTEM_LITTLE_ENDIAN && FSL_FEATURE_ENET_DMA_BIG_ENDIAN_ONLY |
mbed_official | 146:f64d43ff0c18 | 349 | if (((uint16_t)controlRegion > kEnetRxBdCtlJudge1) && ((uint16_t)controlRegion < kEnetRxBdCtlJudge2)) |
mbed_official | 146:f64d43ff0c18 | 350 | { |
mbed_official | 146:f64d43ff0c18 | 351 | return ((bdPtr->controlExtend0 & controlRegion) != 0); /* Control extended0 region*/ |
mbed_official | 146:f64d43ff0c18 | 352 | } |
mbed_official | 146:f64d43ff0c18 | 353 | else |
mbed_official | 146:f64d43ff0c18 | 354 | { |
mbed_official | 146:f64d43ff0c18 | 355 | return ((bdPtr->controlExtend1 & controlRegion) != 0); /* Control extended1 region*/ |
mbed_official | 146:f64d43ff0c18 | 356 | } |
mbed_official | 146:f64d43ff0c18 | 357 | #else |
mbed_official | 146:f64d43ff0c18 | 358 | if( (uint16_t)controlRegion < kEnetRxBdCtlJudge1) |
mbed_official | 146:f64d43ff0c18 | 359 | { |
mbed_official | 146:f64d43ff0c18 | 360 | return ((bdPtr->controlExtend0 & controlRegion) != 0); /* Control extended0 region*/ |
mbed_official | 146:f64d43ff0c18 | 361 | } |
mbed_official | 146:f64d43ff0c18 | 362 | else |
mbed_official | 146:f64d43ff0c18 | 363 | { |
mbed_official | 146:f64d43ff0c18 | 364 | return ((bdPtr->controlExtend1 & controlRegion) != 0);/* Control extended1 region*/ |
mbed_official | 146:f64d43ff0c18 | 365 | } |
mbed_official | 146:f64d43ff0c18 | 366 | #endif |
mbed_official | 146:f64d43ff0c18 | 367 | } |
mbed_official | 146:f64d43ff0c18 | 368 | |
mbed_official | 146:f64d43ff0c18 | 369 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 370 | * |
mbed_official | 146:f64d43ff0c18 | 371 | * Function Name: enet_hal_get_txbd_control_extend |
mbed_official | 146:f64d43ff0c18 | 372 | * Description: Get ENET transmit buffer descriptor extended control region. |
mbed_official | 146:f64d43ff0c18 | 373 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 374 | uint16_t enet_hal_get_txbd_control_extend(void *curBd) |
mbed_official | 146:f64d43ff0c18 | 375 | { |
mbed_official | 146:f64d43ff0c18 | 376 | assert(curBd); |
mbed_official | 146:f64d43ff0c18 | 377 | volatile enet_bd_struct_t *bdPtr = (enet_bd_struct_t *)curBd; |
mbed_official | 146:f64d43ff0c18 | 378 | |
mbed_official | 146:f64d43ff0c18 | 379 | return bdPtr->controlExtend0; |
mbed_official | 146:f64d43ff0c18 | 380 | } |
mbed_official | 146:f64d43ff0c18 | 381 | |
mbed_official | 146:f64d43ff0c18 | 382 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 383 | * |
mbed_official | 146:f64d43ff0c18 | 384 | * Function Name: enet_hal_get_txbd_timestamp_flag |
mbed_official | 146:f64d43ff0c18 | 385 | * Description: Get ENET transmit buffer descriptor timestamp region. |
mbed_official | 146:f64d43ff0c18 | 386 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 387 | bool enet_hal_get_txbd_timestamp_flag(void *curBd) |
mbed_official | 146:f64d43ff0c18 | 388 | { |
mbed_official | 146:f64d43ff0c18 | 389 | assert(curBd); |
mbed_official | 146:f64d43ff0c18 | 390 | volatile enet_bd_struct_t *bdPtr = (enet_bd_struct_t *)curBd; |
mbed_official | 146:f64d43ff0c18 | 391 | return ((bdPtr->controlExtend1 & kEnetTxBdTimeStamp) != 0); |
mbed_official | 146:f64d43ff0c18 | 392 | } |
mbed_official | 146:f64d43ff0c18 | 393 | |
mbed_official | 146:f64d43ff0c18 | 394 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 395 | * |
mbed_official | 146:f64d43ff0c18 | 396 | * Function Name: enet_hal_config_rmii |
mbed_official | 146:f64d43ff0c18 | 397 | * Description: Configure (R)MII mode. |
mbed_official | 146:f64d43ff0c18 | 398 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 399 | void enet_hal_config_rmii(uint32_t instance, enet_config_rmii_t mode, enet_config_speed_t speed, enet_config_duplex_t duplex, bool isRxOnTxDisabled, bool isLoopEnabled) |
mbed_official | 146:f64d43ff0c18 | 400 | { |
mbed_official | 146:f64d43ff0c18 | 401 | assert(instance < HW_ENET_INSTANCE_COUNT); |
mbed_official | 146:f64d43ff0c18 | 402 | |
mbed_official | 146:f64d43ff0c18 | 403 | BW_ENET_RCR_MII_MODE(instance,1); /* Set mii mode */ |
mbed_official | 146:f64d43ff0c18 | 404 | BW_ENET_RCR_RMII_MODE(instance,mode); |
mbed_official | 146:f64d43ff0c18 | 405 | BW_ENET_RCR_RMII_10T(instance,speed); /* Set speed mode */ |
mbed_official | 146:f64d43ff0c18 | 406 | BW_ENET_TCR_FDEN(instance,duplex); /* Set duplex mode*/ |
mbed_official | 146:f64d43ff0c18 | 407 | if ((!duplex) && isRxOnTxDisabled) |
mbed_official | 146:f64d43ff0c18 | 408 | { |
mbed_official | 146:f64d43ff0c18 | 409 | BW_ENET_RCR_DRT(instance,1); /* Disable receive on transmit*/ |
mbed_official | 146:f64d43ff0c18 | 410 | } |
mbed_official | 146:f64d43ff0c18 | 411 | |
mbed_official | 146:f64d43ff0c18 | 412 | if (mode == kEnetCfgMii) /* Set internal loop only for mii mode*/ |
mbed_official | 146:f64d43ff0c18 | 413 | { |
mbed_official | 146:f64d43ff0c18 | 414 | BW_ENET_RCR_LOOP(instance,isLoopEnabled); |
mbed_official | 146:f64d43ff0c18 | 415 | } |
mbed_official | 146:f64d43ff0c18 | 416 | else |
mbed_official | 146:f64d43ff0c18 | 417 | { |
mbed_official | 146:f64d43ff0c18 | 418 | BW_ENET_RCR_LOOP(instance, 0); /* Clear internal loop for rmii mode*/ |
mbed_official | 146:f64d43ff0c18 | 419 | } |
mbed_official | 146:f64d43ff0c18 | 420 | } |
mbed_official | 146:f64d43ff0c18 | 421 | |
mbed_official | 146:f64d43ff0c18 | 422 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 423 | * |
mbed_official | 146:f64d43ff0c18 | 424 | * Function Name: enet_hal_set_mii_command |
mbed_official | 146:f64d43ff0c18 | 425 | * Description: Set MII command. |
mbed_official | 146:f64d43ff0c18 | 426 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 427 | void enet_hal_set_mii_command(uint32_t instance, uint32_t phyAddr, uint32_t phyReg, enet_mii_operation_t operation, uint32_t data) |
mbed_official | 146:f64d43ff0c18 | 428 | { |
mbed_official | 146:f64d43ff0c18 | 429 | assert(instance < HW_ENET_INSTANCE_COUNT); |
mbed_official | 146:f64d43ff0c18 | 430 | uint32_t mmfrValue = 0 ; |
mbed_official | 146:f64d43ff0c18 | 431 | |
mbed_official | 146:f64d43ff0c18 | 432 | mmfrValue = BF_ENET_MMFR_ST(1)| BF_ENET_MMFR_OP(operation)| BF_ENET_MMFR_PA(phyAddr) | BF_ENET_MMFR_RA(phyReg)| BF_ENET_MMFR_TA(2) | (data&0xFFFF); /* mii command*/ |
mbed_official | 146:f64d43ff0c18 | 433 | HW_ENET_MMFR_WR(instance,mmfrValue); |
mbed_official | 146:f64d43ff0c18 | 434 | } |
mbed_official | 146:f64d43ff0c18 | 435 | |
mbed_official | 146:f64d43ff0c18 | 436 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 437 | * |
mbed_official | 146:f64d43ff0c18 | 438 | * Function Name: enet_hal_config_ethernet |
mbed_official | 146:f64d43ff0c18 | 439 | * Description: Enable or disable normal Ethernet mode and enhanced mode. |
mbed_official | 146:f64d43ff0c18 | 440 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 441 | void enet_hal_config_ethernet(uint32_t instance, bool isEnhanced, bool isEnabled) |
mbed_official | 146:f64d43ff0c18 | 442 | { |
mbed_official | 146:f64d43ff0c18 | 443 | assert(instance < HW_ENET_INSTANCE_COUNT); |
mbed_official | 146:f64d43ff0c18 | 444 | |
mbed_official | 146:f64d43ff0c18 | 445 | BW_ENET_ECR_ETHEREN(instance,isEnabled); /* Enable/Disable Ethernet module*/ |
mbed_official | 146:f64d43ff0c18 | 446 | if (isEnhanced) |
mbed_official | 146:f64d43ff0c18 | 447 | { |
mbed_official | 146:f64d43ff0c18 | 448 | BW_ENET_ECR_EN1588(instance,isEnabled); /* Enable/Disable enhanced frame feature*/ |
mbed_official | 146:f64d43ff0c18 | 449 | } |
mbed_official | 146:f64d43ff0c18 | 450 | #if SYSTEM_LITTLE_ENDIAN && !FSL_FEATURE_ENET_DMA_BIG_ENDIAN_ONLY |
mbed_official | 146:f64d43ff0c18 | 451 | BW_ENET_ECR_DBSWP(instance,1); /* buffer descriptor byte swapping for little-endian system and endianness configurable IP*/ |
mbed_official | 146:f64d43ff0c18 | 452 | #endif |
mbed_official | 146:f64d43ff0c18 | 453 | } |
mbed_official | 146:f64d43ff0c18 | 454 | |
mbed_official | 146:f64d43ff0c18 | 455 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 456 | * |
mbed_official | 146:f64d43ff0c18 | 457 | * Function Name: enet_hal_config_interrupt |
mbed_official | 146:f64d43ff0c18 | 458 | * Description: Enable or disable different Ethernet interrupts. |
mbed_official | 146:f64d43ff0c18 | 459 | * the parameter source is the interrupt source and enet_interrupt_request_t |
mbed_official | 146:f64d43ff0c18 | 460 | * enum types is recommended to be used as the interrupt sources. |
mbed_official | 146:f64d43ff0c18 | 461 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 462 | void enet_hal_config_interrupt(uint32_t instance, uint32_t source, bool isEnabled) |
mbed_official | 146:f64d43ff0c18 | 463 | { |
mbed_official | 146:f64d43ff0c18 | 464 | assert(instance < HW_ENET_INSTANCE_COUNT); |
mbed_official | 146:f64d43ff0c18 | 465 | |
mbed_official | 146:f64d43ff0c18 | 466 | if (isEnabled) |
mbed_official | 146:f64d43ff0c18 | 467 | { |
mbed_official | 146:f64d43ff0c18 | 468 | HW_ENET_EIMR_SET(instance,source); /* Enable interrupt */ |
mbed_official | 146:f64d43ff0c18 | 469 | } |
mbed_official | 146:f64d43ff0c18 | 470 | else |
mbed_official | 146:f64d43ff0c18 | 471 | { |
mbed_official | 146:f64d43ff0c18 | 472 | HW_ENET_EIMR_CLR(instance,source); /* Disable interrupt*/ |
mbed_official | 146:f64d43ff0c18 | 473 | } |
mbed_official | 146:f64d43ff0c18 | 474 | } |
mbed_official | 146:f64d43ff0c18 | 475 | |
mbed_official | 146:f64d43ff0c18 | 476 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 477 | * |
mbed_official | 146:f64d43ff0c18 | 478 | * Function Name: enet_hal_config_tx_accelerator |
mbed_official | 146:f64d43ff0c18 | 479 | * Description: Configure Ethernet transmit accelerator features. |
mbed_official | 146:f64d43ff0c18 | 480 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 481 | void enet_hal_config_tx_accelerator(uint32_t instance, enet_config_tx_accelerator_t *txCfgPtr) |
mbed_official | 146:f64d43ff0c18 | 482 | { |
mbed_official | 146:f64d43ff0c18 | 483 | assert(instance < HW_ENET_INSTANCE_COUNT); |
mbed_official | 146:f64d43ff0c18 | 484 | assert(txCfgPtr); |
mbed_official | 146:f64d43ff0c18 | 485 | |
mbed_official | 146:f64d43ff0c18 | 486 | HW_ENET_TACC_WR(instance,0); /* Clear all*/ |
mbed_official | 146:f64d43ff0c18 | 487 | BW_ENET_TACC_IPCHK(instance,txCfgPtr->isIpCheckEnabled); /* Insert ipheader checksum */ |
mbed_official | 146:f64d43ff0c18 | 488 | BW_ENET_TACC_PROCHK(instance,txCfgPtr->isProtocolCheckEnabled); /* Insert protocol checksum*/ |
mbed_official | 146:f64d43ff0c18 | 489 | BW_ENET_TACC_SHIFT16(instance,txCfgPtr->isShift16Enabled); /* Set tx fifo shift-16*/ |
mbed_official | 146:f64d43ff0c18 | 490 | } |
mbed_official | 146:f64d43ff0c18 | 491 | |
mbed_official | 146:f64d43ff0c18 | 492 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 493 | * |
mbed_official | 146:f64d43ff0c18 | 494 | * Function Name: enet_hal_config_rx_accelerator |
mbed_official | 146:f64d43ff0c18 | 495 | * Description: Configure Ethernet receive accelerator features. |
mbed_official | 146:f64d43ff0c18 | 496 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 497 | void enet_hal_config_rx_accelerator(uint32_t instance, enet_config_rx_accelerator_t *rxCfgPtr) |
mbed_official | 146:f64d43ff0c18 | 498 | { |
mbed_official | 146:f64d43ff0c18 | 499 | assert(instance < HW_ENET_INSTANCE_COUNT); |
mbed_official | 146:f64d43ff0c18 | 500 | assert(rxCfgPtr); |
mbed_official | 146:f64d43ff0c18 | 501 | |
mbed_official | 146:f64d43ff0c18 | 502 | HW_ENET_RACC_WR(instance,0); /* Clear all*/ |
mbed_official | 146:f64d43ff0c18 | 503 | BW_ENET_RACC_IPDIS(instance,rxCfgPtr->isIpcheckEnabled); /* Set ipchecksum field*/ |
mbed_official | 146:f64d43ff0c18 | 504 | BW_ENET_RACC_PRODIS(instance,rxCfgPtr->isProtocolCheckEnabled); /* Set protocol field*/ |
mbed_official | 146:f64d43ff0c18 | 505 | BW_ENET_RACC_LINEDIS(instance,rxCfgPtr->isMacCheckEnabled); /* Set maccheck field*/ |
mbed_official | 146:f64d43ff0c18 | 506 | BW_ENET_RACC_SHIFT16(instance,rxCfgPtr->isShift16Enabled); /* Set rx fifo shift field*/ |
mbed_official | 146:f64d43ff0c18 | 507 | BW_ENET_RACC_PADREM(instance,rxCfgPtr->isPadRemoveEnabled); /* Set rx padding remove field*/ |
mbed_official | 146:f64d43ff0c18 | 508 | } |
mbed_official | 146:f64d43ff0c18 | 509 | |
mbed_official | 146:f64d43ff0c18 | 510 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 511 | * |
mbed_official | 146:f64d43ff0c18 | 512 | * Function Name: enet_hal_set_txpause |
mbed_official | 146:f64d43ff0c18 | 513 | * Return Value: The execution status. |
mbed_official | 146:f64d43ff0c18 | 514 | * Description: Set the ENET transmit controller with pause duration and |
mbed_official | 146:f64d43ff0c18 | 515 | * Set enet transmit PAUSE frame transmission. |
mbed_official | 146:f64d43ff0c18 | 516 | * This should be called when a PAUSE frame is dynamically wanted. |
mbed_official | 146:f64d43ff0c18 | 517 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 518 | void enet_hal_set_txpause(uint32_t instance, uint32_t pauseDuration) |
mbed_official | 146:f64d43ff0c18 | 519 | { |
mbed_official | 146:f64d43ff0c18 | 520 | assert(instance < HW_ENET_INSTANCE_COUNT); |
mbed_official | 146:f64d43ff0c18 | 521 | assert(pauseDuration <= BM_ENET_OPD_PAUSE_DUR); |
mbed_official | 146:f64d43ff0c18 | 522 | BW_ENET_OPD_PAUSE_DUR(instance, pauseDuration); |
mbed_official | 146:f64d43ff0c18 | 523 | BW_ENET_TCR_TFC_PAUSE(instance, 1); |
mbed_official | 146:f64d43ff0c18 | 524 | } |
mbed_official | 146:f64d43ff0c18 | 525 | |
mbed_official | 146:f64d43ff0c18 | 526 | /*FUNCTION**************************************************************** |
mbed_official | 146:f64d43ff0c18 | 527 | * |
mbed_official | 146:f64d43ff0c18 | 528 | * Function Name: enet_hal_init_ptp_timer |
mbed_official | 146:f64d43ff0c18 | 529 | * Description: Initialize Ethernet ptp timer. |
mbed_official | 146:f64d43ff0c18 | 530 | *END*********************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 531 | void enet_hal_init_ptp_timer(uint32_t instance,enet_config_ptp_timer_t *ptpCfgPtr) |
mbed_official | 146:f64d43ff0c18 | 532 | { |
mbed_official | 146:f64d43ff0c18 | 533 | assert(instance < HW_ENET_INSTANCE_COUNT); |
mbed_official | 146:f64d43ff0c18 | 534 | assert(ptpCfgPtr); |
mbed_official | 146:f64d43ff0c18 | 535 | |
mbed_official | 146:f64d43ff0c18 | 536 | BW_ENET_ATINC_INC(instance, ptpCfgPtr->clockIncease); /* Set increase value for ptp timer*/ |
mbed_official | 146:f64d43ff0c18 | 537 | HW_ENET_ATPER_WR(instance, ptpCfgPtr->period); /* Set wrap time for ptp timer*/ |
mbed_official | 146:f64d43ff0c18 | 538 | /* set periodical event and the event signal output assertion*/ |
mbed_official | 146:f64d43ff0c18 | 539 | BW_ENET_ATCR_PEREN(instance, 1); |
mbed_official | 146:f64d43ff0c18 | 540 | BW_ENET_ATCR_PINPER(instance, 1); |
mbed_official | 146:f64d43ff0c18 | 541 | /* Set ptp timer slave/master mode*/ |
mbed_official | 146:f64d43ff0c18 | 542 | BW_ENET_ATCR_SLAVE(instance, ptpCfgPtr->isSlaveEnabled); |
mbed_official | 146:f64d43ff0c18 | 543 | } |
mbed_official | 146:f64d43ff0c18 | 544 | |
mbed_official | 146:f64d43ff0c18 | 545 | /******************************************************************************* |
mbed_official | 146:f64d43ff0c18 | 546 | * EOF |
mbed_official | 146:f64d43ff0c18 | 547 | ******************************************************************************/ |
mbed_official | 146:f64d43ff0c18 | 548 |