wip:
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.pio
|
||||||
|
.vscode
|
18
.gitmodules
vendored
Normal file
18
.gitmodules
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[submodule "lib/zh_avr_free_rtos"]
|
||||||
|
path = lib/zh_avr_free_rtos
|
||||||
|
url = http://git.zh.com.ru/avr_libraries/zh_avr_free_rtos
|
||||||
|
[submodule "lib/zh_avr_vector"]
|
||||||
|
path = lib/zh_avr_vector
|
||||||
|
url = http://git.zh.com.ru/avr_libraries/zh_avr_vector
|
||||||
|
[submodule "lib/zh_avr_i2c"]
|
||||||
|
path = lib/zh_avr_i2c
|
||||||
|
url = http://git.zh.com.ru/avr_libraries/zh_avr_i2c
|
||||||
|
[submodule "lib/zh_avr_common"]
|
||||||
|
path = lib/zh_avr_common
|
||||||
|
url = http://git.zh.com.ru/avr_libraries/zh_avr_common
|
||||||
|
[submodule "lib/zh_avr_pcf8574"]
|
||||||
|
path = lib/zh_avr_pcf8574
|
||||||
|
url = http://git.zh.com.ru/avr_libraries/zh_avr_pcf8574
|
||||||
|
[submodule "lib/zh_avr_160x_i2c"]
|
||||||
|
path = lib/zh_avr_160x_i2c
|
||||||
|
url = http://git.zh.com.ru/avr_libraries/zh_avr_160x_i2c
|
Binary file not shown.
BIN
cad/BP-522/BP-522.m3d
Normal file
BIN
cad/BP-522/BP-522.m3d
Normal file
Binary file not shown.
BIN
cad/BP-522/BP-522_1.m3d
Normal file
BIN
cad/BP-522/BP-522_1.m3d
Normal file
Binary file not shown.
BIN
cad/BP-522/BP-522_2.m3d
Normal file
BIN
cad/BP-522/BP-522_2.m3d
Normal file
Binary file not shown.
BIN
cad/BP-522/BP-522_3.m3d
Normal file
BIN
cad/BP-522/BP-522_3.m3d
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
cad/CASE/ATE0003.000.004 _ Верх.m3d
Normal file
BIN
cad/CASE/ATE0003.000.004 _ Верх.m3d
Normal file
Binary file not shown.
BIN
cad/CASE/ATE0003.000.006 _ Кнопка.m3d
Normal file
BIN
cad/CASE/ATE0003.000.006 _ Кнопка.m3d
Normal file
Binary file not shown.
BIN
cad/DUWI 26840/DUWI 26840.m3d
Normal file
BIN
cad/DUWI 26840/DUWI 26840.m3d
Normal file
Binary file not shown.
BIN
cad/DUWI 26840/DUWI 26840_1.m3d
Normal file
BIN
cad/DUWI 26840/DUWI 26840_1.m3d
Normal file
Binary file not shown.
Binary file not shown.
BIN
cad/LCD1604/LCD_SCREEN_16x4_10.a3d
Normal file
BIN
cad/LCD1604/LCD_SCREEN_16x4_10.a3d
Normal file
Binary file not shown.
1
lib/zh_avr_160x_i2c
Submodule
1
lib/zh_avr_160x_i2c
Submodule
Submodule lib/zh_avr_160x_i2c added at d95823281b
1
lib/zh_avr_common
Submodule
1
lib/zh_avr_common
Submodule
Submodule lib/zh_avr_common added at 1cb4a4cc76
1
lib/zh_avr_free_rtos
Submodule
1
lib/zh_avr_free_rtos
Submodule
Submodule lib/zh_avr_free_rtos added at a408615f7d
1
lib/zh_avr_i2c
Submodule
1
lib/zh_avr_i2c
Submodule
Submodule lib/zh_avr_i2c added at da2fd0d2a8
1
lib/zh_avr_pcf8574
Submodule
1
lib/zh_avr_pcf8574
Submodule
Submodule lib/zh_avr_pcf8574 added at 6b8b8c3314
1
lib/zh_avr_vector
Submodule
1
lib/zh_avr_vector
Submodule
Submodule lib/zh_avr_vector added at eddd461e96
4
platformio.ini
Normal file
4
platformio.ini
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[env:ATmega328P]
|
||||||
|
platform = atmelavr
|
||||||
|
board = ATmega328P
|
||||||
|
framework = arduino
|
110
src/main.c
Normal file
110
src/main.c
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "avr/io.h"
|
||||||
|
#include "zh_avr_160x_i2c.h"
|
||||||
|
|
||||||
|
// #define DEBUG
|
||||||
|
|
||||||
|
#define BUTTON_I2C_ADDRESS 0x00
|
||||||
|
#define LED1_I2C_ADDRESS 0x00
|
||||||
|
#define LED2_I2C_ADDRESS 0x00
|
||||||
|
#define RELAY_I2C_ADDRESS 0x00
|
||||||
|
#define LCD_I2C_ADDRESS 0x00
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#define BAUD_RATE 9600
|
||||||
|
#define BAUD_PRESCALE (F_CPU / 16 / BAUD_RATE - 1)
|
||||||
|
|
||||||
|
int usart(char byte, FILE *stream)
|
||||||
|
{
|
||||||
|
while ((UCSR0A & (1 << UDRE0)) == 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
UDR0 = byte;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
FILE uart = FDEV_SETUP_STREAM(usart, NULL, _FDEV_SETUP_WRITE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
zh_avr_pcf8574_handle_t button_handle = {0};
|
||||||
|
zh_avr_pcf8574_handle_t led1_handle = {0};
|
||||||
|
zh_avr_pcf8574_handle_t led2_handle = {0};
|
||||||
|
zh_avr_pcf8574_handle_t relay_handle = {0};
|
||||||
|
zh_avr_pcf8574_handle_t lcd_handle = {0};
|
||||||
|
|
||||||
|
// void led_flash_task(void *pvParameters)
|
||||||
|
// {
|
||||||
|
// DDRB |= (1 << PORTB5);
|
||||||
|
// for (;;)
|
||||||
|
// {
|
||||||
|
// PORTB ^= (1 << PORTB5);
|
||||||
|
// vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
|
// }
|
||||||
|
// vTaskDelete(NULL);
|
||||||
|
// }
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
UBRR0H = (BAUD_PRESCALE >> 8);
|
||||||
|
UBRR0L = BAUD_PRESCALE;
|
||||||
|
UCSR0B = (1 << RXEN0) | (1 << TXEN0);
|
||||||
|
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00);
|
||||||
|
stdout = &uart;
|
||||||
|
#endif
|
||||||
|
zh_avr_i2c_master_init(false);
|
||||||
|
zh_avr_pcf8574_init_config_t pcf8574_init_config = ZH_AVR_PCF8574_INIT_CONFIG_DEFAULT();
|
||||||
|
pcf8574_init_config.i2c_address = LED1_I2C_ADDRESS;
|
||||||
|
zh_avr_pcf8574_init(&pcf8574_init_config, &led1_handle);
|
||||||
|
zh_avr_pcf8574_write(&led1_handle, 0xFF);
|
||||||
|
pcf8574_init_config.i2c_address = LED2_I2C_ADDRESS;
|
||||||
|
zh_avr_pcf8574_init(&pcf8574_init_config, &led2_handle);
|
||||||
|
zh_avr_pcf8574_write(&led2_handle, 0x0F);
|
||||||
|
pcf8574_init_config.i2c_address = RELAY_I2C_ADDRESS;
|
||||||
|
zh_avr_pcf8574_init(&pcf8574_init_config, &relay_handle);
|
||||||
|
pcf8574_init_config.i2c_address = LCD_I2C_ADDRESS;
|
||||||
|
zh_avr_pcf8574_init(&pcf8574_init_config, &lcd_handle);
|
||||||
|
pcf8574_init_config.p0_gpio_work_mode = true;
|
||||||
|
pcf8574_init_config.p1_gpio_work_mode = true;
|
||||||
|
pcf8574_init_config.p2_gpio_work_mode = true;
|
||||||
|
pcf8574_init_config.p3_gpio_work_mode = true;
|
||||||
|
pcf8574_init_config.p4_gpio_work_mode = true;
|
||||||
|
pcf8574_init_config.p5_gpio_work_mode = true;
|
||||||
|
pcf8574_init_config.interrupt_port = AVR_PORTD;
|
||||||
|
pcf8574_init_config.interrupt_gpio = PORTD2;
|
||||||
|
pcf8574_init_config.i2c_address = BUTTON_I2C_ADDRESS;
|
||||||
|
zh_avr_pcf8574_init(&pcf8574_init_config, &button_handle);
|
||||||
|
zh_avr_160x_init(&lcd_handle, ZH_LCD_16X4);
|
||||||
|
zh_avr_160x_set_cursor(&lcd_handle, 0, 0);
|
||||||
|
zh_avr_160x_print_char(&lcd_handle, "LLC AEROTECH");
|
||||||
|
zh_avr_160x_set_cursor(&lcd_handle, 1, 0);
|
||||||
|
zh_avr_160x_print_char(&lcd_handle, "ATE0003.000.000");
|
||||||
|
zh_avr_160x_set_cursor(&lcd_handle, 2, 0);
|
||||||
|
zh_avr_160x_print_char(&lcd_handle, "Firmware v1.0.0");
|
||||||
|
zh_avr_160x_set_cursor(&lcd_handle, 3, 0);
|
||||||
|
zh_avr_160x_print_char(&lcd_handle, "Loading: ");
|
||||||
|
for (uint8_t i = 0; i <= 100; ++i)
|
||||||
|
{
|
||||||
|
zh_avr_160x_set_cursor(&lcd_handle, 3, 10); // For LCD 16X4.
|
||||||
|
zh_avr_160x_print_int(&lcd_handle, i);
|
||||||
|
zh_avr_160x_print_char(&lcd_handle, "%");
|
||||||
|
_delay_ms(50);
|
||||||
|
}
|
||||||
|
// xTaskCreate(led_flash_task, "led flash task", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);
|
||||||
|
vTaskStartScheduler();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void zh_avr_pcf8574_event_handler(zh_avr_pcf8574_event_on_isr_t *event)
|
||||||
|
{
|
||||||
|
printf("Interrupt happened on device address 0x%02X on GPIO number %d at level %d.\n", event->i2c_address, event->gpio_number, event->gpio_level);
|
||||||
|
printf("Interrupt Task Remaining Stack Size %d.\n", uxTaskGetStackHighWaterMark(NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
ISR(PCINT2_vect)
|
||||||
|
{
|
||||||
|
if (zh_avr_pcf8574_isr_handler() == pdTRUE)
|
||||||
|
{
|
||||||
|
portYIELD();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user