rfinit.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /******************************************************************************
  2. * Copyright 2016 Vowstar
  3. *
  4. * FileName: init.c
  5. *
  6. * Description: System and user APP initialization.
  7. *
  8. * Modification history:
  9. * 2016/03/24, v1.0 create this file.
  10. *******************************************************************************/
  11. #include "ets_sys.h"
  12. #include "osapi.h"
  13. #include "user_interface.h"
  14. /******************************************************************************
  15. * FunctionName : user_rf_cal_sector_set
  16. * Description : SDK just reversed 4 sectors, used for rf init data and paramters.
  17. * We add this function to force users to set rf cal sector, since
  18. * we don't know which sector is free in user's application.
  19. * sector map for last several sectors : ABCCC
  20. * A : rf cal
  21. * B : rf init data
  22. * C : sdk parameters
  23. * Parameters : none
  24. * Returns : rf cal sector
  25. *******************************************************************************/
  26. uint32 ICACHE_FLASH_ATTR __attribute__((weak))
  27. user_rf_cal_sector_set(void)
  28. {
  29. enum flash_size_map size_map = system_get_flash_size_map();
  30. uint32 rf_cal_sec = 0;
  31. switch (size_map) {
  32. case FLASH_SIZE_4M_MAP_256_256:
  33. rf_cal_sec = 128 - 5;
  34. break;
  35. case FLASH_SIZE_8M_MAP_512_512:
  36. rf_cal_sec = 256 - 5;
  37. break;
  38. case FLASH_SIZE_16M_MAP_512_512:
  39. case FLASH_SIZE_16M_MAP_1024_1024:
  40. rf_cal_sec = 512 - 5;
  41. break;
  42. case FLASH_SIZE_32M_MAP_512_512:
  43. case FLASH_SIZE_32M_MAP_1024_1024:
  44. rf_cal_sec = 1024 - 5;
  45. break;
  46. default:
  47. rf_cal_sec = 0;
  48. break;
  49. }
  50. return rf_cal_sec;
  51. }
  52. void __attribute__((weak))
  53. user_rf_pre_init(void)
  54. {
  55. // Warning: IF YOU DON'T KNOW WHAT YOU ARE DOING, DON'T TOUCH THESE CODE
  56. // Control RF_CAL by esp_init_data_default.bin(0~127byte) 108 byte when wakeup
  57. // Will low current
  58. // system_phy_set_rfoption(0);
  59. // Process RF_CAL when wakeup.
  60. // Will high current
  61. system_phy_set_rfoption(1);
  62. // Set Wi-Fi Tx Power, Unit: 0.25dBm, Range: [0, 82]
  63. system_phy_set_max_tpw(82);
  64. }