Last active
October 29, 2017 08:24
-
-
Save electronut/f4e158d7de38b1f58c90b165ec5e3c71 to your computer and use it in GitHub Desktop.
stm32-returns-5.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// send 16 bit data packet | |
void MAX7219::sendPacket(MAX7129_REG reg, uint8_t data) | |
{ | |
// CS | |
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET); | |
//uint16_t packet = (reg << 8) | data; | |
uint8_t packet[2]; | |
packet[0] = reg; | |
packet[1] = data; | |
HAL_SPI_Transmit(const_cast<SPI_HandleTypeDef*>(_hSPI), (uint8_t*)&packet, 2, 100); | |
// CS | |
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET); | |
} | |
// set the whole display with an 8x8 buffer | |
void MAX7219::setBuffer(const BitBuf88& buf) | |
{ | |
for (int j = 0 ; j < 8; j++) { | |
sendPacket(static_cast<MAX7129_REG>(j+1), buf._vals[j]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment