Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
stm32-returns-5.c
// 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
You can’t perform that action at this time.