基质喷涂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.8 KiB

  1. // #include "zdelay.h"
  2. //
  3. // #include "zbase.h"
  4. // #include "project_configs.h"
  5. //
  6. // extern TIM_HandleTypeDef SDK_DELAY_US_TIMER;
  7. //
  8. // static HAL_StatusTypeDef _HAL_TIM_Base_Start(TIM_HandleTypeDef* htim) __attribute__((optimize("O2")));
  9. // static HAL_StatusTypeDef _HAL_TIM_Base_Stop(TIM_HandleTypeDef* htim) __attribute__((optimize("O2")));
  10. // static HAL_StatusTypeDef _HAL_TIM_Base_Start(TIM_HandleTypeDef* htim) {
  11. // uint32_t tmpsmcr;
  12. // /* Check the TIM state */
  13. // if (htim->State != HAL_TIM_STATE_READY) {
  14. // return HAL_ERROR;
  15. // }
  16. // htim->State = HAL_TIM_STATE_BUSY;
  17. // if (IS_TIM_SLAVE_INSTANCE(htim->Instance)) {
  18. // tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
  19. // if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr)) {
  20. // __HAL_TIM_ENABLE(htim);
  21. // }
  22. // } else {
  23. // __HAL_TIM_ENABLE(htim);
  24. // }
  25. // return HAL_OK;
  26. // }
  27. // static HAL_StatusTypeDef _HAL_TIM_Base_Stop(TIM_HandleTypeDef* htim) {
  28. // /* Disable the Peripheral */
  29. // __HAL_TIM_DISABLE(htim);
  30. // /* Set the TIM state */
  31. // htim->State = HAL_TIM_STATE_READY;
  32. // /* Return function status */
  33. // return HAL_OK;
  34. // }
  35. //
  36. // void zdelay_us(int var_nus) {
  37. // volatile uint32_t counter = 0;
  38. // __HAL_TIM_SET_COUNTER(&SDK_DELAY_US_TIMER, 0);
  39. // _HAL_TIM_Base_Start(&SDK_DELAY_US_TIMER);
  40. // while (counter < var_nus) {
  41. // counter = __HAL_TIM_GET_COUNTER(&SDK_DELAY_US_TIMER);
  42. // }
  43. // _HAL_TIM_Base_Stop(&SDK_DELAY_US_TIMER);
  44. // }
  45. // void zdelay_ms(int ms) {
  46. // for (int i = 0; i < ms; i++) {
  47. // zdelay_us(1000);
  48. // }
  49. // }
  50. // void zos_delay_ms(int ms) { osDelay(ms); }
  51. //
  52. // uint32_t zget_ticket(void) { return HAL_GetTick(); }
  53. //
  54. // uint32_t zhas_passedms(uint32_t ticket) {
  55. // uint32_t now = HAL_GetTick();
  56. // if (now >= ticket) {
  57. // return now - ticket;
  58. // } else {
  59. // return 0xFFFFFFFF - ticket + now;
  60. // }
  61. // }