123r
Dependencies: WNC14A2AInterface
mcr20a-rf-driver/source/MCR20Drv.c@7:c8e4e62c5fa7, 2019-05-02 (annotated)
- Committer:
- m_ahsan
- Date:
- Thu May 02 13:15:26 2019 +0000
- Revision:
- 7:c8e4e62c5fa7
- Parent:
- 0:2563b0415d1f
123
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JMF | 0:2563b0415d1f | 1 | /*! |
JMF | 0:2563b0415d1f | 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. |
JMF | 0:2563b0415d1f | 3 | * All rights reserved. |
JMF | 0:2563b0415d1f | 4 | * |
JMF | 0:2563b0415d1f | 5 | * \file MCR20Drv.c |
JMF | 0:2563b0415d1f | 6 | * |
JMF | 0:2563b0415d1f | 7 | * Redistribution and use in source and binary forms, with or without modification, |
JMF | 0:2563b0415d1f | 8 | * are permitted provided that the following conditions are met: |
JMF | 0:2563b0415d1f | 9 | * |
JMF | 0:2563b0415d1f | 10 | * o Redistributions of source code must retain the above copyright notice, this list |
JMF | 0:2563b0415d1f | 11 | * of conditions and the following disclaimer. |
JMF | 0:2563b0415d1f | 12 | * |
JMF | 0:2563b0415d1f | 13 | * o Redistributions in binary form must reproduce the above copyright notice, this |
JMF | 0:2563b0415d1f | 14 | * list of conditions and the following disclaimer in the documentation and/or |
JMF | 0:2563b0415d1f | 15 | * other materials provided with the distribution. |
JMF | 0:2563b0415d1f | 16 | * |
JMF | 0:2563b0415d1f | 17 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
JMF | 0:2563b0415d1f | 18 | * contributors may be used to endorse or promote products derived from this |
JMF | 0:2563b0415d1f | 19 | * software without specific prior written permission. |
JMF | 0:2563b0415d1f | 20 | * |
JMF | 0:2563b0415d1f | 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
JMF | 0:2563b0415d1f | 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
JMF | 0:2563b0415d1f | 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
JMF | 0:2563b0415d1f | 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
JMF | 0:2563b0415d1f | 25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
JMF | 0:2563b0415d1f | 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
JMF | 0:2563b0415d1f | 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
JMF | 0:2563b0415d1f | 28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
JMF | 0:2563b0415d1f | 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
JMF | 0:2563b0415d1f | 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
JMF | 0:2563b0415d1f | 31 | */ |
JMF | 0:2563b0415d1f | 32 | |
JMF | 0:2563b0415d1f | 33 | |
JMF | 0:2563b0415d1f | 34 | /***************************************************************************** |
JMF | 0:2563b0415d1f | 35 | * INCLUDED HEADERS * |
JMF | 0:2563b0415d1f | 36 | *---------------------------------------------------------------------------* |
JMF | 0:2563b0415d1f | 37 | * Add to this section all the headers that this module needs to include. * |
JMF | 0:2563b0415d1f | 38 | *---------------------------------------------------------------------------* |
JMF | 0:2563b0415d1f | 39 | *****************************************************************************/ |
JMF | 0:2563b0415d1f | 40 | |
JMF | 0:2563b0415d1f | 41 | #include "platform/arm_hal_interrupt.h" |
JMF | 0:2563b0415d1f | 42 | #include "MCR20Drv.h" |
JMF | 0:2563b0415d1f | 43 | #include "MCR20Reg.h" |
JMF | 0:2563b0415d1f | 44 | #include "XcvrSpi.h" |
JMF | 0:2563b0415d1f | 45 | |
JMF | 0:2563b0415d1f | 46 | |
JMF | 0:2563b0415d1f | 47 | /***************************************************************************** |
JMF | 0:2563b0415d1f | 48 | * PRIVATE VARIABLES * |
JMF | 0:2563b0415d1f | 49 | *---------------------------------------------------------------------------* |
JMF | 0:2563b0415d1f | 50 | * Add to this section all the variables and constants that have local * |
JMF | 0:2563b0415d1f | 51 | * (file) scope. * |
JMF | 0:2563b0415d1f | 52 | * Each of this declarations shall be preceded by the 'static' keyword. * |
JMF | 0:2563b0415d1f | 53 | * These variables / constants cannot be accessed outside this module. * |
JMF | 0:2563b0415d1f | 54 | *---------------------------------------------------------------------------* |
JMF | 0:2563b0415d1f | 55 | *****************************************************************************/ |
JMF | 0:2563b0415d1f | 56 | uint32_t mPhyIrqDisableCnt = 1; |
JMF | 0:2563b0415d1f | 57 | |
JMF | 0:2563b0415d1f | 58 | /***************************************************************************** |
JMF | 0:2563b0415d1f | 59 | * PUBLIC VARIABLES * |
JMF | 0:2563b0415d1f | 60 | *---------------------------------------------------------------------------* |
JMF | 0:2563b0415d1f | 61 | * Add to this section all the variables and constants that have global * |
JMF | 0:2563b0415d1f | 62 | * (project) scope. * |
JMF | 0:2563b0415d1f | 63 | * These variables / constants can be accessed outside this module. * |
JMF | 0:2563b0415d1f | 64 | * These variables / constants shall be preceded by the 'extern' keyword in * |
JMF | 0:2563b0415d1f | 65 | * the interface header. * |
JMF | 0:2563b0415d1f | 66 | *---------------------------------------------------------------------------* |
JMF | 0:2563b0415d1f | 67 | *****************************************************************************/ |
JMF | 0:2563b0415d1f | 68 | |
JMF | 0:2563b0415d1f | 69 | /***************************************************************************** |
JMF | 0:2563b0415d1f | 70 | * PRIVATE FUNCTIONS PROTOTYPES * |
JMF | 0:2563b0415d1f | 71 | *---------------------------------------------------------------------------* |
JMF | 0:2563b0415d1f | 72 | * Add to this section all the functions prototypes that have local (file) * |
JMF | 0:2563b0415d1f | 73 | * scope. * |
JMF | 0:2563b0415d1f | 74 | * These functions cannot be accessed outside this module. * |
JMF | 0:2563b0415d1f | 75 | * These declarations shall be preceded by the 'static' keyword. * |
JMF | 0:2563b0415d1f | 76 | *---------------------------------------------------------------------------* |
JMF | 0:2563b0415d1f | 77 | *****************************************************************************/ |
JMF | 0:2563b0415d1f | 78 | |
JMF | 0:2563b0415d1f | 79 | /***************************************************************************** |
JMF | 0:2563b0415d1f | 80 | * PRIVATE FUNCTIONS * |
JMF | 0:2563b0415d1f | 81 | *---------------------------------------------------------------------------* |
JMF | 0:2563b0415d1f | 82 | * Add to this section all the functions that have local (file) scope. * |
JMF | 0:2563b0415d1f | 83 | * These functions cannot be accessed outside this module. * |
JMF | 0:2563b0415d1f | 84 | * These definitions shall be preceded by the 'static' keyword. * |
JMF | 0:2563b0415d1f | 85 | *---------------------------------------------------------------------------* |
JMF | 0:2563b0415d1f | 86 | *****************************************************************************/ |
JMF | 0:2563b0415d1f | 87 | |
JMF | 0:2563b0415d1f | 88 | |
JMF | 0:2563b0415d1f | 89 | /***************************************************************************** |
JMF | 0:2563b0415d1f | 90 | * PUBLIC FUNCTIONS * |
JMF | 0:2563b0415d1f | 91 | *---------------------------------------------------------------------------* |
JMF | 0:2563b0415d1f | 92 | * Add to this section all the functions that have global (project) scope. * |
JMF | 0:2563b0415d1f | 93 | * These functions can be accessed outside this module. * |
JMF | 0:2563b0415d1f | 94 | * These functions shall have their declarations (prototypes) within the * |
JMF | 0:2563b0415d1f | 95 | * interface header file and shall be preceded by the 'extern' keyword. * |
JMF | 0:2563b0415d1f | 96 | *---------------------------------------------------------------------------* |
JMF | 0:2563b0415d1f | 97 | *****************************************************************************/ |
JMF | 0:2563b0415d1f | 98 | |
JMF | 0:2563b0415d1f | 99 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 100 | * Name: MCR20Drv_Init |
JMF | 0:2563b0415d1f | 101 | * Description: - |
JMF | 0:2563b0415d1f | 102 | * Parameters: - |
JMF | 0:2563b0415d1f | 103 | * Return: - |
JMF | 0:2563b0415d1f | 104 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 105 | void MCR20Drv_Init |
JMF | 0:2563b0415d1f | 106 | ( |
JMF | 0:2563b0415d1f | 107 | void |
JMF | 0:2563b0415d1f | 108 | ) |
JMF | 0:2563b0415d1f | 109 | { |
JMF | 0:2563b0415d1f | 110 | xcvr_spi_init(gXcvrSpiInstance_c); |
JMF | 0:2563b0415d1f | 111 | xcvr_spi_configure_speed(gXcvrSpiInstance_c, 8000000); |
JMF | 0:2563b0415d1f | 112 | |
JMF | 0:2563b0415d1f | 113 | gXcvrDeassertCS_d(); |
JMF | 0:2563b0415d1f | 114 | MCR20Drv_RST_B_Deassert(); |
JMF | 0:2563b0415d1f | 115 | RF_IRQ_Init(); |
JMF | 0:2563b0415d1f | 116 | RF_IRQ_Disable(); |
JMF | 0:2563b0415d1f | 117 | mPhyIrqDisableCnt = 1; |
JMF | 0:2563b0415d1f | 118 | } |
JMF | 0:2563b0415d1f | 119 | |
JMF | 0:2563b0415d1f | 120 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 121 | * Name: MCR20Drv_DirectAccessSPIWrite |
JMF | 0:2563b0415d1f | 122 | * Description: - |
JMF | 0:2563b0415d1f | 123 | * Parameters: - |
JMF | 0:2563b0415d1f | 124 | * Return: - |
JMF | 0:2563b0415d1f | 125 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 126 | void MCR20Drv_DirectAccessSPIWrite |
JMF | 0:2563b0415d1f | 127 | ( |
JMF | 0:2563b0415d1f | 128 | uint8_t address, |
JMF | 0:2563b0415d1f | 129 | uint8_t value |
JMF | 0:2563b0415d1f | 130 | ) |
JMF | 0:2563b0415d1f | 131 | { |
JMF | 0:2563b0415d1f | 132 | uint16_t txData; |
JMF | 0:2563b0415d1f | 133 | |
JMF | 0:2563b0415d1f | 134 | ProtectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 135 | |
JMF | 0:2563b0415d1f | 136 | xcvr_spi_configure_speed(gXcvrSpiInstance_c, 16000000); |
JMF | 0:2563b0415d1f | 137 | |
JMF | 0:2563b0415d1f | 138 | gXcvrAssertCS_d(); |
JMF | 0:2563b0415d1f | 139 | |
JMF | 0:2563b0415d1f | 140 | txData = (address & TransceiverSPI_DirectRegisterAddressMask); |
JMF | 0:2563b0415d1f | 141 | txData |= value << 8; |
JMF | 0:2563b0415d1f | 142 | |
JMF | 0:2563b0415d1f | 143 | xcvr_spi_transfer(gXcvrSpiInstance_c, (uint8_t *)&txData, 0, sizeof(txData)); |
JMF | 0:2563b0415d1f | 144 | |
JMF | 0:2563b0415d1f | 145 | gXcvrDeassertCS_d(); |
JMF | 0:2563b0415d1f | 146 | UnprotectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 147 | } |
JMF | 0:2563b0415d1f | 148 | |
JMF | 0:2563b0415d1f | 149 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 150 | * Name: MCR20Drv_DirectAccessSPIMultiByteWrite |
JMF | 0:2563b0415d1f | 151 | * Description: - |
JMF | 0:2563b0415d1f | 152 | * Parameters: - |
JMF | 0:2563b0415d1f | 153 | * Return: - |
JMF | 0:2563b0415d1f | 154 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 155 | void MCR20Drv_DirectAccessSPIMultiByteWrite |
JMF | 0:2563b0415d1f | 156 | ( |
JMF | 0:2563b0415d1f | 157 | uint8_t startAddress, |
JMF | 0:2563b0415d1f | 158 | uint8_t * byteArray, |
JMF | 0:2563b0415d1f | 159 | uint8_t numOfBytes |
JMF | 0:2563b0415d1f | 160 | ) |
JMF | 0:2563b0415d1f | 161 | { |
JMF | 0:2563b0415d1f | 162 | uint8_t txData; |
JMF | 0:2563b0415d1f | 163 | |
JMF | 0:2563b0415d1f | 164 | if( (numOfBytes == 0) || (byteArray == 0) ) |
JMF | 0:2563b0415d1f | 165 | { |
JMF | 0:2563b0415d1f | 166 | return; |
JMF | 0:2563b0415d1f | 167 | } |
JMF | 0:2563b0415d1f | 168 | |
JMF | 0:2563b0415d1f | 169 | ProtectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 170 | |
JMF | 0:2563b0415d1f | 171 | xcvr_spi_configure_speed(gXcvrSpiInstance_c, 16000000); |
JMF | 0:2563b0415d1f | 172 | |
JMF | 0:2563b0415d1f | 173 | gXcvrAssertCS_d(); |
JMF | 0:2563b0415d1f | 174 | |
JMF | 0:2563b0415d1f | 175 | txData = (startAddress & TransceiverSPI_DirectRegisterAddressMask); |
JMF | 0:2563b0415d1f | 176 | |
JMF | 0:2563b0415d1f | 177 | xcvr_spi_transfer(gXcvrSpiInstance_c, &txData, 0, sizeof(txData)); |
JMF | 0:2563b0415d1f | 178 | xcvr_spi_transfer(gXcvrSpiInstance_c, byteArray, 0, numOfBytes); |
JMF | 0:2563b0415d1f | 179 | |
JMF | 0:2563b0415d1f | 180 | gXcvrDeassertCS_d(); |
JMF | 0:2563b0415d1f | 181 | UnprotectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 182 | } |
JMF | 0:2563b0415d1f | 183 | |
JMF | 0:2563b0415d1f | 184 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 185 | * Name: MCR20Drv_PB_SPIByteWrite |
JMF | 0:2563b0415d1f | 186 | * Description: - |
JMF | 0:2563b0415d1f | 187 | * Parameters: - |
JMF | 0:2563b0415d1f | 188 | * Return: - |
JMF | 0:2563b0415d1f | 189 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 190 | void MCR20Drv_PB_SPIByteWrite |
JMF | 0:2563b0415d1f | 191 | ( |
JMF | 0:2563b0415d1f | 192 | uint8_t address, |
JMF | 0:2563b0415d1f | 193 | uint8_t value |
JMF | 0:2563b0415d1f | 194 | ) |
JMF | 0:2563b0415d1f | 195 | { |
JMF | 0:2563b0415d1f | 196 | uint32_t txData; |
JMF | 0:2563b0415d1f | 197 | |
JMF | 0:2563b0415d1f | 198 | ProtectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 199 | |
JMF | 0:2563b0415d1f | 200 | xcvr_spi_configure_speed(gXcvrSpiInstance_c, 16000000); |
JMF | 0:2563b0415d1f | 201 | |
JMF | 0:2563b0415d1f | 202 | gXcvrAssertCS_d(); |
JMF | 0:2563b0415d1f | 203 | |
JMF | 0:2563b0415d1f | 204 | txData = TransceiverSPI_WriteSelect | |
JMF | 0:2563b0415d1f | 205 | TransceiverSPI_PacketBuffAccessSelect | |
JMF | 0:2563b0415d1f | 206 | TransceiverSPI_PacketBuffByteModeSelect; |
JMF | 0:2563b0415d1f | 207 | txData |= (address) << 8; |
JMF | 0:2563b0415d1f | 208 | txData |= (value) << 16; |
JMF | 0:2563b0415d1f | 209 | |
JMF | 0:2563b0415d1f | 210 | xcvr_spi_transfer(gXcvrSpiInstance_c, (uint8_t*)&txData, 0, 3); |
JMF | 0:2563b0415d1f | 211 | |
JMF | 0:2563b0415d1f | 212 | gXcvrDeassertCS_d(); |
JMF | 0:2563b0415d1f | 213 | UnprotectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 214 | } |
JMF | 0:2563b0415d1f | 215 | |
JMF | 0:2563b0415d1f | 216 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 217 | * Name: MCR20Drv_PB_SPIBurstWrite |
JMF | 0:2563b0415d1f | 218 | * Description: - |
JMF | 0:2563b0415d1f | 219 | * Parameters: - |
JMF | 0:2563b0415d1f | 220 | * Return: - |
JMF | 0:2563b0415d1f | 221 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 222 | void MCR20Drv_PB_SPIBurstWrite |
JMF | 0:2563b0415d1f | 223 | ( |
JMF | 0:2563b0415d1f | 224 | uint8_t * byteArray, |
JMF | 0:2563b0415d1f | 225 | uint8_t numOfBytes |
JMF | 0:2563b0415d1f | 226 | ) |
JMF | 0:2563b0415d1f | 227 | { |
JMF | 0:2563b0415d1f | 228 | uint8_t txData; |
JMF | 0:2563b0415d1f | 229 | |
JMF | 0:2563b0415d1f | 230 | if( (numOfBytes == 0) || (byteArray == 0) ) |
JMF | 0:2563b0415d1f | 231 | { |
JMF | 0:2563b0415d1f | 232 | return; |
JMF | 0:2563b0415d1f | 233 | } |
JMF | 0:2563b0415d1f | 234 | |
JMF | 0:2563b0415d1f | 235 | ProtectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 236 | |
JMF | 0:2563b0415d1f | 237 | xcvr_spi_configure_speed(gXcvrSpiInstance_c, 16000000); |
JMF | 0:2563b0415d1f | 238 | |
JMF | 0:2563b0415d1f | 239 | gXcvrAssertCS_d(); |
JMF | 0:2563b0415d1f | 240 | |
JMF | 0:2563b0415d1f | 241 | txData = TransceiverSPI_WriteSelect | |
JMF | 0:2563b0415d1f | 242 | TransceiverSPI_PacketBuffAccessSelect | |
JMF | 0:2563b0415d1f | 243 | TransceiverSPI_PacketBuffBurstModeSelect; |
JMF | 0:2563b0415d1f | 244 | |
JMF | 0:2563b0415d1f | 245 | xcvr_spi_transfer(gXcvrSpiInstance_c, &txData, 0, 1); |
JMF | 0:2563b0415d1f | 246 | xcvr_spi_transfer(gXcvrSpiInstance_c, byteArray, 0, numOfBytes); |
JMF | 0:2563b0415d1f | 247 | |
JMF | 0:2563b0415d1f | 248 | gXcvrDeassertCS_d(); |
JMF | 0:2563b0415d1f | 249 | UnprotectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 250 | } |
JMF | 0:2563b0415d1f | 251 | |
JMF | 0:2563b0415d1f | 252 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 253 | * Name: MCR20Drv_DirectAccessSPIRead |
JMF | 0:2563b0415d1f | 254 | * Description: - |
JMF | 0:2563b0415d1f | 255 | * Parameters: - |
JMF | 0:2563b0415d1f | 256 | * Return: - |
JMF | 0:2563b0415d1f | 257 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 258 | |
JMF | 0:2563b0415d1f | 259 | uint8_t MCR20Drv_DirectAccessSPIRead |
JMF | 0:2563b0415d1f | 260 | ( |
JMF | 0:2563b0415d1f | 261 | uint8_t address |
JMF | 0:2563b0415d1f | 262 | ) |
JMF | 0:2563b0415d1f | 263 | { |
JMF | 0:2563b0415d1f | 264 | uint8_t txData; |
JMF | 0:2563b0415d1f | 265 | uint8_t rxData; |
JMF | 0:2563b0415d1f | 266 | |
JMF | 0:2563b0415d1f | 267 | ProtectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 268 | |
JMF | 0:2563b0415d1f | 269 | xcvr_spi_configure_speed(gXcvrSpiInstance_c, 8000000); |
JMF | 0:2563b0415d1f | 270 | |
JMF | 0:2563b0415d1f | 271 | gXcvrAssertCS_d(); |
JMF | 0:2563b0415d1f | 272 | |
JMF | 0:2563b0415d1f | 273 | txData = (address & TransceiverSPI_DirectRegisterAddressMask) | |
JMF | 0:2563b0415d1f | 274 | TransceiverSPI_ReadSelect; |
JMF | 0:2563b0415d1f | 275 | |
JMF | 0:2563b0415d1f | 276 | xcvr_spi_transfer(gXcvrSpiInstance_c, &txData, 0, sizeof(txData)); |
JMF | 0:2563b0415d1f | 277 | xcvr_spi_transfer(gXcvrSpiInstance_c, 0, &rxData, sizeof(rxData)); |
JMF | 0:2563b0415d1f | 278 | |
JMF | 0:2563b0415d1f | 279 | gXcvrDeassertCS_d(); |
JMF | 0:2563b0415d1f | 280 | UnprotectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 281 | |
JMF | 0:2563b0415d1f | 282 | return rxData; |
JMF | 0:2563b0415d1f | 283 | |
JMF | 0:2563b0415d1f | 284 | } |
JMF | 0:2563b0415d1f | 285 | |
JMF | 0:2563b0415d1f | 286 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 287 | * Name: MCR20Drv_DirectAccessSPIMultyByteRead |
JMF | 0:2563b0415d1f | 288 | * Description: - |
JMF | 0:2563b0415d1f | 289 | * Parameters: - |
JMF | 0:2563b0415d1f | 290 | * Return: - |
JMF | 0:2563b0415d1f | 291 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 292 | uint8_t MCR20Drv_DirectAccessSPIMultiByteRead |
JMF | 0:2563b0415d1f | 293 | ( |
JMF | 0:2563b0415d1f | 294 | uint8_t startAddress, |
JMF | 0:2563b0415d1f | 295 | uint8_t * byteArray, |
JMF | 0:2563b0415d1f | 296 | uint8_t numOfBytes |
JMF | 0:2563b0415d1f | 297 | ) |
JMF | 0:2563b0415d1f | 298 | { |
JMF | 0:2563b0415d1f | 299 | uint8_t txData; |
JMF | 0:2563b0415d1f | 300 | uint8_t phyIRQSTS1; |
JMF | 0:2563b0415d1f | 301 | |
JMF | 0:2563b0415d1f | 302 | if( (numOfBytes == 0) || (byteArray == 0) ) |
JMF | 0:2563b0415d1f | 303 | { |
JMF | 0:2563b0415d1f | 304 | return 0; |
JMF | 0:2563b0415d1f | 305 | } |
JMF | 0:2563b0415d1f | 306 | |
JMF | 0:2563b0415d1f | 307 | ProtectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 308 | |
JMF | 0:2563b0415d1f | 309 | xcvr_spi_configure_speed(gXcvrSpiInstance_c, 8000000); |
JMF | 0:2563b0415d1f | 310 | |
JMF | 0:2563b0415d1f | 311 | gXcvrAssertCS_d(); |
JMF | 0:2563b0415d1f | 312 | |
JMF | 0:2563b0415d1f | 313 | txData = (startAddress & TransceiverSPI_DirectRegisterAddressMask) | |
JMF | 0:2563b0415d1f | 314 | TransceiverSPI_ReadSelect; |
JMF | 0:2563b0415d1f | 315 | |
JMF | 0:2563b0415d1f | 316 | xcvr_spi_transfer(gXcvrSpiInstance_c, &txData, &phyIRQSTS1, sizeof(txData)); |
JMF | 0:2563b0415d1f | 317 | xcvr_spi_transfer(gXcvrSpiInstance_c, 0, byteArray, numOfBytes); |
JMF | 0:2563b0415d1f | 318 | |
JMF | 0:2563b0415d1f | 319 | gXcvrDeassertCS_d(); |
JMF | 0:2563b0415d1f | 320 | UnprotectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 321 | |
JMF | 0:2563b0415d1f | 322 | return phyIRQSTS1; |
JMF | 0:2563b0415d1f | 323 | } |
JMF | 0:2563b0415d1f | 324 | |
JMF | 0:2563b0415d1f | 325 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 326 | * Name: MCR20Drv_PB_SPIBurstRead |
JMF | 0:2563b0415d1f | 327 | * Description: - |
JMF | 0:2563b0415d1f | 328 | * Parameters: - |
JMF | 0:2563b0415d1f | 329 | * Return: - |
JMF | 0:2563b0415d1f | 330 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 331 | uint8_t MCR20Drv_PB_SPIBurstRead |
JMF | 0:2563b0415d1f | 332 | ( |
JMF | 0:2563b0415d1f | 333 | uint8_t * byteArray, |
JMF | 0:2563b0415d1f | 334 | uint8_t numOfBytes |
JMF | 0:2563b0415d1f | 335 | ) |
JMF | 0:2563b0415d1f | 336 | { |
JMF | 0:2563b0415d1f | 337 | uint8_t txData; |
JMF | 0:2563b0415d1f | 338 | uint8_t phyIRQSTS1; |
JMF | 0:2563b0415d1f | 339 | |
JMF | 0:2563b0415d1f | 340 | if( (numOfBytes == 0) || (byteArray == 0) ) |
JMF | 0:2563b0415d1f | 341 | { |
JMF | 0:2563b0415d1f | 342 | return 0; |
JMF | 0:2563b0415d1f | 343 | } |
JMF | 0:2563b0415d1f | 344 | |
JMF | 0:2563b0415d1f | 345 | ProtectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 346 | |
JMF | 0:2563b0415d1f | 347 | xcvr_spi_configure_speed(gXcvrSpiInstance_c, 8000000); |
JMF | 0:2563b0415d1f | 348 | |
JMF | 0:2563b0415d1f | 349 | gXcvrAssertCS_d(); |
JMF | 0:2563b0415d1f | 350 | |
JMF | 0:2563b0415d1f | 351 | txData = TransceiverSPI_ReadSelect | |
JMF | 0:2563b0415d1f | 352 | TransceiverSPI_PacketBuffAccessSelect | |
JMF | 0:2563b0415d1f | 353 | TransceiverSPI_PacketBuffBurstModeSelect; |
JMF | 0:2563b0415d1f | 354 | |
JMF | 0:2563b0415d1f | 355 | xcvr_spi_transfer(gXcvrSpiInstance_c, &txData, &phyIRQSTS1, sizeof(txData)); |
JMF | 0:2563b0415d1f | 356 | xcvr_spi_transfer(gXcvrSpiInstance_c, 0, byteArray, numOfBytes); |
JMF | 0:2563b0415d1f | 357 | |
JMF | 0:2563b0415d1f | 358 | gXcvrDeassertCS_d(); |
JMF | 0:2563b0415d1f | 359 | UnprotectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 360 | |
JMF | 0:2563b0415d1f | 361 | return phyIRQSTS1; |
JMF | 0:2563b0415d1f | 362 | } |
JMF | 0:2563b0415d1f | 363 | |
JMF | 0:2563b0415d1f | 364 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 365 | * Name: MCR20Drv_IndirectAccessSPIWrite |
JMF | 0:2563b0415d1f | 366 | * Description: - |
JMF | 0:2563b0415d1f | 367 | * Parameters: - |
JMF | 0:2563b0415d1f | 368 | * Return: - |
JMF | 0:2563b0415d1f | 369 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 370 | void MCR20Drv_IndirectAccessSPIWrite |
JMF | 0:2563b0415d1f | 371 | ( |
JMF | 0:2563b0415d1f | 372 | uint8_t address, |
JMF | 0:2563b0415d1f | 373 | uint8_t value |
JMF | 0:2563b0415d1f | 374 | ) |
JMF | 0:2563b0415d1f | 375 | { |
JMF | 0:2563b0415d1f | 376 | uint32_t txData; |
JMF | 0:2563b0415d1f | 377 | |
JMF | 0:2563b0415d1f | 378 | ProtectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 379 | |
JMF | 0:2563b0415d1f | 380 | xcvr_spi_configure_speed(gXcvrSpiInstance_c, 16000000); |
JMF | 0:2563b0415d1f | 381 | |
JMF | 0:2563b0415d1f | 382 | gXcvrAssertCS_d(); |
JMF | 0:2563b0415d1f | 383 | |
JMF | 0:2563b0415d1f | 384 | txData = TransceiverSPI_IARIndexReg; |
JMF | 0:2563b0415d1f | 385 | txData |= (address) << 8; |
JMF | 0:2563b0415d1f | 386 | txData |= (value) << 16; |
JMF | 0:2563b0415d1f | 387 | |
JMF | 0:2563b0415d1f | 388 | xcvr_spi_transfer(gXcvrSpiInstance_c, (uint8_t*)&txData, 0, 3); |
JMF | 0:2563b0415d1f | 389 | |
JMF | 0:2563b0415d1f | 390 | gXcvrDeassertCS_d(); |
JMF | 0:2563b0415d1f | 391 | UnprotectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 392 | } |
JMF | 0:2563b0415d1f | 393 | |
JMF | 0:2563b0415d1f | 394 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 395 | * Name: MCR20Drv_IndirectAccessSPIMultiByteWrite |
JMF | 0:2563b0415d1f | 396 | * Description: - |
JMF | 0:2563b0415d1f | 397 | * Parameters: - |
JMF | 0:2563b0415d1f | 398 | * Return: - |
JMF | 0:2563b0415d1f | 399 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 400 | void MCR20Drv_IndirectAccessSPIMultiByteWrite |
JMF | 0:2563b0415d1f | 401 | ( |
JMF | 0:2563b0415d1f | 402 | uint8_t startAddress, |
JMF | 0:2563b0415d1f | 403 | uint8_t * byteArray, |
JMF | 0:2563b0415d1f | 404 | uint8_t numOfBytes |
JMF | 0:2563b0415d1f | 405 | ) |
JMF | 0:2563b0415d1f | 406 | { |
JMF | 0:2563b0415d1f | 407 | uint16_t txData; |
JMF | 0:2563b0415d1f | 408 | |
JMF | 0:2563b0415d1f | 409 | if( (numOfBytes == 0) || (byteArray == 0) ) |
JMF | 0:2563b0415d1f | 410 | { |
JMF | 0:2563b0415d1f | 411 | return; |
JMF | 0:2563b0415d1f | 412 | } |
JMF | 0:2563b0415d1f | 413 | |
JMF | 0:2563b0415d1f | 414 | ProtectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 415 | |
JMF | 0:2563b0415d1f | 416 | xcvr_spi_configure_speed(gXcvrSpiInstance_c, 16000000); |
JMF | 0:2563b0415d1f | 417 | |
JMF | 0:2563b0415d1f | 418 | gXcvrAssertCS_d(); |
JMF | 0:2563b0415d1f | 419 | |
JMF | 0:2563b0415d1f | 420 | txData = TransceiverSPI_IARIndexReg; |
JMF | 0:2563b0415d1f | 421 | txData |= (startAddress) << 8; |
JMF | 0:2563b0415d1f | 422 | |
JMF | 0:2563b0415d1f | 423 | xcvr_spi_transfer(gXcvrSpiInstance_c, (uint8_t*)&txData, 0, sizeof(txData)); |
JMF | 0:2563b0415d1f | 424 | xcvr_spi_transfer(gXcvrSpiInstance_c, (uint8_t*)byteArray, 0, numOfBytes); |
JMF | 0:2563b0415d1f | 425 | |
JMF | 0:2563b0415d1f | 426 | gXcvrDeassertCS_d(); |
JMF | 0:2563b0415d1f | 427 | UnprotectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 428 | } |
JMF | 0:2563b0415d1f | 429 | |
JMF | 0:2563b0415d1f | 430 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 431 | * Name: MCR20Drv_IndirectAccessSPIRead |
JMF | 0:2563b0415d1f | 432 | * Description: - |
JMF | 0:2563b0415d1f | 433 | * Parameters: - |
JMF | 0:2563b0415d1f | 434 | * Return: - |
JMF | 0:2563b0415d1f | 435 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 436 | uint8_t MCR20Drv_IndirectAccessSPIRead |
JMF | 0:2563b0415d1f | 437 | ( |
JMF | 0:2563b0415d1f | 438 | uint8_t address |
JMF | 0:2563b0415d1f | 439 | ) |
JMF | 0:2563b0415d1f | 440 | { |
JMF | 0:2563b0415d1f | 441 | uint16_t txData; |
JMF | 0:2563b0415d1f | 442 | uint8_t rxData; |
JMF | 0:2563b0415d1f | 443 | |
JMF | 0:2563b0415d1f | 444 | ProtectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 445 | |
JMF | 0:2563b0415d1f | 446 | xcvr_spi_configure_speed(gXcvrSpiInstance_c, 8000000); |
JMF | 0:2563b0415d1f | 447 | |
JMF | 0:2563b0415d1f | 448 | gXcvrAssertCS_d(); |
JMF | 0:2563b0415d1f | 449 | |
JMF | 0:2563b0415d1f | 450 | txData = TransceiverSPI_IARIndexReg | TransceiverSPI_ReadSelect; |
JMF | 0:2563b0415d1f | 451 | txData |= (address) << 8; |
JMF | 0:2563b0415d1f | 452 | |
JMF | 0:2563b0415d1f | 453 | xcvr_spi_transfer(gXcvrSpiInstance_c, (uint8_t*)&txData, 0, sizeof(txData)); |
JMF | 0:2563b0415d1f | 454 | xcvr_spi_transfer(gXcvrSpiInstance_c, 0, &rxData, sizeof(rxData)); |
JMF | 0:2563b0415d1f | 455 | |
JMF | 0:2563b0415d1f | 456 | gXcvrDeassertCS_d(); |
JMF | 0:2563b0415d1f | 457 | UnprotectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 458 | |
JMF | 0:2563b0415d1f | 459 | return rxData; |
JMF | 0:2563b0415d1f | 460 | } |
JMF | 0:2563b0415d1f | 461 | |
JMF | 0:2563b0415d1f | 462 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 463 | * Name: MCR20Drv_IndirectAccessSPIMultiByteRead |
JMF | 0:2563b0415d1f | 464 | * Description: - |
JMF | 0:2563b0415d1f | 465 | * Parameters: - |
JMF | 0:2563b0415d1f | 466 | * Return: - |
JMF | 0:2563b0415d1f | 467 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 468 | void MCR20Drv_IndirectAccessSPIMultiByteRead |
JMF | 0:2563b0415d1f | 469 | ( |
JMF | 0:2563b0415d1f | 470 | uint8_t startAddress, |
JMF | 0:2563b0415d1f | 471 | uint8_t * byteArray, |
JMF | 0:2563b0415d1f | 472 | uint8_t numOfBytes |
JMF | 0:2563b0415d1f | 473 | ) |
JMF | 0:2563b0415d1f | 474 | { |
JMF | 0:2563b0415d1f | 475 | uint16_t txData; |
JMF | 0:2563b0415d1f | 476 | |
JMF | 0:2563b0415d1f | 477 | if( (numOfBytes == 0) || (byteArray == 0) ) |
JMF | 0:2563b0415d1f | 478 | { |
JMF | 0:2563b0415d1f | 479 | return; |
JMF | 0:2563b0415d1f | 480 | } |
JMF | 0:2563b0415d1f | 481 | |
JMF | 0:2563b0415d1f | 482 | ProtectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 483 | |
JMF | 0:2563b0415d1f | 484 | xcvr_spi_configure_speed(gXcvrSpiInstance_c, 8000000); |
JMF | 0:2563b0415d1f | 485 | |
JMF | 0:2563b0415d1f | 486 | gXcvrAssertCS_d(); |
JMF | 0:2563b0415d1f | 487 | |
JMF | 0:2563b0415d1f | 488 | txData = (TransceiverSPI_IARIndexReg | TransceiverSPI_ReadSelect); |
JMF | 0:2563b0415d1f | 489 | txData |= (startAddress) << 8; |
JMF | 0:2563b0415d1f | 490 | |
JMF | 0:2563b0415d1f | 491 | xcvr_spi_transfer(gXcvrSpiInstance_c, (uint8_t*)&txData, 0, sizeof(txData)); |
JMF | 0:2563b0415d1f | 492 | xcvr_spi_transfer(gXcvrSpiInstance_c, 0, byteArray, numOfBytes); |
JMF | 0:2563b0415d1f | 493 | |
JMF | 0:2563b0415d1f | 494 | gXcvrDeassertCS_d(); |
JMF | 0:2563b0415d1f | 495 | UnprotectFromMCR20Interrupt(); |
JMF | 0:2563b0415d1f | 496 | } |
JMF | 0:2563b0415d1f | 497 | |
JMF | 0:2563b0415d1f | 498 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 499 | * Name: MCR20Drv_IsIrqPending |
JMF | 0:2563b0415d1f | 500 | * Description: - |
JMF | 0:2563b0415d1f | 501 | * Parameters: - |
JMF | 0:2563b0415d1f | 502 | * Return: - |
JMF | 0:2563b0415d1f | 503 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 504 | uint32_t MCR20Drv_IsIrqPending |
JMF | 0:2563b0415d1f | 505 | ( |
JMF | 0:2563b0415d1f | 506 | void |
JMF | 0:2563b0415d1f | 507 | ) |
JMF | 0:2563b0415d1f | 508 | { |
JMF | 0:2563b0415d1f | 509 | return RF_isIRQ_Pending(); |
JMF | 0:2563b0415d1f | 510 | } |
JMF | 0:2563b0415d1f | 511 | |
JMF | 0:2563b0415d1f | 512 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 513 | * Name: MCR20Drv_IRQ_Disable |
JMF | 0:2563b0415d1f | 514 | * Description: - |
JMF | 0:2563b0415d1f | 515 | * Parameters: - |
JMF | 0:2563b0415d1f | 516 | * Return: - |
JMF | 0:2563b0415d1f | 517 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 518 | void MCR20Drv_IRQ_Disable |
JMF | 0:2563b0415d1f | 519 | ( |
JMF | 0:2563b0415d1f | 520 | void |
JMF | 0:2563b0415d1f | 521 | ) |
JMF | 0:2563b0415d1f | 522 | { |
JMF | 0:2563b0415d1f | 523 | platform_enter_critical(); |
JMF | 0:2563b0415d1f | 524 | |
JMF | 0:2563b0415d1f | 525 | if( mPhyIrqDisableCnt == 0 ) |
JMF | 0:2563b0415d1f | 526 | { |
JMF | 0:2563b0415d1f | 527 | RF_IRQ_Disable(); |
JMF | 0:2563b0415d1f | 528 | } |
JMF | 0:2563b0415d1f | 529 | |
JMF | 0:2563b0415d1f | 530 | mPhyIrqDisableCnt++; |
JMF | 0:2563b0415d1f | 531 | |
JMF | 0:2563b0415d1f | 532 | platform_exit_critical(); |
JMF | 0:2563b0415d1f | 533 | } |
JMF | 0:2563b0415d1f | 534 | |
JMF | 0:2563b0415d1f | 535 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 536 | * Name: MCR20Drv_IRQ_Enable |
JMF | 0:2563b0415d1f | 537 | * Description: - |
JMF | 0:2563b0415d1f | 538 | * Parameters: - |
JMF | 0:2563b0415d1f | 539 | * Return: - |
JMF | 0:2563b0415d1f | 540 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 541 | void MCR20Drv_IRQ_Enable |
JMF | 0:2563b0415d1f | 542 | ( |
JMF | 0:2563b0415d1f | 543 | void |
JMF | 0:2563b0415d1f | 544 | ) |
JMF | 0:2563b0415d1f | 545 | { |
JMF | 0:2563b0415d1f | 546 | platform_enter_critical(); |
JMF | 0:2563b0415d1f | 547 | |
JMF | 0:2563b0415d1f | 548 | if( mPhyIrqDisableCnt ) |
JMF | 0:2563b0415d1f | 549 | { |
JMF | 0:2563b0415d1f | 550 | mPhyIrqDisableCnt--; |
JMF | 0:2563b0415d1f | 551 | |
JMF | 0:2563b0415d1f | 552 | if( mPhyIrqDisableCnt == 0 ) |
JMF | 0:2563b0415d1f | 553 | { |
JMF | 0:2563b0415d1f | 554 | RF_IRQ_Enable(); |
JMF | 0:2563b0415d1f | 555 | } |
JMF | 0:2563b0415d1f | 556 | } |
JMF | 0:2563b0415d1f | 557 | |
JMF | 0:2563b0415d1f | 558 | platform_exit_critical(); |
JMF | 0:2563b0415d1f | 559 | } |
JMF | 0:2563b0415d1f | 560 | |
JMF | 0:2563b0415d1f | 561 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 562 | * Name: MCR20Drv_RST_Assert |
JMF | 0:2563b0415d1f | 563 | * Description: - |
JMF | 0:2563b0415d1f | 564 | * Parameters: - |
JMF | 0:2563b0415d1f | 565 | * Return: - |
JMF | 0:2563b0415d1f | 566 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 567 | void MCR20Drv_RST_B_Assert |
JMF | 0:2563b0415d1f | 568 | ( |
JMF | 0:2563b0415d1f | 569 | void |
JMF | 0:2563b0415d1f | 570 | ) |
JMF | 0:2563b0415d1f | 571 | { |
JMF | 0:2563b0415d1f | 572 | RF_RST_Set(0); |
JMF | 0:2563b0415d1f | 573 | } |
JMF | 0:2563b0415d1f | 574 | |
JMF | 0:2563b0415d1f | 575 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 576 | * Name: MCR20Drv_RST_Deassert |
JMF | 0:2563b0415d1f | 577 | * Description: - |
JMF | 0:2563b0415d1f | 578 | * Parameters: - |
JMF | 0:2563b0415d1f | 579 | * Return: - |
JMF | 0:2563b0415d1f | 580 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 581 | void MCR20Drv_RST_B_Deassert |
JMF | 0:2563b0415d1f | 582 | ( |
JMF | 0:2563b0415d1f | 583 | void |
JMF | 0:2563b0415d1f | 584 | ) |
JMF | 0:2563b0415d1f | 585 | { |
JMF | 0:2563b0415d1f | 586 | RF_RST_Set(1); |
JMF | 0:2563b0415d1f | 587 | } |
JMF | 0:2563b0415d1f | 588 | |
JMF | 0:2563b0415d1f | 589 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 590 | * Name: MCR20Drv_SoftRST_Assert |
JMF | 0:2563b0415d1f | 591 | * Description: - |
JMF | 0:2563b0415d1f | 592 | * Parameters: - |
JMF | 0:2563b0415d1f | 593 | * Return: - |
JMF | 0:2563b0415d1f | 594 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 595 | void MCR20Drv_SoftRST_Assert |
JMF | 0:2563b0415d1f | 596 | ( |
JMF | 0:2563b0415d1f | 597 | void |
JMF | 0:2563b0415d1f | 598 | ) |
JMF | 0:2563b0415d1f | 599 | { |
JMF | 0:2563b0415d1f | 600 | MCR20Drv_IndirectAccessSPIWrite(SOFT_RESET, (0x80)); |
JMF | 0:2563b0415d1f | 601 | } |
JMF | 0:2563b0415d1f | 602 | |
JMF | 0:2563b0415d1f | 603 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 604 | * Name: MCR20Drv_SoftRST_Deassert |
JMF | 0:2563b0415d1f | 605 | * Description: - |
JMF | 0:2563b0415d1f | 606 | * Parameters: - |
JMF | 0:2563b0415d1f | 607 | * Return: - |
JMF | 0:2563b0415d1f | 608 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 609 | void MCR20Drv_SoftRST_Deassert |
JMF | 0:2563b0415d1f | 610 | ( |
JMF | 0:2563b0415d1f | 611 | void |
JMF | 0:2563b0415d1f | 612 | ) |
JMF | 0:2563b0415d1f | 613 | { |
JMF | 0:2563b0415d1f | 614 | MCR20Drv_IndirectAccessSPIWrite(SOFT_RESET, (0x00)); |
JMF | 0:2563b0415d1f | 615 | } |
JMF | 0:2563b0415d1f | 616 | |
JMF | 0:2563b0415d1f | 617 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 618 | * Name: MCR20Drv_Soft_RESET |
JMF | 0:2563b0415d1f | 619 | * Description: - |
JMF | 0:2563b0415d1f | 620 | * Parameters: - |
JMF | 0:2563b0415d1f | 621 | * Return: - |
JMF | 0:2563b0415d1f | 622 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 623 | void MCR20Drv_Soft_RESET |
JMF | 0:2563b0415d1f | 624 | ( |
JMF | 0:2563b0415d1f | 625 | void |
JMF | 0:2563b0415d1f | 626 | ) |
JMF | 0:2563b0415d1f | 627 | { |
JMF | 0:2563b0415d1f | 628 | //assert SOG_RST |
JMF | 0:2563b0415d1f | 629 | MCR20Drv_IndirectAccessSPIWrite(SOFT_RESET, (0x80)); |
JMF | 0:2563b0415d1f | 630 | |
JMF | 0:2563b0415d1f | 631 | //deassert SOG_RST |
JMF | 0:2563b0415d1f | 632 | MCR20Drv_IndirectAccessSPIWrite(SOFT_RESET, (0x00)); |
JMF | 0:2563b0415d1f | 633 | } |
JMF | 0:2563b0415d1f | 634 | |
JMF | 0:2563b0415d1f | 635 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 636 | * Name: MCR20Drv_RESET |
JMF | 0:2563b0415d1f | 637 | * Description: - |
JMF | 0:2563b0415d1f | 638 | * Parameters: - |
JMF | 0:2563b0415d1f | 639 | * Return: - |
JMF | 0:2563b0415d1f | 640 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 641 | void MCR20Drv_RESET |
JMF | 0:2563b0415d1f | 642 | ( |
JMF | 0:2563b0415d1f | 643 | void |
JMF | 0:2563b0415d1f | 644 | ) |
JMF | 0:2563b0415d1f | 645 | { |
JMF | 0:2563b0415d1f | 646 | volatile uint32_t delay = 1000; |
JMF | 0:2563b0415d1f | 647 | //assert RST_B |
JMF | 0:2563b0415d1f | 648 | MCR20Drv_RST_B_Assert(); |
JMF | 0:2563b0415d1f | 649 | |
JMF | 0:2563b0415d1f | 650 | while(delay--); |
JMF | 0:2563b0415d1f | 651 | |
JMF | 0:2563b0415d1f | 652 | //deassert RST_B |
JMF | 0:2563b0415d1f | 653 | MCR20Drv_RST_B_Deassert(); |
JMF | 0:2563b0415d1f | 654 | } |
JMF | 0:2563b0415d1f | 655 | |
JMF | 0:2563b0415d1f | 656 | /*--------------------------------------------------------------------------- |
JMF | 0:2563b0415d1f | 657 | * Name: MCR20Drv_Set_CLK_OUT_Freq |
JMF | 0:2563b0415d1f | 658 | * Description: - |
JMF | 0:2563b0415d1f | 659 | * Parameters: - |
JMF | 0:2563b0415d1f | 660 | * Return: - |
JMF | 0:2563b0415d1f | 661 | *---------------------------------------------------------------------------*/ |
JMF | 0:2563b0415d1f | 662 | void MCR20Drv_Set_CLK_OUT_Freq |
JMF | 0:2563b0415d1f | 663 | ( |
JMF | 0:2563b0415d1f | 664 | uint8_t freqDiv |
JMF | 0:2563b0415d1f | 665 | ) |
JMF | 0:2563b0415d1f | 666 | { |
JMF | 0:2563b0415d1f | 667 | uint8_t clkOutCtrlReg = (freqDiv & cCLK_OUT_DIV_Mask) | cCLK_OUT_EN | cCLK_OUT_EXTEND; |
JMF | 0:2563b0415d1f | 668 | |
JMF | 0:2563b0415d1f | 669 | if(freqDiv == gCLK_OUT_FREQ_DISABLE) |
JMF | 0:2563b0415d1f | 670 | { |
JMF | 0:2563b0415d1f | 671 | clkOutCtrlReg = (cCLK_OUT_EXTEND | gCLK_OUT_FREQ_4_MHz); //reset value with clock out disabled |
JMF | 0:2563b0415d1f | 672 | } |
JMF | 0:2563b0415d1f | 673 | |
JMF | 0:2563b0415d1f | 674 | MCR20Drv_DirectAccessSPIWrite((uint8_t) CLK_OUT_CTRL, clkOutCtrlReg); |
JMF | 0:2563b0415d1f | 675 | } |