Taiga Develop 2 tuần trước cách đây
mục cha
commit
87d3fdb1f4

+ 0 - 13
include/cx/chlcd.h

@@ -1,13 +0,0 @@
-#ifndef CX_CHLCD_H_INCLUDED
-#define CX_CHLCD_H_INCLUDED
-
-#include "chlcd/types.h"
-#include "chlcd/error.h"
-#include "chlcd/command.h"
-#include "chlcd/connector.h"
-#include "chlcd/creator.h"
-#include "chlcd/decoder.h"
-#include "chlcd/display.h"
-#include "chlcd/sender.h"
-
-#endif

+ 0 - 12
include/cx/chlcd/api.h

@@ -1,12 +0,0 @@
-#ifndef CX_CHLCD_API_H_INCLUDED
-#define CX_CHLCD_API_H_INCLUDED
-
-#include "chlcd/types.h"
-#include "chlcd/error.h"
-#include "chlcd/display.h"
-
-chlcd_error_t chlcd_display_init(chlcd_display_t *self);
-chlcd_error_t chlcd_display_clear(chlcd_display_t *self);
-chlcd_error_t chlcd_display_print(chlcd_display_t *self, char *content);
-
-#endif

+ 0 - 14
include/cx/chlcd/command.h

@@ -1,14 +0,0 @@
-#ifndef CX_CHLCD_COMMAND_H_INCLUDED
-#define CX_CHLCD_COMMAND_H_INCLUDED
-
-typedef enum chlcd_command_e {
-    CHLCD_RESET,
-    CHLCD_INIT,
-    CHLCD_CLEAR,
-    CHLCD_SHOW_CURSOR,
-    CHLCD_HIDE_CURSOR,
-    CHLCD_MOVE_CURSOR,
-    CHLCD_SEND_CHAR
-} chlcd_command_t;
-
-#endif

+ 0 - 30
include/cx/chlcd/connector.h

@@ -1,30 +0,0 @@
-#ifndef CX_CHLCD_CONNECTOR_H_INCLUDED
-#define CX_CHLCD_CONNECTOR_H_INCLUDED
-
-#include "chlcd/types.h"
-
-typedef struct chlcd_hd44780_direct_connector_s {
-    chlcd_pin_t e;
-    chlcd_pin_t rs;
-    chlcd_pin_t d4;
-    chlcd_pin_t d5;
-    chlcd_pin_t d6;
-    chlcd_pin_t d7;
-} chlcd_hd44780_direct_connector_t;
-
-typedef struct chlcd_hd44780_shift_register_connector_s {
-    chlcd_pin_t register_latch;
-    chlcd_pin_t register_clock;
-    chlcd_pin_t register_data;
-   
-    chlcd_bitcount_t e;
-    chlcd_bitcount_t rs;
-    chlcd_bitcount_t d4;
-    chlcd_bitcount_t d5;
-    chlcd_bitcount_t d6;
-
-    uint8_t last_state;
-    chlcd_bitcount_t d7;
-} chlcd_hd44780_shift_register_connector_t;
-
-#endif

+ 0 - 23
include/cx/chlcd/creator.h

@@ -1,23 +0,0 @@
-#ifndef CX_CHLCD_CREATOR_H_INCLUDED
-#define CX_CHLCD_CREATOR_H_INCLUDED
-
-#include "chlcd/types.h"
-#include "chlcd/error.h"
-#include "chlcd/display.h"
-#include "chlcd/connector.h"
-
-chlcd_error_t chlcd_hd44780_direct_create(
-    chlcd_display_t *self,
-    chlcd_hd44780_direct_connector_t *connector,
-    chlcd_size_t width,
-    chlcd_size_t height
-);
-
-chlcd_error_t chlcd_hd44780_shift_register_create(
-    chlcd_display_t *self,
-    chlcd_hd44780_shift_register_connector_t *connector,
-    chlcd_size_t width,
-    chlcd_size_t height
-);
-
-#endif

+ 0 - 17
include/cx/chlcd/decoder.h

@@ -1,17 +0,0 @@
-#ifndef CX_CHLCD_DECODER_H_INCLUDED
-#define CX_CHLCD_DECODER_H_INCLUDED
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include "chlcd/error.h"
-#include "chlcd/command.h"
-#include "chlcd/types.h"
-
-chlcd_error_t chlcd_hd44780_decoder_(
-    chlcd_command_t command,
-    chlcd_data_t content,
-    chlcd_sender_t sender
-);
-
-#endif

+ 0 - 20
include/cx/chlcd/display.h

@@ -1,20 +0,0 @@
-#ifndef CX_CHLCD_DISPLAY_H_INCLUDED
-#define CX_CHLCD_DISPLAY_H_INCLUDED
-
-#include <stdint.h>
-#include <stddef.h>
-#include <stdbool.h>
-
-#include "chlcd/types.h"
-#include "chldc/connector.h"
-#include "chldc/display_type.h"
-
-typedef struct chlcd_display_s {
-    chlcd_sender_t sender;
-    chlcd_decoder_t decoder;
-    chlcd_size_t width;
-    chlcd_size_t height;
-    void *connector;
-} chlcd_display_t;
-
-#endif

