main.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Unlicense OR CC0-1.0
  5. */
  6. /* ULP-RISC-V example
  7. This example code is in the Public Domain (or CC0 licensed, at your option.)
  8. Unless required by applicable law or agreed to in writing, this
  9. software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  10. CONDITIONS OF ANY KIND, either express or implied.
  11. This code runs on ULP-RISC-V coprocessor
  12. */
  13. #include <stdint.h>
  14. #include "ulp_riscv_utils.h"
  15. #include "ulp_riscv_adc_ulp_core.h"
  16. #include "ulp_riscv_gpio.h"
  17. #include <stdio.h>
  18. #include "example_config.h"
  19. #if 0
  20. #include "freertos/FreeRTOS.h"
  21. #include "freertos/task.h"
  22. #include "freertos/queue.h"
  23. extern QueueHandle_t sleep_queue;
  24. extern QueueHandle_t wakeup_queue;
  25. #else
  26. #include "user_sleep.h"
  27. #endif
  28. uint32_t adc_threshold = EXAMPLE_ADC_TRESHOLD;
  29. int32_t wakeup_result = 0x00000000;
  30. uint32_t last_power_chargeing_status = 1;
  31. uint32_t new_power_chargeing_status = 1;
  32. int main (void)
  33. {
  34. uint8_t button_info = 0;
  35. uint8_t name = 0;
  36. //adc_ll_set_power_manage(ADC_POWER_BY_FSM);
  37. int32_t last_result = ulp_riscv_adc_read_channel(EXAMPLE_ADC_UNIT, EXAMPLE_ADC_CHANNEL); //key
  38. //adc_ll_set_power_manage(ADC_POWER_SW_OFF);
  39. //adc_ll_set_power_manage(ADC_POWER_BY_FSM);
  40. int32_t power_result = 0; //= ulp_riscv_adc_read_channel(EXAMPLE_ADC_UNIT, ADC_CHANNEL_3); //power_key
  41. //adc_ll_set_power_manage(ADC_POWER_SW_OFF);
  42. //sar_ctrl_ll_set_power_mode(SAR_CTRL_LL_POWER_OFF);
  43. if (last_result < adc_threshold) {
  44. wakeup_result = last_result;
  45. #if 1
  46. //printf("start wake up\r\n");
  47. ulp_riscv_wakeup_main_processor();
  48. #else
  49. #endif
  50. }
  51. #if 0
  52. if(power_result <adc_threshold)
  53. {
  54. ulp_riscv_wakeup_main_processor();
  55. }
  56. #endif
  57. return 0;
  58. }