Bladeren bron

Развёл плату.

Vladimir N. Shilov 9 jaren geleden
bovenliggende
commit
5fd208d37a
5 gewijzigde bestanden met toevoegingen van 19 en 18 verwijderingen
  1. 2 0
      .gitignore
  2. 13 15
      app/max7219.cpp
  3. BIN
      hw/esp-clock.dch
  4. BIN
      hw/esp-clock.dip
  5. 4 3
      include/configuration.h

+ 2 - 0
.gitignore

@@ -2,3 +2,5 @@ out
 language.settings.xml
 .settings
 nbproject
+~*.*
+*.*~

+ 13 - 15
app/max7219.cpp

@@ -14,8 +14,8 @@
 #include "max7219.h"
 
 // çàù¸ëêà
-#define MAX7219_LOAD1			PinSet(PIN_SS)
-#define MAX7219_LOAD0			PinRes(PIN_SS)
+#define MAX7219_LOAD1			PinSet(PIN_LOAD)
+#define MAX7219_LOAD0			PinRes(PIN_LOAD)
 
 #define MAX7219_ON				0x01
 #define MAX7219_OFF				0x00
@@ -26,21 +26,19 @@ const uint8_t max7219_dig[8] = {
 	0x05,0x01,0x07,0x03,0x04,0x08,0x06,0x02
 };
 
-const uint8_t digitsInUse = 8;
-
 // ïðîãðàììíûé SPI. Âûâîäèò áàéò íà÷èíàÿ ñî ñòàðøåãî áèòà
 // âûõîäíûå ïèíû -- SCK, MOSI
 static void spi_SendByte (uint8_t DataByte) {
 	uint8_t i; // ñ÷åò÷èê áèò
 
 	for (i=8; i!=0; i--) {
-		PinRes(PIN_SCK); // âûäàëè ñòðîá
+		PinRes(PIN_CLK); // âûäàëè ñòðîá
 		if (bit_is_set(DataByte,7)) { // åñëè áèò 7 == 1
-			PinSet(PIN_MOSI); // MOSI = 1
+			PinSet(PIN_DIN); // MOSI = 1
 		} else { // åñëè áèò 7 == 0
-			PinRes(PIN_MOSI); // MOSI = 0
+			PinRes(PIN_DIN); // MOSI = 0
 		}
-		PinSet(PIN_SCK); // çàù¸ëêíóëè ñòðîá
+		PinSet(PIN_CLK); // çàù¸ëêíóëè ñòðîá
 		DataByte <<= 1; // ñäâèã âëåâî íà 1 áèò
 	}
 
@@ -58,16 +56,16 @@ void MAX7219_writeData(uint8_t data_register, uint8_t data)
 
 void MAX7219_Init(void) {
 // íàñòðîéêà ïèíîâ SPI
-	pinMode(PIN_SS, OUTPUT);
-	pinMode(PIN_MOSI, OUTPUT);
-	pinMode(PIN_SCK, OUTPUT);
-	PinSet(PIN_SS);
-	PinSet(PIN_MOSI);
-	PinSet(PIN_SCK);
+	pinMode(PIN_LOAD, OUTPUT);
+	pinMode(PIN_DIN, OUTPUT);
+	pinMode(PIN_CLK, OUTPUT);
+	PinSet(PIN_LOAD);
+	PinSet(PIN_DIN);
+	PinSet(PIN_CLK);
 
 //	Íàñòðîéêà MAX71219
 	MAX7219_writeData(MAX7219_MODE_DECODE, 0x00); // âñå áåç BCD äåêîäèðîâàíèÿ
-	MAX7219_writeData(MAX7219_MODE_SCAN_LIMIT, digitsInUse - 1); // Scan limit runs from 0.
+	MAX7219_writeData(MAX7219_MODE_SCAN_LIMIT, MAX7219_DIGITS - 1); // Scan limit runs from 0.
 	MAX7219_writeData(MAX7219_MODE_INTENSITY, MAX7219_BRIGHT); // ÿðêîñòü èç 16
 	MAX7219_writeData(MAX7219_MODE_POWER,MAX7219_ON); // âêëþ÷èëè ïèòàíèå
 

BIN
hw/esp-clock.dch


BIN
hw/esp-clock.dip


+ 4 - 3
include/configuration.h

@@ -22,9 +22,10 @@
 #define CONTROL_PIN 16
 
 // MAX7219
-#define PIN_SCK		14
-#define PIN_MOSI	12
-#define PIN_SS		13
+#define PIN_DIN		14
+#define PIN_CLK		13
+#define PIN_LOAD	12
+#define MAX7219_DIGITS	8
 
 
 #define CLOCK_CONFIG_FILE ".clock.conf" // leading point for security reasons :)