Junichi Katsu
/
LineFollow2
ライントレーサPD制御 ロボット製作セミナー演習ex
HighSpeedAnalogIn/HighSpeedAnalogIn.h@0:b5d91230ff3c, 2013-08-10 (annotated)
- Committer:
- jksoft
- Date:
- Sat Aug 10 04:13:15 2013 +0000
- Revision:
- 0:b5d91230ff3c
Rev1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 0:b5d91230ff3c | 1 | #ifndef HIGH_SPEED_ANALOG_IN_H |
jksoft | 0:b5d91230ff3c | 2 | #define HIGH_SPEED_ANALOG_IN_H |
jksoft | 0:b5d91230ff3c | 3 | |
jksoft | 0:b5d91230ff3c | 4 | #include "mbed.h" |
jksoft | 0:b5d91230ff3c | 5 | |
jksoft | 0:b5d91230ff3c | 6 | class HighSpeedAnalogIn { |
jksoft | 0:b5d91230ff3c | 7 | public: |
jksoft | 0:b5d91230ff3c | 8 | |
jksoft | 0:b5d91230ff3c | 9 | HighSpeedAnalogIn(PinName pin0, PinName pin1 = NC, PinName pin2 = NC, PinName pin3 = NC, PinName pin4 = NC, PinName pin5 = NC); |
jksoft | 0:b5d91230ff3c | 10 | ~HighSpeedAnalogIn(); |
jksoft | 0:b5d91230ff3c | 11 | float read(PinName pin); |
jksoft | 0:b5d91230ff3c | 12 | unsigned short read_u16(PinName pin); |
jksoft | 0:b5d91230ff3c | 13 | |
jksoft | 0:b5d91230ff3c | 14 | private: |
jksoft | 0:b5d91230ff3c | 15 | |
jksoft | 0:b5d91230ff3c | 16 | HighSpeedAnalogIn(); |
jksoft | 0:b5d91230ff3c | 17 | uint32_t _adc_data[8]; |
jksoft | 0:b5d91230ff3c | 18 | |
jksoft | 0:b5d91230ff3c | 19 | static const int XTAL_FREQ = 12000000; |
jksoft | 0:b5d91230ff3c | 20 | static const int MAX_ADC_CLOCK = 13000000; |
jksoft | 0:b5d91230ff3c | 21 | static const int CLKS_PER_SAMPLE = 64; |
jksoft | 0:b5d91230ff3c | 22 | |
jksoft | 0:b5d91230ff3c | 23 | static HighSpeedAnalogIn *instance; |
jksoft | 0:b5d91230ff3c | 24 | static int refcnt; |
jksoft | 0:b5d91230ff3c | 25 | |
jksoft | 0:b5d91230ff3c | 26 | static void static_adcisr(void); |
jksoft | 0:b5d91230ff3c | 27 | |
jksoft | 0:b5d91230ff3c | 28 | int get_channel(PinName pin); |
jksoft | 0:b5d91230ff3c | 29 | uint32_t get_data(PinName pin); |
jksoft | 0:b5d91230ff3c | 30 | void adcisr(void); |
jksoft | 0:b5d91230ff3c | 31 | void setup(PinName pin, int state); |
jksoft | 0:b5d91230ff3c | 32 | void interrupt_state(PinName pin, int state); |
jksoft | 0:b5d91230ff3c | 33 | }; |
jksoft | 0:b5d91230ff3c | 34 | |
jksoft | 0:b5d91230ff3c | 35 | #endif |