nrf_ic_info.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */
  12. #include "nrf_ic_info.h"
  13. #include "nrf.h"
  14. #define PART_NO_NRF51 0x01
  15. #define PART_NO_NRF52 0x06
  16. void nrf_ic_info_get(nrf_ic_info_t * p_ic_info)
  17. {
  18. uint32_t ic_data = ((*((uint32_t volatile *)0xF0000FE8)) & 0x000000F0) >> 4;
  19. uint32_t ic_part_no = ((*((uint32_t volatile *)0xF0000FE0)) & 0x000000FF);
  20. switch (ic_part_no)
  21. {
  22. #if defined(NRF51)
  23. case PART_NO_NRF51:
  24. {
  25. p_ic_info->ram_size = (uint16_t) NRF_FICR->NUMRAMBLOCK;
  26. p_ic_info->ram_size *= (uint16_t) (NRF_FICR->SIZERAMBLOCKS / 1024);
  27. p_ic_info->flash_size = (uint16_t) NRF_FICR->CODESIZE;
  28. switch (ic_data)
  29. {
  30. /** IC revision 1 */
  31. case 1:
  32. p_ic_info->ic_revision = IC_REVISION_NRF51_REV1;
  33. break;
  34. /** IC revision 2 */
  35. case 4:
  36. p_ic_info->ic_revision = IC_REVISION_NRF51_REV2;
  37. break;
  38. /** IC revision 3 */
  39. case 7:
  40. /* fall through */
  41. case 8:
  42. /* fall through */
  43. case 9:
  44. p_ic_info->ic_revision = IC_REVISION_NRF51_REV3;
  45. break;
  46. default:
  47. p_ic_info->ic_revision = IC_REVISION_NRF51_UNKNOWN;
  48. break;
  49. }
  50. break;
  51. }
  52. #endif
  53. default:
  54. p_ic_info->ic_revision = IC_PART_UNKNOWN;
  55. p_ic_info->flash_size = 0;
  56. p_ic_info->ram_size = 0;
  57. break;
  58. }
  59. }