欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5944|回復: 2
打印 上一主題 下一主題
收起左側

ARDUINO PWM庫下載

[復制鏈接]
跳轉到指定樓層
樓主
ARDUINO PWM庫


單片機源程序如下:
  1. /*
  2. This library is built to support two of the AVR Architecture 'groups' that Arduino uses
  3. a) ATmega48/88/168/328,
  4. b) ATmega640/1280/1281/2560/2561
  5. */

  6. #ifndef PWM_H_
  7. #define PWM_H_

  8. #include "avr/pgmspace.h"
  9. #include "math.h"

  10. #if defined(__AVR_ATmega640__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
  11.         #include "utility/ATimerDefs.h"
  12. #elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__)
  13.         #include "utility/BTimerDefs.h"
  14. #endif


  15. #if defined(__AVR_ATmega640__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
  16. // 16 bit timers
  17. extern uint32_t        GetFrequency_16(const int16_t timerOffset);
  18. extern bool                SetFrequency_16(const int16_t timerOffset, uint32_t f);
  19. extern uint16_t GetPrescaler_16(const int16_t timerOffset);
  20. extern void                SetPrescaler_16(const int16_t timerOffset, prescaler psc);
  21. extern void                SetTop_16(const int16_t timerOffset, uint16_t top);
  22. extern uint16_t GetTop_16(const int16_t timerOffset);
  23. extern void                Initialize_16(const int16_t timerOffset);
  24. extern float        GetResolution_16(const int16_t timerOffset);

  25. // 8 bit timers
  26. extern uint32_t        GetFrequency_8(const int16_t timerOffset);
  27. extern bool                SetFrequency_8(const int16_t timerOffset, uint32_t f);
  28. extern uint16_t GetPrescaler_8(const int16_t timerOffset);
  29. extern void                SetPrescaler_8(const int16_t timerOffset, prescaler psc);
  30. extern void                SetPrescalerAlt_8(const int16_t timerOffset, prescaler_alt psc);
  31. extern void                SetTop_8(const int16_t timerOffset, uint8_t top);
  32. extern uint8_t        GetTop_8(const int16_t timerOffset);
  33. extern void                Initialize_8(const int16_t timerOffset);
  34. extern float        GetResolution_8(const int16_t timerOffset);

  35. #endif

  36. #if defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__)

  37. // 16 bit timers
  38. extern uint32_t        GetFrequency_16();
  39. extern bool                SetFrequency_16(uint32_t f);
  40. extern uint16_t GetPrescaler_16();
  41. extern void                SetPrescaler_16(prescaler psc);
  42. extern void                SetTop_16(uint16_t top);
  43. extern uint16_t GetTop_16();
  44. extern void                Initialize_16();
  45. extern float        GetResolution_16();

  46. // 8 bit timers
  47. extern uint32_t        GetFrequency_8(const int16_t timerOffset);
  48. extern bool                SetFrequency_8(const int16_t timerOffset, uint32_t f);
  49. extern uint16_t GetPrescaler_8(const int16_t timerOffset);
  50. extern void                SetPrescaler_8(const int16_t timerOffset, prescaler psc);
  51. extern void                SetPrescalerAlt_8(const int16_t timerOffset, prescaler_alt psc);
  52. extern void                SetTop_8(const int16_t timerOffset, uint8_t top);
  53. extern uint8_t        GetTop_8(const int16_t timerOffset);
  54. extern void                Initialize_8(const int16_t timerOffset);
  55. extern float        GetResolution_8(const int16_t timerOffset);

  56. #endif

  57. //common functions

  58. extern void                InitTimers();
  59. extern void                InitTimersSafe();                                                                                //doesn't init timers responsible for time keeping functions
  60. extern void                pwmWrite(uint8_t pin, uint8_t val);
  61. extern void                pwmWriteHR(uint8_t pin, uint16_t val);                                        //accepts a 16 bit value and maps it down to the timer for maximum resolution
  62. extern bool                SetPinFrequency(int8_t pin, uint32_t frequency);
  63. extern bool                SetPinFrequencySafe(int8_t pin, uint32_t frequency);        //does not set timers responsible for time keeping functions
  64. extern float        GetPinResolution(uint8_t pin);                                                        //gets the PWM resolution of a pin in base 2, 0 is returned if the pin is not connected to a timer

  65. #endif /* PWM_H_ */
復制代碼

所有資料51hei提供下載:
pwm.zip (14.53 KB, 下載次數: 98)


評分

參與人數 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏3 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:614623 發表于 2019-12-14 00:36 | 只看該作者
謝謝分享
回復

使用道具 舉報

板凳
ID:272235 發表于 2019-12-25 11:31 | 只看該作者
為樓主點贊,感謝技術大咖分析好資料!后續多多支持!!!
回復

使用道具 舉報

無效樓層,該帖已經被刪除
5#
無效樓層,該帖已經被刪除
6#
無效樓層,該帖已經被刪除
您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表