+ 0 - 10
include/cx/chlcd/error.h

@@ -1,10 +0,0 @@
-#ifndef CX_CHLCD_ERROR_H_INCLUDED
-#define CX_CHLCD_ERROR_H_INCLUDED
-
-typedef enum chlcd_error_e {
-    CHLCD_SUCCESS,
-    CHLCD_BAD_ARGUMENT,
-    CHLCD_SEND_ERROR
-} chlcd_error_t;
-
-#endif

+ 0 - 61
include/cx/chlcd/hal.h

@@ -1,61 +0,0 @@
-#ifndef CX_CHLCD_HAL_H_INCLUDED
-#define CX_CHLCD_HAL_H_INCLUDED
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include "chlcd/types.h"
-
-#ifdef CHLCD_ON_ESP
-
-static inline chlcd_error_t chlcd_pin_set_output(chlcd_pin_t target) {
-
-}
-
-static inline chlcd_error_t chlcd_pin_write(chlcd_pin_t target, bool state) {
-
-}
-
-static inline chlcd_error_t chlcd_pin_set_pwm(chlcd_pin_t target) {
-
-}
-
-static inline chlcd_error_t chlcd_pin_write_pwm(
-    chlcd_pin_t target, 
-    uint16_t pwm
-) {
-
-}
-
-#else
-
-#define CHLCD_MODE_DEBUG
-
-#include <stdio.h>
-
-static inline chlcd_error_t chlcd_pin_set_output(chlcd_pin_t target) {
-    printf("Pin %li mode set to output.\n", (uint32_t) target);
-    return CHLCD_SUCCESS;
-}
-
-static inline chlcd_error_t chlcd_pin_write(chlcd_pin_t target, bool state) {
-    printf("Pin %li set to %s.\n", (uint32_t) target, state ? "HIGH" : "LOW");
-    return CHLCD_SUCCESS;
-}
-
-static inline chlcd_error_t chlcd_pin_set_pwm(chlcd_pin_t target) {
-    printf("Pin %li mode set to PWM.\n", (uint32_t) target);
-    return CHLCD_SUCCESS;
-}
-
-static inline chlcd_error_t chlcd_pin_write_pwm(
-    chlcd_pin_t target,
-    uint16_t pwm
-) {
-    printf("Pin %li write to PWM %i.\n", (uint32_t) target, pwm);
-    return CHLCD_SUCCESS;
-}
-
-#endif
-
-#endif

+ 0 - 21
include/cx/chlcd/sender.h

@@ -1,21 +0,0 @@
-#ifndef CX_CHLCD_SENDER_H_INCLUDED
-#define CX_CHLCD_SENDER_H_INCLUDED
-
-#include "chlcd/types.h"
-#include "chlcd/error.h"
-
-chlcd_error_t chlcd_hd44780_direct_sender(
-    void *self,
-    chlcd_data_t content,
-    bool is_command,
-    bool is_half_word
-);
-
-chlcd_error_t chlcd_hd44780_shift_register_sender(
-    void *self,
-    chlcd_data_t content,
-    bool is_command,
-    bool is_half_word
-);
-
-#endif

+ 0 - 37
include/cx/chlcd/types.h

@@ -1,37 +0,0 @@
-#ifndef CX_CHLCD_TYPES_H_INCLUDED
-#define CX_CHLCD_TYPES_H_INCLUDED
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#ifdef CHLCD_ON_ESP
-#define chlcd_pin_t gpio_num_t
-#endif
-
-#ifndef chlcd_pin_t 
-#define chlcd_pin_t uint32_t
-#endif
-
-typedef uint8_t chlcd_size_t;
-typedef uint8_t chlcd_bitcount_t;
-struct chlcd_display_s;
-struct chlcd_connector_s;
-enum chlcd_command_e;
-enum chlcd_error_e;
-typedef uint8_t chlcd_data_t;
-
-typedef enum chlcd_error_e (*chlcd_sender_t)(
-    void *self, 
-    chlcd_data_t content,
-    bool is_command,
-    bool is_half_word
-);
-
-typedef enum chlcd_error_r (*chlcd_decoder_t)(
-    enum chlcd_command_e command,
-    chlcd_data_t content,
-    void *connector,
-    chlcd_sender_t sender
-);
-
-#endif

+ 0 - 20
source/display.c

@@ -1,20 +0,0 @@
-#include "chlcd.h"
-
-chlcd_error_t chlcd_display_init(chlcd_display_t *self) {
-    chlcd_error_t result;
-
-    result = self->decoder(CHLCD_INIT, 0x00, self->sender);
- 
-    if (result != CHLCD_SUCCESS) {
-        return result;
-    }
-
-    result = self->decoder(CHLCD_CLEAR, 0x00, self->sender);
-
-    if (result != CHLCD_SUCCESS) {
-        return result;
-    }
-
-    return CHLCD_SUCCESS;
-}
-

+ 0 - 118
source/hd44780.c

@@ -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);
-    }
-}   
-

+ 0 - 0
source/shift_register.c