AD9249 ADC
Fork of adc_ad9249 by
AD9249.h@2:f300a1dafedc, 2014-10-07 (annotated)
- Committer:
- NickRyder
- Date:
- Tue Oct 07 21:31:16 2014 +0000
- Revision:
- 2:f300a1dafedc
- Parent:
- 1:01459a6ab296
Tidying up.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wbeaumont | 0:9efb460e962b | 1 | #ifndef AD9249_H |
wbeaumont | 0:9efb460e962b | 2 | #define AD9249_H |
wbeaumont | 0:9efb460e962b | 3 | /* interface for controlling the AD9249 ADC , 16 channel ADC Analog Devices |
wbeaumont | 0:9efb460e962b | 4 | |
wbeaumont | 0:9efb460e962b | 5 | -only one CSB line , so assumes the pins CSB1 and CSB2 are connected together . |
wbeaumont | 0:9efb460e962b | 6 | -only MSB mode is supported, so configuration register MSB is set at the start. |
wbeaumont | 0:9efb460e962b | 7 | |
wbeaumont | 0:9efb460e962b | 8 | |
wbeaumont | 0:9efb460e962b | 9 | W. Beaumont |
wbeaumont | 0:9efb460e962b | 10 | (C) Universiteit Antwerpen 27 August 2014 |
wbeaumont | 0:9efb460e962b | 11 | |
wbeaumont | 0:9efb460e962b | 12 | */ |
wbeaumont | 1:01459a6ab296 | 13 | |
wbeaumont | 1:01459a6ab296 | 14 | #define AD9249_HDR_VER "1.22" |
wbeaumont | 1:01459a6ab296 | 15 | #include "getVersion.h" |
wbeaumont | 1:01459a6ab296 | 16 | |
wbeaumont | 0:9efb460e962b | 17 | class SWSPI_BI; |
wbeaumont | 0:9efb460e962b | 18 | //class DigitalIn; |
wbeaumont | 0:9efb460e962b | 19 | |
wbeaumont | 1:01459a6ab296 | 20 | class AD9249: public getVersion { |
wbeaumont | 0:9efb460e962b | 21 | typedef unsigned char u8; |
wbeaumont | 0:9efb460e962b | 22 | typedef unsigned int u32; |
wbeaumont | 0:9efb460e962b | 23 | typedef unsigned short u16; |
wbeaumont | 0:9efb460e962b | 24 | // address defs |
NickRyder | 2:f300a1dafedc | 25 | static const u16 configreg = 0x0; |
NickRyder | 2:f300a1dafedc | 26 | static const u16 chip_id_reg = 0x1; |
NickRyder | 2:f300a1dafedc | 27 | static const u16 chip_grade_reg = 0x2; |
wbeaumont | 0:9efb460e962b | 28 | // static const u16 unused_reg= { 0x3, 0x07, 0xA, 0xE, 0xF ,0x11, 0x12,0x13, 0x17, 0x1D, 0x1E, 0x1F,0x20 }; |
NickRyder | 2:f300a1dafedc | 29 | static const u16 dev_index2_reg = 0x4; |
NickRyder | 2:f300a1dafedc | 30 | static const u16 dev_index1_reg = 0x4; |
NickRyder | 2:f300a1dafedc | 31 | static const u16 transfer_reg = 0xFF; |
NickRyder | 2:f300a1dafedc | 32 | static const u16 power_mode_reg = 0x8; |
NickRyder | 2:f300a1dafedc | 33 | static const u16 clock_gobal_reg = 0x9; |
NickRyder | 2:f300a1dafedc | 34 | static const u16 clock_divide_reg = 0xB; |
NickRyder | 2:f300a1dafedc | 35 | static const u16 enhancement_ctr_reg = 0xC; |
NickRyder | 2:f300a1dafedc | 36 | static const u16 test_mode_reg = 0xD; |
NickRyder | 2:f300a1dafedc | 37 | static const u16 offset_adj_reg = 0x10; |
NickRyder | 2:f300a1dafedc | 38 | static const u16 output_mode_reg = 0x14; |
NickRyder | 2:f300a1dafedc | 39 | static const u16 output_adj_reg = 0x15; |
NickRyder | 2:f300a1dafedc | 40 | static const u16 output_phase_reg = 0x16; |
NickRyder | 2:f300a1dafedc | 41 | static const u16 vref_reg = 0x18; |
NickRyder | 2:f300a1dafedc | 42 | static const u16 usserpatt1_LSB_reg = 0x19; |
NickRyder | 2:f300a1dafedc | 43 | static const u16 usserpatt1_MSB_reg = 0x1A; |
NickRyder | 2:f300a1dafedc | 44 | static const u16 usserpatt2_LSB_reg = 0x1B; |
NickRyder | 2:f300a1dafedc | 45 | static const u16 usserpatt2_MSB_reg = 0x1C; |
NickRyder | 2:f300a1dafedc | 46 | static const u16 serial_out_cntr_reg = 0x21; |
NickRyder | 2:f300a1dafedc | 47 | static const u16 serial_status_reg = 0x22; |
NickRyder | 2:f300a1dafedc | 48 | static const u16 sample_rate_reg = 0x100; |
NickRyder | 2:f300a1dafedc | 49 | static const u16 user_io_ctr2_reg = 0x101; |
NickRyder | 2:f300a1dafedc | 50 | static const u16 user_io_ctr3_reg = 0x102; |
NickRyder | 2:f300a1dafedc | 51 | static const u16 sync_reg = 0x109; |
wbeaumont | 0:9efb460e962b | 52 | |
NickRyder | 2:f300a1dafedc | 53 | u32 spi_cycle(u16 reg, bool rw, u16 nrbytes, u32 data); |
NickRyder | 2:f300a1dafedc | 54 | SWSPI_BI * spi; |
NickRyder | 2:f300a1dafedc | 55 | DigitalOut * csb; |
NickRyder | 2:f300a1dafedc | 56 | public: |
NickRyder | 2:f300a1dafedc | 57 | AD9249(SWSPI_BI * spi_dev, DigitalOut * csb_dev); |
NickRyder | 2:f300a1dafedc | 58 | bool getDevInfo(u8& chipid, u8& grade, u16& rb); |
NickRyder | 2:f300a1dafedc | 59 | bool getDevId(u8& chipid); |
NickRyder | 2:f300a1dafedc | 60 | bool getGrade(u8& grade); |
NickRyder | 2:f300a1dafedc | 61 | bool setPattern1(u16 pattern); |
NickRyder | 2:f300a1dafedc | 62 | bool setPattern2(u16 pattern); |
NickRyder | 2:f300a1dafedc | 63 | bool readPattern1(u16& pattern); |
NickRyder | 2:f300a1dafedc | 64 | bool readPattern2(u16& pattern); |
NickRyder | 2:f300a1dafedc | 65 | //general read write |
NickRyder | 2:f300a1dafedc | 66 | bool setReg16(u16 regaddr, u16 data); |
NickRyder | 2:f300a1dafedc | 67 | bool setReg8(u16 regaddr, u8 data); |
NickRyder | 2:f300a1dafedc | 68 | bool readReg16(u16 regaddr, u16& data); |
NickRyder | 2:f300a1dafedc | 69 | bool readReg8(u16 regaddr, u8& data); |
NickRyder | 2:f300a1dafedc | 70 | void init1(); |
NickRyder | 2:f300a1dafedc | 71 | void init2(); |
wbeaumont | 0:9efb460e962b | 72 | }; |
wbeaumont | 0:9efb460e962b | 73 | |
NickRyder | 2:f300a1dafedc | 74 | #endif |