lpc_bod.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /**********************************************************************
  2. * $Id$ lpc_bod.c 2011-12-09
  3. *//**
  4. * @file lpc_bod.c
  5. * @brief Contain functions related to BOD.
  6. * @version 1.0
  7. * @date 09 December. 2011
  8. * @author NXP MCU SW Application Team
  9. *
  10. * Copyright(C) 2011, NXP Semiconductor
  11. * All rights reserved.
  12. *
  13. ***********************************************************************
  14. * Software that is described herein is for illustrative purposes only
  15. * which provides customers with programming information regarding the
  16. * products. This software is supplied "AS IS" without any warranties.
  17. * NXP Semiconductors assumes no responsibility or liability for the
  18. * use of the software, conveys no license or title under any patent,
  19. * copyright, or mask work right to the product. NXP Semiconductors
  20. * reserves the right to make changes in the software without
  21. * notification. NXP Semiconductors also make no representation or
  22. * warranty that such application will be suitable for the specified
  23. * use without further testing or modification.
  24. * Permission to use, copy, modify, and distribute this software and its
  25. * documentation is hereby granted, under NXP Semiconductors'
  26. * relevant copyright in the software, without fee, provided that it
  27. * is used in conjunction with NXP Semiconductors microcontrollers. This
  28. * copyright, permission, and disclaimer notice must appear in all copies of
  29. * this code.
  30. **********************************************************************/
  31. /* Peripheral group ----------------------------------------------------------- */
  32. /** @addtogroup BOD
  33. * @{
  34. */
  35. #ifdef __BUILD_WITH_EXAMPLE__
  36. #include "lpc_libcfg.h"
  37. #else
  38. #include "lpc_libcfg_default.h"
  39. #endif /* __BUILD_WITH_EXAMPLE__ */
  40. #ifdef _BOD
  41. #include "LPC407x_8x_177x_8x.h" /* LPC407x_8x_177x_8x Peripheral Registers */
  42. #include "lpc_bod.h"
  43. /* Public Functions ----------------------------------------------------------- */
  44. /** @addtogroup BOD_Public_Functions
  45. * @{
  46. */
  47. /*********************************************************************//**
  48. * @brief Initialize BOD control register
  49. * @param[in] pConfig BOD Configuration
  50. * @return None
  51. **********************************************************************/
  52. void BOD_Init( BOD_Config_Type* pConfig )
  53. {
  54. /* Turn on/off BOD. */
  55. if(pConfig->Enabled == DISABLE)
  56. {
  57. LPC_SC->PCON |= BOD_PCON_BOGD;
  58. return;
  59. }
  60. LPC_SC->PCON &= ~BOD_PCON_BOGD;
  61. /* Brown-Out Reduced Power Mode */
  62. if(pConfig->PowerReduced == ENABLE)
  63. {
  64. LPC_SC->PCON |= BOD_PCON_BODRPM;
  65. }
  66. else
  67. {
  68. LPC_SC->PCON &= ~BOD_PCON_BODRPM;
  69. }
  70. /* Brown-Out Reset */
  71. if(pConfig->ResetOnVoltageDown == DISABLE)
  72. {
  73. LPC_SC->PCON |= BOD_PCON_BORD;
  74. }
  75. else
  76. {
  77. LPC_SC->PCON &= ~BOD_PCON_BORD;
  78. }
  79. /* Enable the BOD Interrupt */
  80. NVIC_EnableIRQ(BOD_IRQn);
  81. return;
  82. }
  83. /*********************************************************************//**
  84. * @brief Get BOD reset source status
  85. * @param[in] None
  86. * @return TRUE/FALSE
  87. **********************************************************************/
  88. int32_t BOD_ResetSourceStatus( void )
  89. {
  90. if((LPC_SC->RSID & BOD_RSID_POR) == 1)
  91. return DISABLE;
  92. return ((LPC_SC->RSID & BOD_RSID_BODR)? ENABLE:DISABLE);
  93. }
  94. /*********************************************************************//**
  95. * @brief Clear BOD reset source bit
  96. * @param[in] None
  97. * @return None
  98. **********************************************************************/
  99. void BOD_ResetSourceClr( void )
  100. {
  101. LPC_SC->RSID |= BOD_RSID_BODR;
  102. }
  103. /**
  104. * @}
  105. */
  106. #endif /*_BOD */
  107. /**
  108. * @}
  109. */
  110. /******************************************************************************
  111. ** End Of File
  112. ******************************************************************************/