make ssd driver work
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "ssd.h"
|
||||
|
||||
#include "esp_rom_sys.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -9,23 +10,28 @@ extern "C" {
|
||||
|
||||
inline void pulse(gpio_num_t pin) {
|
||||
gpio_set_level(pin, 1);
|
||||
esp_rom_delay_us(1);
|
||||
gpio_set_level(pin, 0);
|
||||
esp_rom_delay_us(1);
|
||||
}
|
||||
|
||||
void shiftInit(const ssd_595_t* device) {
|
||||
|
||||
gpio_reset_pin(device->dataPin);
|
||||
gpio_reset_pin(device->clockPin);
|
||||
gpio_reset_pin(device->latchPin);
|
||||
|
||||
gpio_config_t ioConfig = {
|
||||
.mode = GPIO_MODE_OUTPUT,
|
||||
.pin_bit_mask = (1ULL << device->dataPin) |
|
||||
(1ULL << device->clockPin) |
|
||||
(1ULL << device->latchPin)
|
||||
(1ULL << device->latchPin),
|
||||
};
|
||||
gpio_config(&ioConfig);
|
||||
|
||||
gpio_set_level(device->dataPin, 0);
|
||||
gpio_set_level(device->clockPin, 0);
|
||||
gpio_set_level(device->latchPin, 0);
|
||||
|
||||
ESP_LOGI(__FILE__, "ssd_595 initialized");
|
||||
}
|
||||
|
||||
void addDecimal(uint8_t* data) {
|
||||
@@ -34,8 +40,9 @@ void addDecimal(uint8_t* data) {
|
||||
}
|
||||
|
||||
void shiftByte(const ssd_595_t* device, uint8_t byte) {
|
||||
for(int i = 0; i < __CHAR_BIT__; i++) {
|
||||
gpio_set_level(device->dataPin, (byte >> i) & 0x1);
|
||||
for(int i = 0; i < __CHAR_BIT__ ; i++) {
|
||||
uint32_t level = ((byte >> i) & 0x1) ^ device->commonCathode;
|
||||
gpio_set_level(device->dataPin, level);
|
||||
pulse(device->clockPin);
|
||||
}
|
||||
pulse(device->latchPin);
|
||||
|
||||
Reference in New Issue
Block a user