12-Channel LED Driver With Gray scale Adaptive Pulse Density Modulation Control IC Library. maker MY-Semi

Dependents:   Library_MY9221

Files at this revision

API Documentation at this revision

Comitter:
suupen
Date:
Thu Oct 19 05:28:32 2017 +0000
Child:
1:60440eb16f81
Commit message:
library?????main.cpp????????????????

Changed in this revision

MY9221.cpp Show annotated file Show diff for this revision Revisions of this file
MY9221.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MY9221.cpp	Thu Oct 19 05:28:32 2017 +0000
@@ -0,0 +1,35 @@
+/**
+ * MY9221 Library
+ */
+
+#include "mbed.h" 
+#include "MY9221.h"
+ 
+/**
+ *
+ */
+MY9221::MY9221(PinName di, PinName dcki, uint8_t number
+                    ) : _di(di), _dcki(dcki), _number(number)
+{
+ 
+    // 変数初期化 ,マイコン機能の設定
+    _di = 0;
+    _dcki = 0; 
+
+/*
+    _onEdge = 0;
+    _offEdge = 0;
+    _levelNow = 1;
+    _levelOld = 1;
+ 
+    if(_pull == 1) {
+        _sw.mode(PullUp);
+    } else {
+        _sw.mode(PullDown);
+    }
+    
+    _sw.rise(this, &DigitalSw::swLevelUp);
+    _sw.fall(this, &DigitalSw::swLevelDown);
+*/ 
+ 
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MY9221.h	Thu Oct 19 05:28:32 2017 +0000
@@ -0,0 +1,148 @@
+#ifndef MBED_MY9221_H
+#define MBED_MY9221_H
+ 
+#include "mbed.h"
+#include "MY9221.h"
+
+
+/**
+ * LED driver MY9221
+ */
+
+
+/**
+ *  @class MY9221
+ *  @brief nothine
+ */
+class MY9221
+{
+ 
+public:
+ 
+    /** Create a MY9221 port, connected to the specified IC pins
+     *  @param DI pin
+     *  @param DCKI pin
+     *  @param IC serial connection number :min = 1(default)
+     *  @note  nothing
+     */
+    MY9221(PinName di, PinName dcki, uint8_t number = 1);
+ 
+    /**
+     * start of driver.
+     */
+    void start(void);
+
+    /**
+     * stop of driver.
+     */
+    void stop(void);
+ 
+    /**
+     * clear of data.
+     */
+    void dataClear(void);
+
+    /**
+     * set of commant
+     * @param uint16_t command MY9221 commandset
+     */
+    void commandSet(uint16_t command);
+
+//=========================
+// command data description
+//=========================
+// 0x0000にクリアした上で、下記の定義をorしていく
+
+// CMD[10] 0000 0x00 0000 0000  lout Tr/Tf select
+#define LOUT_SLOW_MODE (0x0000)
+#define LOUT_FAST_MODE (0x0400)
+
+// CMD[9:8] 0000 00xx 0000 0000  Gryascale resolution select
+#define GRAYSCALE_8BIT  (0x0000)
+#define GRAYSCALE_12BIT (0x0100)
+#define GRAYSCALE_14BIT (0x0200)
+#define GRAYSCALE_16BIT (0x0300)
+
+// CMD[7:5] 0000 0000 xxx0 0000  Internal oscillator freq select
+#define ORIGINAL_FREQ1      (0x0000)
+#define ORIGINAL_FREQ2      (0x0020)
+#define ORIGINAL_FREQ4      (0x0040)
+#define ORIGINAL_FREQ8      (0x0060)
+#define ORIGINAL_FREQ16     (0x0080)
+#define ORIGINAL_FREQ64     (0x00a0)
+#define ORIGINAL_FREQ128    (0x00c0)
+#define ORIGINAL_FREQ256    (0x00e0)
+
+// CMD[4] 0000 0000 000x 0000  Output waveform select
+#define WAVE_MYPWM    (0x0000)   // Only Grayscale = 8bit
+#define WAVE_APDM     (0x0010)
+
+// CMD[3] 0000 0000 0000 x000  Grayscale clock source select
+#define GCLOCK_INTERNAL   (0x0000)
+#define GCLOCK_EXTERNAL   (0x0008)
+
+// CMD[2] 0000 0000 0000 0x00  Output polarity select
+#define WORK_LED   (0x0000)
+#define WORK_MYPWM (0x0004)
+
+// CMD[1] 0000 0000 0000 00x0  Counter reset select
+#define COUNTER_FREE   (0x0000)
+#define COUNTER_RESET  (0x0002)
+
+// CMD[0] 0000 0000 0000 000x  One-shot select
+#define SHOT_REPEAT   (0x0000)
+#define SHOT_SHOT     (0x0001)
+
+// commandData_t D[]の配列番号
+// MY9221のOUTxの番号と配列番号をあわせるための定義
+#define OUT3 (0)
+#define OUT2 (1)
+#define OUT1 (2)
+#define OUT0 (3)
+
+//=========================
+// MY9221 command data 定義
+//=========================
+typedef struct {
+    uint16_t DA;
+    uint16_t DB;
+    uint16_t DC;
+} dataSet_t;
+
+typedef struct {
+    uint16_t CMD;
+    dataSet_t D[4]; // [0]:OUT3 [1]:OUT2 [2]:OUT1 [3]:OUT0
+} commandData_t;
+
+
+
+//----------------------------------------------------------
+private:
+ 
+/** send one word data
+ * @param uint16_t data : send data
+ * @param return none
+ */
+void sendWord(uint16_t data);
+
+/** data latch & display
+ * @param none
+ * @param return none
+ */
+void latch(void);
+
+    DigitalOut _di;
+    DigitalOut _dcki;
+    
+ 
+    int8_t _number;
+ 
+ /*
+    volatile int16_t _onEdge;
+    volatile int16_t _offEdge;
+    volatile int16_t _levelNow;
+    volatile int16_t _levelOld;
+ */
+};
+ 
+#endif  //  MBED_PCA9547_H
\ No newline at end of file