my customized lib

Committer:
DuyLionTran
Date:
Sun Nov 26 15:08:14 2017 +0000
Revision:
0:8094b249013c
Initial commit

Who changed what in which revision?

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