|
|
@@ -1,118 +0,0 @@
|
|
|
-#include <stdint.h>
|
|
|
-#include <stddef.h>
|
|
|
-#include <stdbool.h>
|
|
|
-
|
|
|
-#include "chlcd.h"
|
|
|
-
|
|
|
-#define __R(X) (if (X != CHLCD_SUCCESS) { return CHLCD_BAD_ARGUMENT; })
|
|
|
-
|
|
|
-chlcd_error_t chlcd_hd44780_direct_sender_init(void *self_pointer) {
|
|
|
- chlcd_hd44780_direct_connector_t *self
|
|
|
- = (chlcd_hd44780_direct_connector_t *) self_pointer;
|
|
|
-
|
|
|
- __R(chlcd_pin_set_output(self->e);
|
|
|
- __R(chlcd_pin_set_output(self->rs);
|
|
|
- __R(chlcd_pin_set_output(self->d4);
|
|
|
- __R(chlcd_pin_set_output(self->d5);
|
|
|
- __R(chlcd_pin_set_output(self->d6);
|
|
|
- __R(chlcd_pin_set_output(self->d7);
|
|
|
-
|
|
|
- return CHLCD_SUCCESS;
|
|
|
-}
|
|
|
-
|
|
|
-#undef __R
|
|
|
-
|
|
|
-#define __R(X) (if (X != CHLCD_SUCCESS) { return CHLCD_BAD_ARGUMENT; })
|
|
|
-
|
|
|
-static chlcd_error_t __chlcd_hd44780_shift_register_send_byte(
|
|
|
- void *self_pointer,
|
|
|
- uint8_t content
|
|
|
-) {
|
|
|
- chlcd_hd44780_shift_register_t *self
|
|
|
- = (chlcd_hd44780_shift_register_t *) self_pointer;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- self->last_state = content;
|
|
|
-}
|
|
|
-
|
|
|
-#undef __R
|
|
|
-
|
|
|
-#define __R(X) (if (X != CHLCD_SUCCESS) { return CHLCD_BAD_ARGUMENT; })
|
|
|
-
|
|
|
-chlcd_error_t chlcd_hd44780_shift_register_init(void *self_pointer) {
|
|
|
- chlcd_hd44780_shift_register_t *self
|
|
|
- = (chlcd_hd44780_shift_register_t *) self_pointer;
|
|
|
-
|
|
|
- __R(chlcd_pin_set_output(self->register_latch));
|
|
|
- __R(chlcd_pin_set_output(self->register_clock));
|
|
|
- __R(chlcd_pin_set_output(self->register_data));
|
|
|
-
|
|
|
- return CHLCD_SUCCESS;
|
|
|
-}
|
|
|
-
|
|
|
-#undef __R
|
|
|
-
|
|
|
-chlcd_error_t chlcd_hd44780_direct_sender(
|
|
|
- void *self,
|
|
|
- chlcd_data_t content,
|
|
|
- bool is_command,
|
|
|
- bool is_half_word
|
|
|
-) {
|
|
|
- return CHLCD_SUCCESS;
|
|
|
-}
|
|
|
-
|
|
|
-chlcd_error_t chlcd_hd44780_shift_register_sender(
|
|
|
- void *self,
|
|
|
- chlcd_data_t content,
|
|
|
- bool is_command,
|
|
|
- bool is_half_word
|
|
|
-) {
|
|
|
- return CHLCD_SUCCESS;
|
|
|
-}
|
|
|
-
|
|
|
-static inline chlcd_error_t __chlcd_hd44780_decoder_init(
|
|
|
- void *connector,
|
|
|
- chlcd_sender_t sender
|
|
|
-) {
|
|
|
- if (sender(connector, 0b0010, true, true) != CHLCD_SUCCESS) {
|
|
|
- return CHLCD_SEND_ERROR;
|
|
|
- }
|
|
|
-
|
|
|
- if (sender(connector, 0b00001111, true, false) != CHLCD_SUCCESS) {
|
|
|
- return CHLCD_SEND_ERROR;
|
|
|
- }
|
|
|
-
|
|
|
- return CHLCD_SUCCESS;
|
|
|
-}
|
|
|
-
|
|
|
-static inline chlcd_error_t __chlcd_hd4470_decoder_clear(
|
|
|
- void *connector,
|
|
|
- chlcd_sender_t sender;
|
|
|
-) {
|
|
|
- if (sender(connector, 0b00000001, true, false) != CHLCD_SUCCESS) {
|
|
|
- return CHLCD_SEND_ERROR;
|
|
|
- }
|
|
|
-
|
|
|
- if (sender(connector, 0b00000010, true, false) != CHLCD_SUCCESS) {
|
|
|
- return CHLCD_SEND_ERROR;
|
|
|
- }
|
|
|
-
|
|
|
- return CHLCD_SUCCESS;
|
|
|
-}
|
|
|
-
|
|
|
-chlcd_error_t chlcd_hd44780_decoder(
|
|
|
- chlcd_command_t command,
|
|
|
- chlcd_data_t content,
|
|
|
- void *connector,
|
|
|
- chlcd_sender_t sender
|
|
|
-) {
|
|
|
- switch (command) {
|
|
|
- case CHLCD_INIT:
|
|
|
- return __chlcd_hd44780_decoder_init(connector, init);
|
|
|
-
|
|
|
- case CHLCD_CLEAR:
|
|
|
- return __chlcd_hd44780_decoder_clear(connector, init);
|
|
|
- }
|
|
|
-}
|
|
|
-
|