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.

Committer:
aktk
Date:
Tue Nov 27 21:43:00 2018 +0000
Revision:
2:1c2e272dc40f
Parent:
1:f7d6fbcb3bca
Child:
3:ac9dea7bfe0a
add HV507 class comment;

Who changed what in which revision?

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