NXP / fsl_phy_mcr20a

Fork of fsl_phy_mcr20a by Freescale

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MCR20Drv.c Source File

MCR20Drv.c

Go to the documentation of this file.
00001 /*!
00002 * Copyright (c) 2015, Freescale Semiconductor, Inc.
00003 * All rights reserved.
00004 *
00005 * \file MCR20Drv.c
00006 *
00007 * Redistribution and use in source and binary forms, with or without modification,
00008 * are permitted provided that the following conditions are met:
00009 *
00010 * o Redistributions of source code must retain the above copyright notice, this list
00011 *   of conditions and the following disclaimer.
00012 *
00013 * o Redistributions in binary form must reproduce the above copyright notice, this
00014 *   list of conditions and the following disclaimer in the documentation and/or
00015 *   other materials provided with the distribution.
00016 *
00017 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
00018 *   contributors may be used to endorse or promote products derived from this
00019 *   software without specific prior written permission.
00020 *
00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00022 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00023 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00024 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00025 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00026 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00028 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00029 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031 */
00032 
00033 
00034 /*****************************************************************************
00035 *                               INCLUDED HEADERS                            *
00036 *---------------------------------------------------------------------------*
00037 * Add to this section all the headers that this module needs to include.    *
00038 *---------------------------------------------------------------------------*
00039 *****************************************************************************/
00040 
00041 #include "MCR20Drv.h "
00042 #include "MCR20Reg.h"
00043 
00044 #include "XcvrSpi.h "
00045 
00046 /*****************************************************************************
00047 *                               PRIVATE VARIABLES                           *
00048 *---------------------------------------------------------------------------*
00049 * Add to this section all the variables and constants that have local       *
00050 * (file) scope.                                                             *
00051 * Each of this declarations shall be preceded by the 'static' keyword.      *
00052 * These variables / constants cannot be accessed outside this module.       *
00053 *---------------------------------------------------------------------------*
00054 *****************************************************************************/
00055 static uint32_t mPhyIrqDisableCnt = 1;
00056 
00057 /*****************************************************************************
00058 *                               PUBLIC VARIABLES                            *
00059 *---------------------------------------------------------------------------*
00060 * Add to this section all the variables and constants that have global      *
00061 * (project) scope.                                                          *
00062 * These variables / constants can be accessed outside this module.          *
00063 * These variables / constants shall be preceded by the 'extern' keyword in  *
00064 * the interface header.                                                     *
00065 *---------------------------------------------------------------------------*
00066 *****************************************************************************/
00067 
00068 /*****************************************************************************
00069 *                           PRIVATE FUNCTIONS PROTOTYPES                    *
00070 *---------------------------------------------------------------------------*
00071 * Add to this section all the functions prototypes that have local (file)   *
00072 * scope.                                                                    *
00073 * These functions cannot be accessed outside this module.                   *
00074 * These declarations shall be preceded by the 'static' keyword.             *
00075 *---------------------------------------------------------------------------*
00076 *****************************************************************************/
00077 
00078 /*****************************************************************************
00079 *                                PRIVATE FUNCTIONS                          *
00080 *---------------------------------------------------------------------------*
00081 * Add to this section all the functions that have local (file) scope.       *
00082 * These functions cannot be accessed outside this module.                   *
00083 * These definitions shall be preceded by the 'static' keyword.              *
00084 *---------------------------------------------------------------------------*
00085 *****************************************************************************/
00086 
00087 
00088 /*****************************************************************************
00089 *                             PUBLIC FUNCTIONS                              *
00090 *---------------------------------------------------------------------------*
00091 * Add to this section all the functions that have global (project) scope.   *
00092 * These functions can be accessed outside this module.                      *
00093 * These functions shall have their declarations (prototypes) within the     *
00094 * interface header file and shall be preceded by the 'extern' keyword.      *
00095 *---------------------------------------------------------------------------*
00096 *****************************************************************************/
00097 
00098 /*---------------------------------------------------------------------------
00099 * Name: MCR20Drv_Init
00100 * Description: -
00101 * Parameters: -
00102 * Return: -
00103 *---------------------------------------------------------------------------*/
00104 void MCR20Drv_Init
00105 (
00106 void
00107 )
00108 {
00109     spi_master_init(gXcvrSpiInstance_c);
00110     spi_master_configure_speed(gXcvrSpiInstance_c, 8000000);
00111 
00112     gXcvrDeassertCS_d();
00113     MCR20Drv_RST_B_Deassert();
00114     //MCR20Drv_RESET();
00115 }
00116 
00117 /*---------------------------------------------------------------------------
00118 * Name: MCR20Drv_DirectAccessSPIWrite
00119 * Description: -
00120 * Parameters: -
00121 * Return: -
00122 *---------------------------------------------------------------------------*/
00123 void MCR20Drv_DirectAccessSPIWrite
00124 (
00125 uint8_t address,
00126 uint8_t value
00127 )
00128 {
00129     uint16_t txData;
00130 
00131     ProtectFromMCR20Interrupt();
00132 
00133     spi_master_configure_speed(gXcvrSpiInstance_c, 16000000);
00134 
00135     gXcvrAssertCS_d();
00136 
00137     txData = (address & TransceiverSPI_DirectRegisterAddressMask);
00138     txData |= value << 8;
00139 
00140     spi_master_transfer(gXcvrSpiInstance_c, (uint8_t *)&txData, NULL, sizeof(txData));
00141 
00142     gXcvrDeassertCS_d();
00143     UnprotectFromMCR20Interrupt();
00144 }
00145 
00146 /*---------------------------------------------------------------------------
00147 * Name: MCR20Drv_DirectAccessSPIMultiByteWrite
00148 * Description: -
00149 * Parameters: -
00150 * Return: -
00151 *---------------------------------------------------------------------------*/
00152 void MCR20Drv_DirectAccessSPIMultiByteWrite
00153 (
00154 uint8_t startAddress,
00155 uint8_t * byteArray,
00156 uint8_t numOfBytes
00157 )
00158 {
00159     uint8_t txData;
00160 
00161     if( (numOfBytes == 0) || (byteArray == NULL) )
00162     {
00163         return;
00164     }
00165 
00166     ProtectFromMCR20Interrupt();
00167 
00168     spi_master_configure_speed(gXcvrSpiInstance_c, 16000000);
00169 
00170     gXcvrAssertCS_d();
00171 
00172     txData = (startAddress & TransceiverSPI_DirectRegisterAddressMask);
00173 
00174     spi_master_transfer(gXcvrSpiInstance_c, &txData, NULL, sizeof(txData));
00175     spi_master_transfer(gXcvrSpiInstance_c, byteArray, NULL, numOfBytes);
00176 
00177     gXcvrDeassertCS_d();
00178     UnprotectFromMCR20Interrupt();
00179 }
00180 
00181 /*---------------------------------------------------------------------------
00182 * Name: MCR20Drv_PB_SPIByteWrite
00183 * Description: -
00184 * Parameters: -
00185 * Return: -
00186 *---------------------------------------------------------------------------*/
00187 void MCR20Drv_PB_SPIByteWrite
00188 (
00189 uint8_t address,
00190 uint8_t value
00191 )
00192 {
00193     uint32_t txData;
00194 
00195     ProtectFromMCR20Interrupt();
00196 
00197     spi_master_configure_speed(gXcvrSpiInstance_c, 16000000);
00198 
00199     gXcvrAssertCS_d();
00200 
00201     txData  = TransceiverSPI_WriteSelect            |
00202         TransceiverSPI_PacketBuffAccessSelect |
00203             TransceiverSPI_PacketBuffByteModeSelect;
00204     txData |= (address) << 8;
00205     txData |= (value)   << 16;
00206 
00207     spi_master_transfer(gXcvrSpiInstance_c, (uint8_t*)&txData, NULL, 3);
00208 
00209     gXcvrDeassertCS_d();
00210     UnprotectFromMCR20Interrupt();
00211 }
00212 
00213 /*---------------------------------------------------------------------------
00214 * Name: MCR20Drv_PB_SPIBurstWrite
00215 * Description: -
00216 * Parameters: -
00217 * Return: -
00218 *---------------------------------------------------------------------------*/
00219 void MCR20Drv_PB_SPIBurstWrite
00220 (
00221 uint8_t * byteArray,
00222 uint8_t numOfBytes
00223 )
00224 {
00225     uint8_t txData;
00226 
00227     if( (numOfBytes == 0) || (byteArray == NULL) )
00228     {
00229         return;
00230     }
00231 
00232     ProtectFromMCR20Interrupt();
00233 
00234     spi_master_configure_speed(gXcvrSpiInstance_c, 16000000);
00235 
00236     gXcvrAssertCS_d();
00237 
00238     txData = TransceiverSPI_WriteSelect            |
00239         TransceiverSPI_PacketBuffAccessSelect |
00240             TransceiverSPI_PacketBuffBurstModeSelect;
00241 
00242     spi_master_transfer(gXcvrSpiInstance_c, &txData, NULL, 1);
00243     spi_master_transfer(gXcvrSpiInstance_c, byteArray, NULL, numOfBytes);
00244 
00245     gXcvrDeassertCS_d();
00246     UnprotectFromMCR20Interrupt();
00247 }
00248 
00249 /*---------------------------------------------------------------------------
00250 * Name: MCR20Drv_DirectAccessSPIRead
00251 * Description: -
00252 * Parameters: -
00253 * Return: -
00254 *---------------------------------------------------------------------------*/
00255 
00256 uint8_t MCR20Drv_DirectAccessSPIRead
00257 (
00258 uint8_t address
00259 )
00260 {
00261     uint8_t txData;
00262     uint8_t rxData;
00263 
00264     ProtectFromMCR20Interrupt();
00265 
00266     spi_master_configure_speed(gXcvrSpiInstance_c, 8000000);
00267 
00268     gXcvrAssertCS_d();
00269 
00270     txData = (address & TransceiverSPI_DirectRegisterAddressMask) |
00271         TransceiverSPI_ReadSelect;
00272 
00273     spi_master_transfer(gXcvrSpiInstance_c, &txData, NULL, sizeof(txData));
00274     spi_master_transfer(gXcvrSpiInstance_c, NULL, &rxData, sizeof(rxData));
00275 
00276     gXcvrDeassertCS_d();
00277     UnprotectFromMCR20Interrupt();
00278 
00279     return rxData;
00280 
00281 }
00282 
00283 /*---------------------------------------------------------------------------
00284 * Name: MCR20Drv_DirectAccessSPIMultyByteRead
00285 * Description: -
00286 * Parameters: -
00287 * Return: -
00288 *---------------------------------------------------------------------------*/
00289 uint8_t MCR20Drv_DirectAccessSPIMultiByteRead
00290 (
00291 uint8_t startAddress,
00292 uint8_t * byteArray,
00293 uint8_t numOfBytes
00294 )
00295 {
00296     uint8_t  txData;
00297     uint8_t  phyIRQSTS1;
00298 
00299     if( (numOfBytes == 0) || (byteArray == NULL) )
00300     {
00301         return 0;
00302     }
00303 
00304     ProtectFromMCR20Interrupt();
00305 
00306     spi_master_configure_speed(gXcvrSpiInstance_c, 8000000);
00307 
00308     gXcvrAssertCS_d();
00309 
00310     txData = (startAddress & TransceiverSPI_DirectRegisterAddressMask) |
00311         TransceiverSPI_ReadSelect;
00312 
00313     spi_master_transfer(gXcvrSpiInstance_c, &txData, &phyIRQSTS1, sizeof(txData));
00314     spi_master_transfer(gXcvrSpiInstance_c, NULL, byteArray, numOfBytes);
00315 
00316     gXcvrDeassertCS_d();
00317     UnprotectFromMCR20Interrupt();
00318 
00319     return phyIRQSTS1;
00320 }
00321 
00322 /*---------------------------------------------------------------------------
00323 * Name: MCR20Drv_PB_SPIBurstRead
00324 * Description: -
00325 * Parameters: -
00326 * Return: -
00327 *---------------------------------------------------------------------------*/
00328 uint8_t MCR20Drv_PB_SPIBurstRead
00329 (
00330 uint8_t * byteArray,
00331 uint8_t numOfBytes
00332 )
00333 {
00334     uint8_t  txData;
00335     uint8_t  phyIRQSTS1;
00336 
00337     if( (numOfBytes == 0) || (byteArray == NULL) )
00338     {
00339         return 0;
00340     }
00341 
00342     ProtectFromMCR20Interrupt();
00343 
00344     spi_master_configure_speed(gXcvrSpiInstance_c, 8000000);
00345 
00346     gXcvrAssertCS_d();
00347 
00348     txData = TransceiverSPI_ReadSelect |
00349         TransceiverSPI_PacketBuffAccessSelect |
00350             TransceiverSPI_PacketBuffBurstModeSelect;
00351 
00352     spi_master_transfer(gXcvrSpiInstance_c, &txData, &phyIRQSTS1, sizeof(txData));
00353     spi_master_transfer(gXcvrSpiInstance_c, NULL, byteArray, numOfBytes);
00354 
00355     gXcvrDeassertCS_d();
00356     UnprotectFromMCR20Interrupt();
00357 
00358     return phyIRQSTS1;
00359 }
00360 
00361 /*---------------------------------------------------------------------------
00362 * Name: MCR20Drv_IndirectAccessSPIWrite
00363 * Description: -
00364 * Parameters: -
00365 * Return: -
00366 *---------------------------------------------------------------------------*/
00367 void MCR20Drv_IndirectAccessSPIWrite
00368 (
00369 uint8_t address,
00370 uint8_t value
00371 )
00372 {
00373     uint32_t  txData;
00374 
00375     ProtectFromMCR20Interrupt();
00376 
00377     spi_master_configure_speed(gXcvrSpiInstance_c, 16000000);
00378 
00379     gXcvrAssertCS_d();
00380 
00381     txData = TransceiverSPI_IARIndexReg;
00382     txData |= (address) << 8;
00383     txData |= (value)   << 16;
00384 
00385     spi_master_transfer(gXcvrSpiInstance_c, (uint8_t*)&txData, NULL, 3);
00386 
00387     gXcvrDeassertCS_d();
00388     UnprotectFromMCR20Interrupt();
00389 }
00390 
00391 /*---------------------------------------------------------------------------
00392 * Name: MCR20Drv_IndirectAccessSPIMultiByteWrite
00393 * Description: -
00394 * Parameters: -
00395 * Return: -
00396 *---------------------------------------------------------------------------*/
00397 void MCR20Drv_IndirectAccessSPIMultiByteWrite
00398 (
00399 uint8_t startAddress,
00400 uint8_t * byteArray,
00401 uint8_t numOfBytes
00402 )
00403 {
00404     uint16_t  txData;
00405 
00406     if( (numOfBytes == 0) || (byteArray == NULL) )
00407     {
00408         return;
00409     }
00410 
00411     ProtectFromMCR20Interrupt();
00412 
00413     spi_master_configure_speed(gXcvrSpiInstance_c, 16000000);
00414 
00415     gXcvrAssertCS_d();
00416 
00417     txData = TransceiverSPI_IARIndexReg;
00418     txData |= (startAddress)  << 8;
00419 
00420     spi_master_transfer(gXcvrSpiInstance_c, (uint8_t*)&txData, NULL, sizeof(txData));
00421     spi_master_transfer(gXcvrSpiInstance_c, (uint8_t*)byteArray, NULL, numOfBytes);
00422 
00423     gXcvrDeassertCS_d();
00424     UnprotectFromMCR20Interrupt();
00425 }
00426 
00427 /*---------------------------------------------------------------------------
00428 * Name: MCR20Drv_IndirectAccessSPIRead
00429 * Description: -
00430 * Parameters: -
00431 * Return: -
00432 *---------------------------------------------------------------------------*/
00433 uint8_t MCR20Drv_IndirectAccessSPIRead
00434 (
00435 uint8_t address
00436 )
00437 {
00438     uint16_t  txData;
00439     uint8_t   rxData;
00440 
00441     ProtectFromMCR20Interrupt();
00442 
00443     spi_master_configure_speed(gXcvrSpiInstance_c, 8000000);
00444 
00445     gXcvrAssertCS_d();
00446 
00447     txData = TransceiverSPI_IARIndexReg | TransceiverSPI_ReadSelect;
00448     txData |= (address) << 8;
00449 
00450     spi_master_transfer(gXcvrSpiInstance_c, (uint8_t*)&txData, NULL, sizeof(txData));
00451     spi_master_transfer(gXcvrSpiInstance_c, NULL, &rxData, sizeof(rxData));
00452 
00453     gXcvrDeassertCS_d();
00454     UnprotectFromMCR20Interrupt();
00455 
00456     return rxData;
00457 }
00458 
00459 /*---------------------------------------------------------------------------
00460 * Name: MCR20Drv_IndirectAccessSPIMultiByteRead
00461 * Description: -
00462 * Parameters: -
00463 * Return: -
00464 *---------------------------------------------------------------------------*/
00465 void MCR20Drv_IndirectAccessSPIMultiByteRead
00466 (
00467 uint8_t startAddress,
00468 uint8_t * byteArray,
00469 uint8_t numOfBytes
00470 )
00471 {
00472     uint16_t  txData;
00473 
00474     if( (numOfBytes == 0) || (byteArray == NULL) )
00475     {
00476         return;
00477     }
00478 
00479     ProtectFromMCR20Interrupt();
00480 
00481     spi_master_configure_speed(gXcvrSpiInstance_c, 8000000);
00482 
00483     gXcvrAssertCS_d();
00484 
00485     txData = (TransceiverSPI_IARIndexReg | TransceiverSPI_ReadSelect);
00486     txData |= (startAddress) << 8;
00487 
00488     spi_master_transfer(gXcvrSpiInstance_c, (uint8_t*)&txData, NULL, sizeof(txData));
00489     spi_master_transfer(gXcvrSpiInstance_c, NULL, byteArray, numOfBytes);
00490 
00491     gXcvrDeassertCS_d();
00492     UnprotectFromMCR20Interrupt();
00493 }
00494 
00495 /*---------------------------------------------------------------------------
00496 * Name: MCR20Drv_IRQ_PortConfig
00497 * Description: -
00498 * Parameters: -
00499 * Return: -
00500 *---------------------------------------------------------------------------*/
00501 void MCR20Drv_IRQ_PortConfig
00502 (
00503 void
00504 )
00505 {
00506 #if 0
00507     PORT_HAL_SetMuxMode(g_portBaseAddr[GPIO_EXTRACT_PORT(kGpioXcvrIrqPin)],
00508                         GPIO_EXTRACT_PIN(kGpioXcvrIrqPin),
00509                         kPortMuxAsGpio);
00510     GPIO_DRV_InputPinInit(&mXcvrIrqPinCfg);
00511 #endif
00512 }
00513 
00514 /*---------------------------------------------------------------------------
00515 * Name: MCR20Drv_IsIrqPending
00516 * Description: -
00517 * Parameters: -
00518 * Return: -
00519 *---------------------------------------------------------------------------*/
00520 uint32_t  MCR20Drv_IsIrqPending
00521 (
00522 void
00523 )
00524 {
00525     if( !RF_isIRQ_Pending() )
00526     {
00527         return TRUE;
00528     }
00529 
00530     return FALSE;
00531 }
00532 
00533 /*---------------------------------------------------------------------------
00534 * Name: MCR20Drv_IRQ_Disable
00535 * Description: -
00536 * Parameters: -
00537 * Return: -
00538 *---------------------------------------------------------------------------*/
00539 void MCR20Drv_IRQ_Disable
00540 (
00541 void
00542 )
00543 {
00544     OSA_EnterCritical(kCriticalDisableInt);
00545 
00546     if( mPhyIrqDisableCnt == 0 )
00547     {
00548         RF_IRQ_Disable();
00549     }
00550 
00551     mPhyIrqDisableCnt++;
00552 
00553     OSA_ExitCritical(kCriticalDisableInt);
00554 }
00555 
00556 /*---------------------------------------------------------------------------
00557 * Name: MCR20Drv_IRQ_Enable
00558 * Description: -
00559 * Parameters: -
00560 * Return: -
00561 *---------------------------------------------------------------------------*/
00562 void MCR20Drv_IRQ_Enable
00563 (
00564 void
00565 )
00566 {
00567     OSA_EnterCritical(kCriticalDisableInt);
00568 
00569     if( mPhyIrqDisableCnt )
00570     {
00571         mPhyIrqDisableCnt--;
00572 
00573         if( mPhyIrqDisableCnt == 0 )
00574         {
00575             RF_IRQ_Enable();
00576         }
00577     }
00578 
00579     OSA_ExitCritical(kCriticalDisableInt);
00580 }
00581 
00582 /*---------------------------------------------------------------------------
00583 * Name: MCR20Drv_IRQ_IsEnabled
00584 * Description: -
00585 * Parameters: -
00586 * Return: -
00587 *---------------------------------------------------------------------------*/
00588 uint32_t MCR20Drv_IRQ_IsEnabled
00589 (
00590 void
00591 )
00592 {
00593   
00594 #if 0
00595     port_interrupt_config_t mode;
00596 
00597     mode = PORT_HAL_GetPinIntMode(g_portBaseAddr[GPIO_EXTRACT_PORT(kGpioXcvrIrqPin)],
00598                                   GPIO_EXTRACT_PIN(kGpioXcvrIrqPin));
00599     return (mode != kPortIntDisabled);
00600 #endif
00601     return 1;
00602 }
00603 
00604 /*---------------------------------------------------------------------------
00605 * Name: MCR20Drv_IRQ_Clear
00606 * Description: -
00607 * Parameters: -
00608 * Return: -
00609 *---------------------------------------------------------------------------*/
00610 void MCR20Drv_IRQ_Clear
00611 (
00612 void
00613 )
00614 {
00615     //GPIO_DRV_ClearPinIntFlag(kGpioXcvrIrqPin);
00616 }
00617 
00618 /*---------------------------------------------------------------------------
00619 * Name: MCR20Drv_RST_Assert
00620 * Description: -
00621 * Parameters: -
00622 * Return: -
00623 *---------------------------------------------------------------------------*/
00624 void MCR20Drv_RST_B_Assert
00625 (
00626 void
00627 )
00628 {
00629     RF_RST_Set(0);
00630     //GPIO_DRV_ClearPinOutput(kGpioXcvrResetPin);
00631 }
00632 
00633 /*---------------------------------------------------------------------------
00634 * Name: MCR20Drv_RST_Deassert
00635 * Description: -
00636 * Parameters: -
00637 * Return: -
00638 *---------------------------------------------------------------------------*/
00639 void MCR20Drv_RST_B_Deassert
00640 (
00641 void
00642 )
00643 {
00644     RF_RST_Set(1);
00645     //GPIO_DRV_SetPinOutput(kGpioXcvrResetPin);
00646 }
00647 
00648 /*---------------------------------------------------------------------------
00649 * Name: MCR20Drv_SoftRST_Assert
00650 * Description: -
00651 * Parameters: -
00652 * Return: -
00653 *---------------------------------------------------------------------------*/
00654 void MCR20Drv_SoftRST_Assert
00655 (
00656 void
00657 )
00658 {
00659     MCR20Drv_IndirectAccessSPIWrite(SOFT_RESET, (0x80));
00660 }
00661 
00662 /*---------------------------------------------------------------------------
00663 * Name: MCR20Drv_SoftRST_Deassert
00664 * Description: -
00665 * Parameters: -
00666 * Return: -
00667 *---------------------------------------------------------------------------*/
00668 void MCR20Drv_SoftRST_Deassert
00669 (
00670 void
00671 )
00672 {
00673     MCR20Drv_IndirectAccessSPIWrite(SOFT_RESET, (0x00));
00674 }
00675 
00676 /*---------------------------------------------------------------------------
00677 * Name: MCR20Drv_Soft_RESET
00678 * Description: -
00679 * Parameters: -
00680 * Return: -
00681 *---------------------------------------------------------------------------*/
00682 void MCR20Drv_Soft_RESET
00683 (
00684 void
00685 )
00686 {
00687     //assert SOG_RST
00688     MCR20Drv_IndirectAccessSPIWrite(SOFT_RESET, (0x80));
00689 
00690     //deassert SOG_RST
00691     MCR20Drv_IndirectAccessSPIWrite(SOFT_RESET, (0x00));
00692 }
00693 
00694 /*---------------------------------------------------------------------------
00695 * Name: MCR20Drv_RESET
00696 * Description: -
00697 * Parameters: -
00698 * Return: -
00699 *---------------------------------------------------------------------------*/
00700 void MCR20Drv_RESET
00701 (
00702 void
00703 )
00704 {
00705     volatile uint32_t delay = 1000;
00706     //assert RST_B
00707     MCR20Drv_RST_B_Assert();
00708 
00709     // TODO
00710     while(delay--);
00711 
00712     //deassert RST_B
00713     MCR20Drv_RST_B_Deassert();
00714 }
00715 
00716 /*---------------------------------------------------------------------------
00717 * Name: MCR20Drv_Set_CLK_OUT_Freq
00718 * Description: -
00719 * Parameters: -
00720 * Return: -
00721 *---------------------------------------------------------------------------*/
00722 void MCR20Drv_Set_CLK_OUT_Freq
00723 (
00724 uint8_t freqDiv
00725 )
00726 {
00727     uint8_t clkOutCtrlReg = (freqDiv & cCLK_OUT_DIV_Mask) | cCLK_OUT_EN | cCLK_OUT_EXTEND;
00728 
00729     if(freqDiv == gCLK_OUT_FREQ_DISABLE)
00730     {
00731         clkOutCtrlReg = (cCLK_OUT_EXTEND | gCLK_OUT_FREQ_4_MHz); //reset value with clock out disabled
00732     }
00733 
00734     MCR20Drv_DirectAccessSPIWrite((uint8_t) CLK_OUT_CTRL, clkOutCtrlReg);
00735 }