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
| static void _cli_history_up(void* a_ctx) { | |
| t_cli_ctx *ctx = (t_cli_ctx *)a_ctx; | |
| char prompt[12] = {0x00}; | |
| if ((ctx->hhead != ctx->htail) && | |
| strlen(ctx->history[ctx->hpos])) { | |
| memset(ctx->cmd, 0x00, CLI_CMD_BUFFER_SIZE); | |
| strcpy(ctx->cmd, ctx->history[ctx->hpos]); |
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
| static void _cli_history_add(t_cli_ctx *a_ctx) { | |
| if (a_ctx->hhead == CLI_CMD_HISTORY_LEN && | |
| a_ctx->htail == CLI_CMD_HISTORY_LEN) { | |
| a_ctx->hhead = 0; | |
| a_ctx->htail = 0; | |
| } | |
| else { | |
| a_ctx->hhead++; | |
| a_ctx->hhead %= CLI_CMD_HISTORY_LEN; |
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
| void cli_read(t_cli_ctx *a_ctx) { | |
| unsigned char i = 0x00; | |
| unsigned char res = E_CMD_OK; | |
| // if no character available - then exit | |
| if (!CLI_IO_INPUT(&i)) return; | |
| /// multi-code matching | |
| if (a_ctx->mc.pos && a_ctx->mc.pos < MULTICODE_INPUT_MAX_LEN) { |
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
| static void _cli_reinterpret_cmd(t_cli_ctx *a_ctx, unsigned char a_response) { | |
| switch(a_response) { | |
| case E_CMD_NOT_FOUND: { | |
| char str[] = "\r\nCommand not found"; | |
| CLI_IO_OUTPUT(str, strlen(str)); | |
| } | |
| break; | |
| case E_CMD_TOO_SHORT: { | |
| char str[] = "\r\nCommand too short"; |
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
| typedef enum _t_cmd_status { | |
| E_CMD_OK = 0, | |
| E_CMD_NOT_FOUND, | |
| E_CMD_TOO_SHORT, | |
| E_CMD_EMPTY | |
| } t_cmd_status; | |
| static unsigned char _cli_interpret_cmd(t_cli_ctx *a_ctx) { | |
| unsigned char i = 0; |
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
| #define POSINC(__x) (((__x) < (CLI_CMD_BUFFER_SIZE - 1)) ? (__x + 1) : (__x)) | |
| #define POSDEC(__x) ((__x) ? ((__x) - 1) : 0) | |
| #define KEY_CODE_BACKSPACE 0x7f | |
| #define KEY_CODE_DELETE 0x1b | |
| #define KEY_CODE_ENTER 0x0a | |
| #define CLI_IO_INPUT(__data) \ | |
| linux_getc(__data) | |
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
| unsigned char linux_getc(unsigned char *a_data) { | |
| *a_data = getchar(); | |
| return 1; | |
| } | |
| unsigned char linux_putc(unsigned char *data, unsigned char a_len) { | |
| while (a_len--) { | |
| fputc(*data++, stdout); | |
| } | |
| } |
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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <unistd.h> | |
| #include <termios.h> | |
| void cm_off(void) | |
| { | |
| struct termios t; |
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
| #include <avr/io.h> | |
| #include <stdint.h> | |
| #include <util/delay.h> | |
| typedef struct _gpio_pin { | |
| volatile uint8_t *port; | |
| uint8_t pin; | |
| } gpio_pin; |
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
| #include "pca.h" | |
| #include <stdio.h> | |
| #include <util/delay.h> | |
| #include <avr/interrupt.h> | |
| volatile static uint8_t cnt = 0x00; | |
| volatile static uint32_t g_epoch = 0x00; | |
| ISR(TIMER0_COMPA_vect) { |