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:
Wed Nov 28 06:43:18 2018 +0000
Branch:
document_branch
Revision:
6:96df8bca04c4
Parent:
5:a601936990ea
neko

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 3:ac9dea7bfe0a 50 /** Constructor
aktk 0:26eea8042420 51 *
aktk 5:a601936990ea 52 * \param (const int arg_num_of_board = 1) 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 3:ac9dea7bfe0a 57 *
aktk 3:ac9dea7bfe0a 58 * This is curried in constructor.
aktk 3:ac9dea7bfe0a 59 * In this function, all output pins are set as L (ALL GROUND),
aktk 3:ac9dea7bfe0a 60 * and Porarity (POL) is set to 1 (nomal mode; in other words,
aktk 3:ac9dea7bfe0a 61 * data in latches of HV507 is reflected to output as is.
aktk 3:ac9dea7bfe0a 62 * If POL = 0, the output is inverted data (inverse mode).
aktk 0:26eea8042420 63 */
aktk 0:26eea8042420 64 void init();
aktk 0:26eea8042420 65
aktk 3:ac9dea7bfe0a 66 /** Set a stim bit.
aktk 3:ac9dea7bfe0a 67 *
aktk 3:ac9dea7bfe0a 68 * Set one high bit (1) this is regarded as stim bit.
aktk 3:ac9dea7bfe0a 69 */
aktk 0:26eea8042420 70 void setHtoSR();
aktk 3:ac9dea7bfe0a 71
aktk 3:ac9dea7bfe0a 72 /** Set a ground bit
aktk 3:ac9dea7bfe0a 73 *
aktk 3:ac9dea7bfe0a 74 * Set one low bit (0) this is regarded as ground bit.
aktk 3:ac9dea7bfe0a 75 * If shifting the register many times, it is recommended to use
aktk 3:ac9dea7bfe0a 76 * shiftSRBits_by().
aktk 3:ac9dea7bfe0a 77 */
aktk 0:26eea8042420 78 void setLtoSR();
aktk 0:26eea8042420 79
aktk 0:26eea8042420 80 /** Function to shift data only index-incresing-direction
aktk 0:26eea8042420 81 *
aktk 5:a601936990ea 82 * \param (int arg_num_shifting) stimulation point
aktk 0:26eea8042420 83 */
aktk 0:26eea8042420 84 void shiftSRBits_by(int arg_num_shifting);
aktk 0:26eea8042420 85
aktk 0:26eea8042420 86 /** Fill all with zero (ground)
aktk 0:26eea8042420 87 */
aktk 0:26eea8042420 88 void clearSR();
aktk 0:26eea8042420 89
aktk 3:ac9dea7bfe0a 90 /** Function to define ONE stimulation point
aktk 3:ac9dea7bfe0a 91 *
aktk 5:a601936990ea 92 * \param (const int arg_ch) the pin number supposed to be a stim pin.
aktk 3:ac9dea7bfe0a 93 */
aktk 0:26eea8042420 94 void setCh(const int arg_ch);
aktk 0:26eea8042420 95
aktk 3:ac9dea7bfe0a 96 /** Function to store data in shift register to latches.
aktk 3:ac9dea7bfe0a 97 *
aktk 3:ac9dea7bfe0a 98 * This is called in setCh. But if you need to use other function to deal
aktk 3:ac9dea7bfe0a 99 * the shift rester, you should call this function to output the data.
aktk 3:ac9dea7bfe0a 100 */
aktk 0:26eea8042420 101 void updateLatches();
aktk 3:ac9dea7bfe0a 102
aktk 0:26eea8042420 103 void DEBUG_ALLPIN_ON();
aktk 0:26eea8042420 104 void DEBUG_ALLPIN_OFF();
aktk 0:26eea8042420 105
aktk 0:26eea8042420 106 private:
aktk 0:26eea8042420 107 // HV507 Logical Pins
aktk 0:26eea8042420 108 // Logical Pins Array = (DIOB, CLK, LE, BL, POL)
aktk 0:26eea8042420 109 DigitalOut m_DIOB; ///< Pin to transfer Data input to HV507
aktk 0:26eea8042420 110 DigitalOut m_BL; ///< Pin to transfer signal !BL(not-Blaker)
aktk 0:26eea8042420 111 DigitalOut m_POL; ///< Pin to transfer signal !POL(not-Pole signal)
aktk 0:26eea8042420 112 DigitalOut m_CLK; ///< Pin to transfer signal Clock
aktk 0:26eea8042420 113 DigitalOut m_LE; ///< Pin to transfer signal !LE(not-Latch Enable)
aktk 0:26eea8042420 114
aktk 0:26eea8042420 115 /** The number of all pins including in Hv507 boards.
aktk 0:26eea8042420 116 * This is culculated in a constructor
aktk 0:26eea8042420 117 */
aktk 0:26eea8042420 118 const int m_num_pins;
aktk 0:26eea8042420 119
aktk 0:26eea8042420 120 /** The constant number that expresses the number of output pins in a HV507
aktk 0:26eea8042420 121 */
aktk 0:26eea8042420 122 //enum :int {HV507_NUM_PINS = 64};
aktk 0:26eea8042420 123 static const int HV507_NUM_PINS = 64;
aktk 3:ac9dea7bfe0a 124
aktk 0:26eea8042420 125 /** The variable expressing the postion of stimulation point
aktk 0:26eea8042420 126 *
aktk 0:26eea8042420 127 * - 0 : No stimulationpoint
aktk 0:26eea8042420 128 * - 1 ~ (HV507_PIN_NUM * m_num_of_board): a stimulation point;
aktk 0:26eea8042420 129 * if the number of stim points are over than 1, this var means
aktk 0:26eea8042420 130 * the last one.
aktk 0:26eea8042420 131 */
aktk 0:26eea8042420 132 int m_pos_stim;
aktk 0:26eea8042420 133
aktk 0:26eea8042420 134
aktk 0:26eea8042420 135 void putSRCLKahead();
aktk 0:26eea8042420 136 };
aktk 0:26eea8042420 137 #endif