1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- /* 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"
- void MAX7219_Config(void) {
- /* Настройка MAX71219 */
- MAX7219_WriteData(RegDecodeMode, 0x00); // все без BCD декодирования
- MAX7219_WriteData(RegScanLimit, MAX7219_DIGITS); // сколько цифр используем
- MAX7219_WriteData(RegIntensity, MAX7219_BRIGHT); // яркость из 16
- MAX7219_WriteData(RegPower, MAX7219_ON); // включили питание
- }
- void MAX7219_WriteData(max7219_reg_t reg, uint8_t data) {
- /*!< Wait wait until the completion of the transfer. */
- while ((SPI->SR & 0x80) != RESET);
- /* Down LOAD pin */
- SPI_LOAD_PORT->ODR &= ~(SPI_LOAD);
- /*!< Wait until the transmit buffer is empty */
- while ((SPI->SR & 0x02) == RESET);
- /* Send the register where the data will be stored */
- SPI->DR = reg; /* Write in the DR register the data to be sent*/
- /*!< Wait until the transmit buffer is empty */
- while ((SPI->SR & 0x02) == RESET);
- /* Send the data to be stored */
- SPI->DR = data; /* Write in the DR register the data to be sent*/
- /*!< Wait wait until the completion of the transfer. */
- while ((SPI->SR & 0x80) != RESET);
- /* Up LOAD pin */
- SPI_LOAD_PORT->ODR |= SPI_LOAD;
- }
|