This is a library to use HV507 boards as a switching circuitry which is a module used with an electrical stimulator made by kaji-lab.
KajiLabHV507B.h@0:26eea8042420, 2018-11-27 (annotated)
- Committer:
- aktk
- Date:
- Tue Nov 27 21:25:41 2018 +0000
- Revision:
- 0:26eea8042420
- Child:
- 1:f7d6fbcb3bca
Ver2.0; modified to c++ like. (made it available to use HV507 Board as an object in program)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aktk | 0:26eea8042420 | 1 | /** |
aktk | 0:26eea8042420 | 2 | * \file "KajiLabHV507B.h" |
aktk | 0:26eea8042420 | 3 | * \Author Akifumi TAKAHASHI |
aktk | 0:26eea8042420 | 4 | * \breif Functions are divided from Associate Prof. Kajimoto's program, |
aktk | 0:26eea8042420 | 5 | * simple communication. |
aktk | 0:26eea8042420 | 6 | * \details This program is for using HV507(Shift Register Chip Circuit) for |
aktk | 0:26eea8042420 | 7 | * electric stimulation. The base Program had been written by Kajimoto Hiroyuki. |
aktk | 0:26eea8042420 | 8 | * \date 2015/Jul/16th Ver.1 |
aktk | 0:26eea8042420 | 9 | * \date 2018/Nov/27th Ver.2 Simplified as a pure channel switching program. |
aktk | 0:26eea8042420 | 10 | */ |
aktk | 0:26eea8042420 | 11 | #ifndef MBED_HV507DRIVER_H |
aktk | 0:26eea8042420 | 12 | #define MBED_HV507DRIVER_H |
aktk | 0:26eea8042420 | 13 | |
aktk | 0:26eea8042420 | 14 | #include "mbed.h" |
aktk | 0:26eea8042420 | 15 | |
aktk | 0:26eea8042420 | 16 | /* -------------------------------------------------------------------------------------------------------- |
aktk | 0:26eea8042420 | 17 | * HV507 Function table |
aktk | 0:26eea8042420 | 18 | * -------------------------------------------------------------------------------------------------------- |
aktk | 0:26eea8042420 | 19 | * Function Input Output |
aktk | 0:26eea8042420 | 20 | * Data CLK !LE !BL !POL DIR Shift Reg HV Out Data Out |
aktk | 0:26eea8042420 | 21 | * 1 2~64 1 2-64 |
aktk | 0:26eea8042420 | 22 | * ======================================================================================================== |
aktk | 0:26eea8042420 | 23 | * All on X X X L L X * *~* H H-H * |
aktk | 0:26eea8042420 | 24 | * |
aktk | 0:26eea8042420 | 25 | * All off X X X L H X * *~* L L-L * |
aktk | 0:26eea8042420 | 26 | * |
aktk | 0:26eea8042420 | 27 | * Invert mode X X L H L X * *~* !* !*~!* * |
aktk | 0:26eea8042420 | 28 | * -------------------------------------------------------------------------------------------------------- |
aktk | 0:26eea8042420 | 29 | * Load S/R H or L up L H H X H or L *~* * *~* * |
aktk | 0:26eea8042420 | 30 | * |
aktk | 0:26eea8042420 | 31 | * Store data X X down H H X * *~* * *~* * |
aktk | 0:26eea8042420 | 32 | * in latches X X down H L X * *~* !* !*~!* * |
aktk | 0:26eea8042420 | 33 | * |
aktk | 0:26eea8042420 | 34 | * Transparent L up H H H X L *~* L *~* * |
aktk | 0:26eea8042420 | 35 | * latch mode H up H H H X H *~* H *~* * |
aktk | 0:26eea8042420 | 36 | * -------------------------------------------------------------------------------------------------------- |
aktk | 0:26eea8042420 | 37 | * I/O Relation DIOA up X X X L Qn -> Qn+1 - DIOB |
aktk | 0:26eea8042420 | 38 | * DIOB up X X X H Qn -> Qn+1 - DOIA |
aktk | 0:26eea8042420 | 39 | */ |
aktk | 0:26eea8042420 | 40 | |
aktk | 0:26eea8042420 | 41 | class HV507 |
aktk | 0:26eea8042420 | 42 | { |
aktk | 0:26eea8042420 | 43 | public: |
aktk | 0:26eea8042420 | 44 | /** Construction |
aktk | 0:26eea8042420 | 45 | * |
aktk | 0:26eea8042420 | 46 | * \Pram arg_num_of_board the number of Hv507 board. |
aktk | 0:26eea8042420 | 47 | */ |
aktk | 0:26eea8042420 | 48 | HV507(const int arg_num_board = 1); |
aktk | 0:26eea8042420 | 49 | |
aktk | 0:26eea8042420 | 50 | /** HV507 initialization |
aktk | 0:26eea8042420 | 51 | */ |
aktk | 0:26eea8042420 | 52 | void init(); |
aktk | 0:26eea8042420 | 53 | |
aktk | 0:26eea8042420 | 54 | void setHtoSR(); |
aktk | 0:26eea8042420 | 55 | void setLtoSR(); |
aktk | 0:26eea8042420 | 56 | |
aktk | 0:26eea8042420 | 57 | /** Function to shift data only index-incresing-direction |
aktk | 0:26eea8042420 | 58 | * |
aktk | 0:26eea8042420 | 59 | * \Pram arg_ch stimulation point |
aktk | 0:26eea8042420 | 60 | */ |
aktk | 0:26eea8042420 | 61 | void shiftSRBits_by(int arg_num_shifting); |
aktk | 0:26eea8042420 | 62 | |
aktk | 0:26eea8042420 | 63 | /** Fill all with zero (ground) |
aktk | 0:26eea8042420 | 64 | */ |
aktk | 0:26eea8042420 | 65 | void clearSR(); |
aktk | 0:26eea8042420 | 66 | |
aktk | 0:26eea8042420 | 67 | void setCh(const int arg_ch); |
aktk | 0:26eea8042420 | 68 | |
aktk | 0:26eea8042420 | 69 | void updateLatches(); |
aktk | 0:26eea8042420 | 70 | void DEBUG_ALLPIN_ON(); |
aktk | 0:26eea8042420 | 71 | void DEBUG_ALLPIN_OFF(); |
aktk | 0:26eea8042420 | 72 | |
aktk | 0:26eea8042420 | 73 | private: |
aktk | 0:26eea8042420 | 74 | // HV507 Logical Pins |
aktk | 0:26eea8042420 | 75 | // Logical Pins Array = (DIOB, CLK, LE, BL, POL) |
aktk | 0:26eea8042420 | 76 | DigitalOut m_DIOB; ///< Pin to transfer Data input to HV507 |
aktk | 0:26eea8042420 | 77 | DigitalOut m_BL; ///< Pin to transfer signal !BL(not-Blaker) |
aktk | 0:26eea8042420 | 78 | DigitalOut m_POL; ///< Pin to transfer signal !POL(not-Pole signal) |
aktk | 0:26eea8042420 | 79 | DigitalOut m_CLK; ///< Pin to transfer signal Clock |
aktk | 0:26eea8042420 | 80 | DigitalOut m_LE; ///< Pin to transfer signal !LE(not-Latch Enable) |
aktk | 0:26eea8042420 | 81 | |
aktk | 0:26eea8042420 | 82 | /** The number of all pins including in Hv507 boards. |
aktk | 0:26eea8042420 | 83 | * This is culculated in a constructor |
aktk | 0:26eea8042420 | 84 | */ |
aktk | 0:26eea8042420 | 85 | const int m_num_pins; |
aktk | 0:26eea8042420 | 86 | |
aktk | 0:26eea8042420 | 87 | /** The constant number that expresses the number of output pins in a HV507 |
aktk | 0:26eea8042420 | 88 | */ |
aktk | 0:26eea8042420 | 89 | //enum :int {HV507_NUM_PINS = 64}; |
aktk | 0:26eea8042420 | 90 | static const int HV507_NUM_PINS = 64; |
aktk | 0:26eea8042420 | 91 | /** The variable expressing the postion of stimulation point |
aktk | 0:26eea8042420 | 92 | * |
aktk | 0:26eea8042420 | 93 | * - 0 : No stimulationpoint |
aktk | 0:26eea8042420 | 94 | * - 1 ~ (HV507_PIN_NUM * m_num_of_board): a stimulation point; |
aktk | 0:26eea8042420 | 95 | * if the number of stim points are over than 1, this var means |
aktk | 0:26eea8042420 | 96 | * the last one. |
aktk | 0:26eea8042420 | 97 | */ |
aktk | 0:26eea8042420 | 98 | int m_pos_stim; |
aktk | 0:26eea8042420 | 99 | |
aktk | 0:26eea8042420 | 100 | |
aktk | 0:26eea8042420 | 101 | void putSRCLKahead(); |
aktk | 0:26eea8042420 | 102 | }; |
aktk | 0:26eea8042420 | 103 | #endif |