Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

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 #include "XcvrSpi.h "
00044 
00045 #if defined(MBED_CONF_NANOSTACK_CONFIGURATION) && DEVICE_SPI && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)
00046 
00047 #include "platform/mbed_critical.h"
00048 
00049 /*****************************************************************************
00050 *                               PRIVATE VARIABLES                           *
00051 *---------------------------------------------------------------------------*
00052 * Add to this section all the variables and constants that have local       *
00053 * (file) scope.                                                             *
00054 * Each of this declarations shall be preceded by the 'static' keyword.      *
00055 * These variables / constants cannot be accessed outside this module.       *
00056 *---------------------------------------------------------------------------*
00057 *****************************************************************************/
00058 uint32_t mPhyIrqDisableCnt = 1;
00059 
00060 /*****************************************************************************
00061 *                               PUBLIC VARIABLES                            *
00062 *---------------------------------------------------------------------------*
00063 * Add to this section all the variables and constants that have global      *
00064 * (project) scope.                                                          *
00065 * These variables / constants can be accessed outside this module.          *
00066 * These variables / constants shall be preceded by the 'extern' keyword in  *
00067 * the interface header.                                                     *
00068 *---------------------------------------------------------------------------*
00069 *****************************************************************************/
00070 
00071 /*****************************************************************************
00072 *                           PRIVATE FUNCTIONS PROTOTYPES                    *
00073 *---------------------------------------------------------------------------*
00074 * Add to this section all the functions prototypes that have local (file)   *
00075 * scope.                                                                    *
00076 * These functions cannot be accessed outside this module.                   *
00077 * These declarations shall be preceded by the 'static' keyword.             *
00078 *---------------------------------------------------------------------------*
00079 *****************************************************************************/
00080 
00081 /*****************************************************************************
00082 *                                PRIVATE FUNCTIONS                          *
00083 *---------------------------------------------------------------------------*
00084 * Add to this section all the functions that have local (file) scope.       *
00085 * These functions cannot be accessed outside this module.                   *
00086 * These definitions shall be preceded by the 'static' keyword.              *
00087 *---------------------------------------------------------------------------*
00088 *****************************************************************************/
00089 
00090 
00091 /*****************************************************************************
00092 *                             PUBLIC FUNCTIONS                              *
00093 *---------------------------------------------------------------------------*
00094 * Add to this section all the functions that have global (project) scope.   *
00095 * These functions can be accessed outside this module.                      *
00096 * These functions shall have their declarations (prototypes) within the     *
00097 * interface header file and shall be preceded by the 'extern' keyword.      *
00098 *---------------------------------------------------------------------------*
00099 *****************************************************************************/
00100 
00101 /*---------------------------------------------------------------------------
00102 * Name: MCR20Drv_Init
00103 * Description: -
00104 * Parameters: -
00105 * Return: -
00106 *---------------------------------------------------------------------------*/
00107 void MCR20Drv_Init
00108 (
00109     void
00110 )
00111 {
00112     xcvr_spi_init(gXcvrSpiInstance_c);
00113     xcvr_spi_configure_speed(gXcvrSpiInstance_c, 8000000);
00114 
00115     gXcvrDeassertCS_d();
00116 #if !defined(TARGET_KW24D)
00117     MCR20Drv_RST_B_Deassert();
00118 #endif
00119     RF_IRQ_Init();
00120     RF_IRQ_Disable();
00121     mPhyIrqDisableCnt = 1;
00122 }
00123 
00124 /*---------------------------------------------------------------------------
00125 * Name: MCR20Drv_DirectAccessSPIWrite
00126 * Description: -
00127 * Parameters: -
00128 * Return: -
00129 *---------------------------------------------------------------------------*/
00130 void MCR20Drv_DirectAccessSPIWrite
00131 (
00132     uint8_t address,
00133     uint8_t value
00134 )
00135 {
00136     uint16_t txData;
00137 
00138     ProtectFromMCR20Interrupt();
00139 
00140     xcvr_spi_configure_speed(gXcvrSpiInstance_c, 16000000);
00141 
00142     gXcvrAssertCS_d();
00143 
00144     txData = (address & TransceiverSPI_DirectRegisterAddressMask);
00145     txData |= value << 8;
00146 
00147     xcvr_spi_transfer(gXcvrSpiInstance_c, (uint8_t *)&txData, 0, sizeof(txData));
00148 
00149     gXcvrDeassertCS_d();
00150     UnprotectFromMCR20Interrupt();
00151 }
00152 
00153 /*---------------------------------------------------------------------------
00154 * Name: MCR20Drv_DirectAccessSPIMultiByteWrite
00155 * Description: -
00156 * Parameters: -
00157 * Return: -
00158 *---------------------------------------------------------------------------*/
00159 void MCR20Drv_DirectAccessSPIMultiByteWrite
00160 (
00161     uint8_t startAddress,
00162     uint8_t *byteArray,
00163     uint8_t numOfBytes
00164 )
00165 {
00166     uint8_t txData;
00167 
00168     if ((numOfBytes == 0) || (byteArray == 0)) {
00169         return;
00170     }
00171 
00172     ProtectFromMCR20Interrupt();
00173 
00174     xcvr_spi_configure_speed(gXcvrSpiInstance_c, 16000000);
00175 
00176     gXcvrAssertCS_d();
00177 
00178     txData = (startAddress & TransceiverSPI_DirectRegisterAddressMask);
00179 
00180     xcvr_spi_transfer(gXcvrSpiInstance_c, &txData, 0, sizeof(txData));
00181     xcvr_spi_transfer(gXcvrSpiInstance_c, byteArray, 0, numOfBytes);
00182 
00183     gXcvrDeassertCS_d();
00184     UnprotectFromMCR20Interrupt();
00185 }
00186 
00187 /*---------------------------------------------------------------------------
00188 * Name: MCR20Drv_PB_SPIByteWrite
00189 * Description: -
00190 * Parameters: -
00191 * Return: -
00192 *---------------------------------------------------------------------------*/
00193 void MCR20Drv_PB_SPIByteWrite
00194 (
00195     uint8_t address,
00196     uint8_t value
00197 )
00198 {
00199     uint32_t txData;
00200 
00201     ProtectFromMCR20Interrupt();
00202 
00203     xcvr_spi_configure_speed(gXcvrSpiInstance_c, 16000000);
00204 
00205     gXcvrAssertCS_d();
00206 
00207     txData  = TransceiverSPI_WriteSelect            |
00208               TransceiverSPI_PacketBuffAccessSelect |
00209               TransceiverSPI_PacketBuffByteModeSelect;
00210     txData |= (address) << 8;
00211     txData |= (value)   << 16;
00212 
00213     xcvr_spi_transfer(gXcvrSpiInstance_c, (uint8_t *)&txData, 0, 3);
00214 
00215     gXcvrDeassertCS_d();
00216     UnprotectFromMCR20Interrupt();
00217 }
00218 
00219 /*---------------------------------------------------------------------------
00220 * Name: MCR20Drv_PB_SPIBurstWrite
00221 * Description: -
00222 * Parameters: -
00223 * Return: -
00224 *---------------------------------------------------------------------------*/
00225 void MCR20Drv_PB_SPIBurstWrite
00226 (
00227     uint8_t *byteArray,
00228     uint8_t numOfBytes
00229 )
00230 {
00231     uint8_t txData;
00232 
00233     if ((numOfBytes == 0) || (byteArray == 0)) {
00234         return;
00235     }
00236 
00237     ProtectFromMCR20Interrupt();
00238 
00239     xcvr_spi_configure_speed(gXcvrSpiInstance_c, 16000000);
00240 
00241     gXcvrAssertCS_d();
00242 
00243     txData = TransceiverSPI_WriteSelect            |
00244              TransceiverSPI_PacketBuffAccessSelect |
00245              TransceiverSPI_PacketBuffBurstModeSelect;
00246 
00247     xcvr_spi_transfer(gXcvrSpiInstance_c, &txData, 0, 1);
00248     xcvr_spi_transfer(gXcvrSpiInstance_c, byteArray, 0, numOfBytes);
00249 
00250     gXcvrDeassertCS_d();
00251     UnprotectFromMCR20Interrupt();
00252 }
00253 
00254 /*---------------------------------------------------------------------------
00255 * Name: MCR20Drv_DirectAccessSPIRead
00256 * Description: -
00257 * Parameters: -
00258 * Return: -
00259 *---------------------------------------------------------------------------*/
00260 
00261 uint8_t MCR20Drv_DirectAccessSPIRead
00262 (
00263     uint8_t address
00264 )
00265 {
00266     uint8_t txData;
00267     uint8_t rxData;
00268 
00269     ProtectFromMCR20Interrupt();
00270 
00271     xcvr_spi_configure_speed(gXcvrSpiInstance_c, 8000000);
00272 
00273     gXcvrAssertCS_d();
00274 
00275     txData = (address & TransceiverSPI_DirectRegisterAddressMask) |
00276              TransceiverSPI_ReadSelect;
00277 
00278     xcvr_spi_transfer(gXcvrSpiInstance_c, &txData, 0, sizeof(txData));
00279     xcvr_spi_transfer(gXcvrSpiInstance_c, 0, &rxData, sizeof(rxData));
00280 
00281     gXcvrDeassertCS_d();
00282     UnprotectFromMCR20Interrupt();
00283 
00284     return rxData;
00285 
00286 }
00287 
00288 /*---------------------------------------------------------------------------
00289 * Name: MCR20Drv_DirectAccessSPIMultyByteRead
00290 * Description: -
00291 * Parameters: -
00292 * Return: -
00293 *---------------------------------------------------------------------------*/
00294 uint8_t MCR20Drv_DirectAccessSPIMultiByteRead
00295 (
00296     uint8_t startAddress,
00297     uint8_t *byteArray,
00298     uint8_t numOfBytes
00299 )
00300 {
00301     uint8_t  txData;
00302     uint8_t  phyIRQSTS1;
00303 
00304     if ((numOfBytes == 0) || (byteArray == 0)) {
00305         return 0;
00306     }
00307 
00308     ProtectFromMCR20Interrupt();
00309 
00310     xcvr_spi_configure_speed(gXcvrSpiInstance_c, 8000000);
00311 
00312     gXcvrAssertCS_d();
00313 
00314     txData = (startAddress & TransceiverSPI_DirectRegisterAddressMask) |
00315              TransceiverSPI_ReadSelect;
00316 
00317     xcvr_spi_transfer(gXcvrSpiInstance_c, &txData, &phyIRQSTS1, sizeof(txData));
00318     xcvr_spi_transfer(gXcvrSpiInstance_c, 0, byteArray, numOfBytes);
00319 
00320     gXcvrDeassertCS_d();
00321     UnprotectFromMCR20Interrupt();
00322 
00323     return phyIRQSTS1;
00324 }
00325 
00326 /*---------------------------------------------------------------------------
00327 * Name: MCR20Drv_PB_SPIBurstRead
00328 * Description: -
00329 * Parameters: -
00330 * Return: -
00331 *---------------------------------------------------------------------------*/
00332 uint8_t MCR20Drv_PB_SPIBurstRead
00333 (
00334     uint8_t *byteArray,
00335     uint8_t numOfBytes
00336 )
00337 {
00338     uint8_t  txData;
00339     uint8_t  phyIRQSTS1;
00340 
00341     if ((numOfBytes == 0) || (byteArray == 0)) {
00342         return 0;
00343     }
00344 
00345     ProtectFromMCR20Interrupt();
00346 
00347     xcvr_spi_configure_speed(gXcvrSpiInstance_c, 8000000);
00348 
00349     gXcvrAssertCS_d();
00350 
00351     txData = TransceiverSPI_ReadSelect |
00352              TransceiverSPI_PacketBuffAccessSelect |
00353              TransceiverSPI_PacketBuffBurstModeSelect;
00354 
00355     xcvr_spi_transfer(gXcvrSpiInstance_c, &txData, &phyIRQSTS1, sizeof(txData));
00356     xcvr_spi_transfer(gXcvrSpiInstance_c, 0, byteArray, numOfBytes);
00357 
00358     gXcvrDeassertCS_d();
00359     UnprotectFromMCR20Interrupt();
00360 
00361     return phyIRQSTS1;
00362 }
00363 
00364 /*---------------------------------------------------------------------------
00365 * Name: MCR20Drv_IndirectAccessSPIWrite
00366 * Description: -
00367 * Parameters: -
00368 * Return: -
00369 *---------------------------------------------------------------------------*/
00370 void MCR20Drv_IndirectAccessSPIWrite
00371 (
00372     uint8_t address,
00373     uint8_t value
00374 )
00375 {
00376     uint32_t  txData;
00377 
00378     ProtectFromMCR20Interrupt();
00379 
00380     xcvr_spi_configure_speed(gXcvrSpiInstance_c, 16000000);
00381 
00382     gXcvrAssertCS_d();
00383 
00384     txData = TransceiverSPI_IARIndexReg;
00385     txData |= (address) << 8;
00386     txData |= (value)   << 16;
00387 
00388     xcvr_spi_transfer(gXcvrSpiInstance_c, (uint8_t *)&txData, 0, 3);
00389 
00390     gXcvrDeassertCS_d();
00391     UnprotectFromMCR20Interrupt();
00392 }
00393 
00394 /*---------------------------------------------------------------------------
00395 * Name: MCR20Drv_IndirectAccessSPIMultiByteWrite
00396 * Description: -
00397 * Parameters: -
00398 * Return: -
00399 *---------------------------------------------------------------------------*/
00400 void MCR20Drv_IndirectAccessSPIMultiByteWrite
00401 (
00402     uint8_t startAddress,
00403     uint8_t *byteArray,
00404     uint8_t numOfBytes
00405 )
00406 {
00407     uint16_t  txData;
00408 
00409     if ((numOfBytes == 0) || (byteArray == 0)) {
00410         return;
00411     }
00412 
00413     ProtectFromMCR20Interrupt();
00414 
00415     xcvr_spi_configure_speed(gXcvrSpiInstance_c, 16000000);
00416 
00417     gXcvrAssertCS_d();
00418 
00419     txData = TransceiverSPI_IARIndexReg;
00420     txData |= (startAddress)  << 8;
00421 
00422     xcvr_spi_transfer(gXcvrSpiInstance_c, (uint8_t *)&txData, 0, sizeof(txData));
00423     xcvr_spi_transfer(gXcvrSpiInstance_c, (uint8_t *)byteArray, 0, numOfBytes);
00424 
00425     gXcvrDeassertCS_d();
00426     UnprotectFromMCR20Interrupt();
00427 }
00428 
00429 /*---------------------------------------------------------------------------
00430 * Name: MCR20Drv_IndirectAccessSPIRead
00431 * Description: -
00432 * Parameters: -
00433 * Return: -
00434 *---------------------------------------------------------------------------*/
00435 uint8_t MCR20Drv_IndirectAccessSPIRead
00436 (
00437     uint8_t address
00438 )
00439 {
00440     uint16_t  txData;
00441     uint8_t   rxData;
00442 
00443     ProtectFromMCR20Interrupt();
00444 
00445     xcvr_spi_configure_speed(gXcvrSpiInstance_c, 8000000);
00446 
00447     gXcvrAssertCS_d();
00448 
00449     txData = TransceiverSPI_IARIndexReg | TransceiverSPI_ReadSelect;
00450     txData |= (address) << 8;
00451 
00452     xcvr_spi_transfer(gXcvrSpiInstance_c, (uint8_t *)&txData, 0, sizeof(txData));
00453     xcvr_spi_transfer(gXcvrSpiInstance_c, 0, &rxData, sizeof(rxData));
00454 
00455     gXcvrDeassertCS_d();
00456     UnprotectFromMCR20Interrupt();
00457 
00458     return rxData;
00459 }
00460 
00461 /*---------------------------------------------------------------------------
00462 * Name: MCR20Drv_IndirectAccessSPIMultiByteRead
00463 * Description: -
00464 * Parameters: -
00465 * Return: -
00466 *---------------------------------------------------------------------------*/
00467 void MCR20Drv_IndirectAccessSPIMultiByteRead
00468 (
00469     uint8_t startAddress,
00470     uint8_t *byteArray,
00471     uint8_t numOfBytes
00472 )
00473 {
00474     uint16_t  txData;
00475 
00476     if ((numOfBytes == 0) || (byteArray == 0)) {
00477         return;
00478     }
00479 
00480     ProtectFromMCR20Interrupt();
00481 
00482     xcvr_spi_configure_speed(gXcvrSpiInstance_c, 8000000);
00483 
00484     gXcvrAssertCS_d();
00485 
00486     txData = (TransceiverSPI_IARIndexReg | TransceiverSPI_ReadSelect);
00487     txData |= (startAddress) << 8;
00488 
00489     xcvr_spi_transfer(gXcvrSpiInstance_c, (uint8_t *)&txData, 0, sizeof(txData));
00490     xcvr_spi_transfer(gXcvrSpiInstance_c, 0, byteArray, numOfBytes);
00491 
00492     gXcvrDeassertCS_d();
00493     UnprotectFromMCR20Interrupt();
00494 }
00495 
00496 /*---------------------------------------------------------------------------
00497 * Name: MCR20Drv_IsIrqPending
00498 * Description: -
00499 * Parameters: -
00500 * Return: -
00501 *---------------------------------------------------------------------------*/
00502 uint32_t  MCR20Drv_IsIrqPending
00503 (
00504     void
00505 )
00506 {
00507     return RF_isIRQ_Pending();
00508 }
00509 
00510 /*---------------------------------------------------------------------------
00511 * Name: MCR20Drv_IRQ_Disable
00512 * Description: -
00513 * Parameters: -
00514 * Return: -
00515 *---------------------------------------------------------------------------*/
00516 void MCR20Drv_IRQ_Disable
00517 (
00518     void
00519 )
00520 {
00521     core_util_critical_section_enter();
00522 
00523     if (mPhyIrqDisableCnt == 0) {
00524         RF_IRQ_Disable();
00525     }
00526 
00527     mPhyIrqDisableCnt++;
00528 
00529     core_util_critical_section_exit();
00530 }
00531 
00532 /*---------------------------------------------------------------------------
00533 * Name: MCR20Drv_IRQ_Enable
00534 * Description: -
00535 * Parameters: -
00536 * Return: -
00537 *---------------------------------------------------------------------------*/
00538 void MCR20Drv_IRQ_Enable
00539 (
00540     void
00541 )
00542 {
00543     core_util_critical_section_enter();
00544 
00545     if (mPhyIrqDisableCnt) {
00546         mPhyIrqDisableCnt--;
00547 
00548         if (mPhyIrqDisableCnt == 0) {
00549             RF_IRQ_Enable();
00550         }
00551     }
00552 
00553     core_util_critical_section_exit();
00554 }
00555 
00556 /*---------------------------------------------------------------------------
00557 * Name: MCR20Drv_RST_Assert
00558 * Description: -
00559 * Parameters: -
00560 * Return: -
00561 *---------------------------------------------------------------------------*/
00562 void MCR20Drv_RST_B_Assert
00563 (
00564     void
00565 )
00566 {
00567     RF_RST_Set(0);
00568 }
00569 
00570 /*---------------------------------------------------------------------------
00571 * Name: MCR20Drv_RST_Deassert
00572 * Description: -
00573 * Parameters: -
00574 * Return: -
00575 *---------------------------------------------------------------------------*/
00576 void MCR20Drv_RST_B_Deassert
00577 (
00578     void
00579 )
00580 {
00581     RF_RST_Set(1);
00582 }
00583 
00584 /*---------------------------------------------------------------------------
00585 * Name: MCR20Drv_SoftRST_Assert
00586 * Description: -
00587 * Parameters: -
00588 * Return: -
00589 *---------------------------------------------------------------------------*/
00590 void MCR20Drv_SoftRST_Assert
00591 (
00592     void
00593 )
00594 {
00595     MCR20Drv_IndirectAccessSPIWrite(SOFT_RESET, (0x80));
00596 }
00597 
00598 /*---------------------------------------------------------------------------
00599 * Name: MCR20Drv_SoftRST_Deassert
00600 * Description: -
00601 * Parameters: -
00602 * Return: -
00603 *---------------------------------------------------------------------------*/
00604 void MCR20Drv_SoftRST_Deassert
00605 (
00606     void
00607 )
00608 {
00609     MCR20Drv_IndirectAccessSPIWrite(SOFT_RESET, (0x00));
00610 }
00611 
00612 /*---------------------------------------------------------------------------
00613 * Name: MCR20Drv_Soft_RESET
00614 * Description: -
00615 * Parameters: -
00616 * Return: -
00617 *---------------------------------------------------------------------------*/
00618 void MCR20Drv_Soft_RESET
00619 (
00620     void
00621 )
00622 {
00623     //assert SOG_RST
00624     MCR20Drv_IndirectAccessSPIWrite(SOFT_RESET, (0x80));
00625 
00626     //deassert SOG_RST
00627     MCR20Drv_IndirectAccessSPIWrite(SOFT_RESET, (0x00));
00628 }
00629 
00630 /*---------------------------------------------------------------------------
00631 * Name: MCR20Drv_RESET
00632 * Description: -
00633 * Parameters: -
00634 * Return: -
00635 *---------------------------------------------------------------------------*/
00636 void MCR20Drv_RESET
00637 (
00638     void
00639 )
00640 {
00641 #if !defined(TARGET_KW24D)
00642     volatile uint32_t delay = 1000;
00643     //assert RST_B
00644     MCR20Drv_RST_B_Assert();
00645 
00646     while (delay--);
00647 
00648     //deassert RST_B
00649     MCR20Drv_RST_B_Deassert();
00650 #endif
00651 }
00652 
00653 /*---------------------------------------------------------------------------
00654 * Name: MCR20Drv_Set_CLK_OUT_Freq
00655 * Description: -
00656 * Parameters: -
00657 * Return: -
00658 *---------------------------------------------------------------------------*/
00659 void MCR20Drv_Set_CLK_OUT_Freq
00660 (
00661     uint8_t freqDiv
00662 )
00663 {
00664     uint8_t clkOutCtrlReg = (freqDiv & cCLK_OUT_DIV_Mask) | cCLK_OUT_EN | cCLK_OUT_EXTEND;
00665 
00666     if (freqDiv == gCLK_OUT_FREQ_DISABLE) {
00667         clkOutCtrlReg = (cCLK_OUT_EXTEND | gCLK_OUT_FREQ_4_MHz); //reset value with clock out disabled
00668     }
00669 
00670     MCR20Drv_DirectAccessSPIWrite((uint8_t) CLK_OUT_CTRL, clkOutCtrlReg);
00671 }
00672 
00673 #endif /* MBED_CONF_NANOSTACK_CONFIGURATION */