add gpio and finalisation of pinning
This commit is contained in:
@@ -42,7 +42,7 @@ void app_main(void);
|
|||||||
/** Event handler for IP_EVENT_ETH_GOT_IP */
|
/** Event handler for IP_EVENT_ETH_GOT_IP */
|
||||||
static void got_ip_event_handler(void *arg, esp_event_base_t event_base,
|
static void got_ip_event_handler(void *arg, esp_event_base_t event_base,
|
||||||
int32_t event_id, void *event_data)
|
int32_t event_id, void *event_data)
|
||||||
{
|
{
|
||||||
ip_event_got_ip_t *event = (ip_event_got_ip_t *) event_data;
|
ip_event_got_ip_t *event = (ip_event_got_ip_t *) event_data;
|
||||||
const esp_netif_ip_info_t *ip_info = &event->ip_info;
|
const esp_netif_ip_info_t *ip_info = &event->ip_info;
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ static void got_ip_event_handler(void *arg, esp_event_base_t event_base,
|
|||||||
// Event handler for Ethernet
|
// Event handler for Ethernet
|
||||||
static void eth_event_handler(void *arg, esp_event_base_t event_base,
|
static void eth_event_handler(void *arg, esp_event_base_t event_base,
|
||||||
int32_t event_id, void *event_data)
|
int32_t event_id, void *event_data)
|
||||||
{
|
{
|
||||||
uint8_t mac_addr[6] = {0};
|
uint8_t mac_addr[6] = {0};
|
||||||
switch (event_id) {
|
switch (event_id) {
|
||||||
case ETHERNET_EVENT_CONNECTED:
|
case ETHERNET_EVENT_CONNECTED:
|
||||||
@@ -65,7 +65,7 @@ static void eth_event_handler(void *arg, esp_event_base_t event_base,
|
|||||||
s_ethernet_is_connected = true;
|
s_ethernet_is_connected = true;
|
||||||
ESP_LOGI(TAG, "Ethernet Link Up");
|
ESP_LOGI(TAG, "Ethernet Link Up");
|
||||||
ESP_LOGI(TAG, "Ethernet HW Addr %02x:%02x:%02x:%02x:%02x:%02x",
|
ESP_LOGI(TAG, "Ethernet HW Addr %02x:%02x:%02x:%02x:%02x:%02x",
|
||||||
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
|
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
|
||||||
break;
|
break;
|
||||||
case ETHERNET_EVENT_DISCONNECTED:
|
case ETHERNET_EVENT_DISCONNECTED:
|
||||||
ESP_LOGI(TAG, "Ethernet Link Down");
|
ESP_LOGI(TAG, "Ethernet Link Down");
|
||||||
@@ -82,7 +82,7 @@ static void eth_event_handler(void *arg, esp_event_base_t event_base,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initialize_ethernet(void)
|
static void initialize_ethernet(void)
|
||||||
{
|
{
|
||||||
uint8_t eth_port_cnt = 0;
|
uint8_t eth_port_cnt = 0;
|
||||||
esp_eth_handle_t *eth_handles;
|
esp_eth_handle_t *eth_handles;
|
||||||
@@ -114,12 +114,12 @@ static void initialize_ethernet(void)
|
|||||||
void LightingTask() {
|
void LightingTask() {
|
||||||
ESP_LOGI(TAG, "Start Lighting");
|
ESP_LOGI(TAG, "Start Lighting");
|
||||||
|
|
||||||
static I2cMaster master(I2C_NUM_0,
|
static I2cMaster master(I2C_NUM_0,
|
||||||
/*sda=*/ GPIO_NUM_0,
|
/*sda=*/ GPIO_NUM_0,
|
||||||
/*scl=*/ GPIO_NUM_4);
|
/*scl=*/ GPIO_NUM_4);
|
||||||
// static PmwExpanderPca9685 pca9685(master);
|
// static PmwExpanderPca9685 pca9685(master);
|
||||||
static PmwExpanderPca9685 ledDriver1(master, /*iverted=*/ true);
|
static PmwExpanderPca9685 ledDriver1(master, /*iverted=*/ true);
|
||||||
static PmwExpanderPca9685 ledDriver2(master, /*iverted=*/ true, 0x41);
|
static PmwExpanderPca9685 ledDriver2(master, /*iverted=*/ true, 0x41);
|
||||||
PmwExpanderPca9685::GrayValues values[2];
|
PmwExpanderPca9685::GrayValues values[2];
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -131,7 +131,7 @@ void LightingTask() {
|
|||||||
values[0][12] = 0x100;
|
values[0][12] = 0x100;
|
||||||
values[0][15] = 0x100;
|
values[0][15] = 0x100;
|
||||||
ledDriver1.sendImage(values[0]);
|
ledDriver1.sendImage(values[0]);
|
||||||
|
|
||||||
values[1][1] = 0x100;
|
values[1][1] = 0x100;
|
||||||
values[1][2] = 0x100;
|
values[1][2] = 0x100;
|
||||||
ledDriver2.sendImage(values[1]);
|
ledDriver2.sendImage(values[1]);
|
||||||
@@ -158,8 +158,28 @@ void MovementTask() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IoTest()
|
||||||
|
{
|
||||||
|
ESP_LOGI(TAG, "Start IO");
|
||||||
|
InputPort in1(GPIO_NUM_33);
|
||||||
|
InputPort in2(GPIO_NUM_32);
|
||||||
|
InputPort mFault(GPIO_NUM_35);
|
||||||
|
|
||||||
void app_main(void)
|
OutputPort nEnable(GPIO_NUM_2);
|
||||||
|
OutputPort nReset(GPIO_NUM_5);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
ESP_LOGI("Light", "InValues %i %i %i", in1.read(), in2.read(), mFault.read());
|
||||||
|
nEnable.write(true);
|
||||||
|
nReset.write(true);
|
||||||
|
fos::Task::delayMs(500);
|
||||||
|
nEnable.write(false);
|
||||||
|
nReset.write(false);
|
||||||
|
fos::Task::delayMs(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
{
|
{
|
||||||
esp_err_t ret = nvs_flash_init();
|
esp_err_t ret = nvs_flash_init();
|
||||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||||
@@ -171,4 +191,5 @@ void app_main(void)
|
|||||||
initialize_ethernet();
|
initialize_ethernet();
|
||||||
static fos::Task lightingTask(LightingTask, "Lights", 0x4000uL);
|
static fos::Task lightingTask(LightingTask, "Lights", 0x4000uL);
|
||||||
static fos::Task movementTask(MovementTask, "Motor", 0x4000uL);
|
static fos::Task movementTask(MovementTask, "Motor", 0x4000uL);
|
||||||
|
static fos::Task ioTask(IoTest, "IO", 0x4000uL);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user