|
@@ -1,15 +1,15 @@
|
|
|
-/* MAX7219 Interaction Code
|
|
|
- * ---------------------------
|
|
|
- * For more information see
|
|
|
- * http://www.adnbr.co.uk/articles/max7219-and-7-segment-displays
|
|
|
+/* MAX7219 Interaction Code
|
|
|
+ * ---------------------------
|
|
|
+ * For more information see
|
|
|
+ * http://www.adnbr.co.uk/articles/max7219-and-7-segment-displays
|
|
|
* ----------------------------------------------------------------------------
|
|
|
* "THE BEER-WARE LICENSE" (Revision 42):
|
|
|
* <shilow@ukr.net> wrote this file. As long as you retain this notice you
|
|
|
* can do whatever you want with this stuff. If we meet some day, and you think
|
|
|
* this stuff is worth it, you can buy me a beer in return. Shilov V.N.
|
|
|
* ----------------------------------------------------------------------------
|
|
|
- */
|
|
|
-
|
|
|
+ */
|
|
|
+
|
|
|
#include "max7219.h"
|
|
|
|
|
|
#define SPI_PORT GPIOB
|
|
@@ -32,36 +32,36 @@ void MAX7219_Init(void) {
|
|
|
SPI_CPOL_High, SPI_CPHA_2Edge, SPI_Direction_1Line_Tx, SPI_NSS_Soft, 0x00);
|
|
|
/* SPI Enable */
|
|
|
SPI_Cmd(SPI1, ENABLE);
|
|
|
-
|
|
|
- /* Настройка MAX71219 */
|
|
|
- MAX7219_WriteData(DecodeMode, 0x00); // все без BCD декодирования
|
|
|
- MAX7219_WriteData(ScanLimit, MAX7219_DIGITS); // сколько цифр используем
|
|
|
- MAX7219_WriteData(Intensity, MAX7219_BRIGHT); // яркость из 16
|
|
|
- MAX7219_WriteData(Power, MAX7219_ON); // включили питание
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-void MAX7219_WriteData(max7219_reg_t reg, uint8_t data)
|
|
|
+
|
|
|
+ /* Настройка MAX71219 */
|
|
|
+ MAX7219_WriteData(DecodeMode, 0x00); // все без BCD декодирования
|
|
|
+ MAX7219_WriteData(ScanLimit, MAX7219_DIGITS); // сколько цифр используем
|
|
|
+ MAX7219_WriteData(Intensity, MAX7219_BRIGHT); // яркость из 16
|
|
|
+ MAX7219_WriteData(Power, MAX7219_ON); // включили питание
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void MAX7219_WriteData(max7219_reg_t reg, uint8_t data)
|
|
|
{
|
|
|
/*!< Wait wait until the completion of the transfer. */
|
|
|
while (SPI_GetFlagStatus(SPI1, SPI_FLAG_BSY) == SET) {}
|
|
|
/* Down LOCK pin */
|
|
|
- GPIO_ReseBits(SPI_PORT, SPI_NSS);
|
|
|
+ GPIO_ResetBits(SPI_PORT, SPI_NSS);
|
|
|
|
|
|
/*!< Wait until the transmit buffer is empty */
|
|
|
while (SPI_GetFlagStatus(SPI1, SPI_FLAG_TXE) == RESET) {}
|
|
|
/* Send the register where the data will be stored */
|
|
|
//SPI_SendData(SPI1, reg);
|
|
|
- SPI1->DR = reg; /* Write in the DR register the data to be sent*/
|
|
|
+ SPI1->DR = reg; /* Write in the DR register the data to be sent*/
|
|
|
|
|
|
/*!< Wait until the transmit buffer is empty */
|
|
|
while (SPI_GetFlagStatus(SPI1, SPI_FLAG_TXE) == RESET) {}
|
|
|
/* Send the data to be stored */
|
|
|
//SPI_SendData(SPI1, data);
|
|
|
- SPI1->DR = data; /* Write in the DR register the data to be sent*/
|
|
|
+ SPI1->DR = data; /* Write in the DR register the data to be sent*/
|
|
|
|
|
|
/*!< Wait wait until the completion of the transfer. */
|
|
|
while (SPI_GetFlagStatus(SPI1, SPI_FLAG_BSY) == SET) {}
|
|
|
/* Up LOCK pin */
|
|
|
- GPIO_SetBits(SPI_PORT, SPI_NSS);
|
|
|
-}
|
|
|
+ GPIO_SetBits(SPI_PORT, SPI_NSS);
|
|
|
+}
|