ARCS6 AR6-REV.24062600
読み取り中…
検索中…
一致する文字列を見つけられません
PCI-6205C.hh
[詳解]
1
8//
9// Copyright (C) 2011-2020 Yuki YOKOKURA
10// This program is free software;
11// you can redistribute it and/or modify it under the terms of the FreeBSD License.
12// For details, see the License.txt file.
13
14#ifndef PCI_6205C
15#define PCI_6205C
16
17#include <sys/io.h>
18#include <unistd.h>
19#include <stdint.h>
20#include <algorithm>
21#include <array>
22
23namespace ARCS { // ARCS名前空間
25 class PCI6205C {
26 public:
27 PCI6205C(const unsigned int Addr0, const unsigned int Addr1, const unsigned int Addr2, const unsigned int Addr3,
28 unsigned int NumOfChannel, bool Mult4Mode);
29 PCI6205C();
30 ~PCI6205C();
31 static const unsigned int MAX_CH = 8;
32
33 void ZpulseClear(bool flag);
34 void GetCount(long count[MAX_CH]);
35 void GetCount(std::array<long, MAX_CH>& count);
36 void ClearAllCounter(void);
37 void ClearUpperCounter(void);
38
39 private:
40 PCI6205C(const PCI6205C&) = delete;
41 const PCI6205C& operator=(const PCI6205C&) = delete;
42 const unsigned int NUM_CH;
43 const unsigned int ADDR_BASE0;
44 const unsigned int ADDR_BASE1;
45 const unsigned int ADDR_BASE2;
46 const unsigned int ADDR_BASE3;
47 unsigned int ADDR_COUNTER_LO[MAX_CH];
48 unsigned int ADDR_COUNTER_MD[MAX_CH];
49 unsigned int ADDR_COUNTER_HI[MAX_CH];
50 unsigned int ADDR_WRITEREG[MAX_CH];
51 unsigned int ADDR_STATUS[MAX_CH];
52 uint8_t StatusReg[MAX_CH];
53 long CountPrev[MAX_CH];
54 long UpperCount[MAX_CH];
55 bool IsUsedZpulse;
56
57 void Settings(bool Mult4Mode); // エンコーダカウンタの設定を行う関数
58 long GetEncData(unsigned int ch); // エンコーダカウント値を取得する関数
59 void SetEncData(long count, unsigned int ch); // エンコーダカウント値を設定する関数
60 void SetCompData(long count, unsigned int ch); // 比較レジスタにカウント値を設定する関数
61 void ReadStatusReg(void); // ステータスレジスタを読み込む関数 注意!:この関数は制御周期中に1回だけ呼び出すこと。
62 bool GetDirectionFlag(unsigned int ch); // 回転方向を返す関数 true=正方向, false=負方向
63 bool GetCarryBorrowFlag(unsigned int ch); // キャリー/ボローフラグを読み込んで返す関数 注意!:この関数を呼ぶ前に ReadStatusReg() を呼び出さないと最新の状態は得られない。
64 bool GetEquDetectionFlag(unsigned int ch); // カウント値比較検出フラグを読み込んで返す関数
65 void LatchCounter(void); // エンコーダカウンタを読み出しレジスタに移動(ラッチ)
66 void SelectCounter(unsigned int ch); // カウンタを選択する関数
67 void SelectComparator(unsigned int ch); // 比較レジスタを選択する関数
68 static long ProcessCounterSign(long count); // カウンタの符号処理
69 long ProcessUpperCount(long count, unsigned int ch); // 上位カウンタの処理
70 static unsigned long IIIbyteCat(unsigned short High, unsigned short Middle, unsigned short Low);// 上位、中位、下位に分かれている各々1バイトのデータを、3バイトのデータに結合する関数
71 static uint8_t Get4byteHiHi(uint32_t in); // 4byteデータの上位1byteを抽出して出力
72 static uint8_t Get4byteHiLo(uint32_t in); // 4byteデータの中上位1byteを抽出して出力
73 static uint8_t Get4byteLoHi(uint32_t in); // 4byteデータの中下位1byteを抽出して出力
74 static uint8_t Get4byteLoLo(uint32_t in); // 4byteデータの下位1byteを抽出して出力
75 static bool GetBitStatus(uint8_t in, uint8_t bit); // ビットの状態を返す関数 in : 変数, bit : ビット位置, 戻り値 true=1, false=0
76 };
77}
78
79#endif
80
PCI-6205C入出力クラス
Definition PCI-6205C.hh:25
void ClearUpperCounter(void)
上位カウンタをクリアする関数
Definition PCI-6205C.cc:195
void ClearAllCounter(void)
エンコーダカウンタの値を零(0x000000)にする関数
Definition PCI-6205C.cc:189
void GetCount(long count[MAX_CH])
エンコーダカウンタからカウント値を読み込む関数(生配列版)
Definition PCI-6205C.cc:169
void ZpulseClear(bool flag)
Z相クリア設定
Definition PCI-6205C.cc:144
PCI6205C()
空コンストラクタ
Definition PCI-6205C.cc:86
~PCI6205C()
デストラクタ(ENC終了処理)
Definition PCI-6205C.cc:95
static const unsigned int MAX_CH
チャネル最大値
Definition PCI-6205C.hh:31