diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index b0e48ea..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -# -# Copyright 2014-2016 CyberVision, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -cmake_minimum_required(VERSION 2.8.8) - -set (CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/libs/kaa/toolchains/esp8266.cmake") -set (CMAKE_BUILD_TYPE MinSizeRel) - -project(C-SDK-sample C) -set(APP_NAME demo_client) - -set (KAA_PLATFORM esp8266) -set (KAA_MAX_LOG_LEVEL 0) - -# Disable unused features -set (WITH_EXTENSION_CONFIGURATION OFF CACHE BOOL "") -set (WITH_EXTENSION_NOTIFICATION OFF CACHE BOOL "") -set (WITH_EXTENSION_LOGGING OFF CACHE BOOL "") -set (WITH_EXTENSION_CONFIGURATION OFF CACHE BOOL "") -set (WITH_ENCRYPTION OFF CACHE BOOL "") - - -# Target-independent flags. -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -g -Wall -Wextra") - -# Path to the Kaa SDK. -add_subdirectory(libs/kaa) - -# Directory containing target support library. -add_subdirectory(target/esp8266) - -# This is required for ESP8266 platform -# due to it's specific requirements regarding linked executable. -# The blank.c file is a placeholder for CMake's add_executable() -# All the code (Kaa SDK, ESP8266 SDK and demo) is compiled as static libraries -# and linked into that executable. -add_library(${APP_NAME}_s STATIC src/kaa_demo.c) -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/blank.c "") -add_executable(${APP_NAME} ${CMAKE_CURRENT_BINARY_DIR}/blank.c) -target_link_libraries(${APP_NAME} ${APP_NAME}_s) -target_link_libraries(${APP_NAME}_s target_support kaac) - -# Strip the ELF -add_custom_command(TARGET ${APP_NAME} POST_BUILD COMMAND ${CMAKE_OBJCOPY} -O binary ${APP_NAME} ${APP_NAME}.bin) - -install(TARGETS ${APP_NAME} DESTINATION bin) diff --git a/README.md b/README.md index 70ebb0a..e5905c3 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,103 @@ +### Download and run Kaa Sandbox -## Follow the guide to install dependencies - https://kaaproject.github.io/kaa/docs/v0.10.0/Programming-guide/Using-Kaa-endpoint-SDKs/C/SDK-ESP8266/ +Download and import [Kaa Sandbox](https://jenkins.kaaproject.org:52001/job/sandbox_copy/8/artifact/kaa-sandbox-ubuntu-64bit-daily-build-126.ova) -## Install esptool - git clone https://github.com/espressif/esptool.git - cd esptool - sudo python setup.py install +### Download GPIO master application (Android) -## Download and untar the C SDK from the Kaa server - mkdir -p libs/kaa - tar xvf -C libs/kaa +1. Go to [http://localhost:9080/sandbox/#proj:projectId=gpiocontrol_demo_android_master](http://localhost:9080/sandbox/#proj:projectId=gpiocontrol_demo_android_master) +2. Press "Binary" button to download the APK file. -## Build an application - mkdir build - cd build - cmake -DWIFI_SSID= -DWIFI_PASSWORD= .. - make +### Download GPIO slave application (ESP8266) -## Prepare the binary - esptool.py elf2image demo_client +1. Go to [http://localhost:9080/sandbox/#proj:projectId=gpiocontrol_demo_c_slave](http://localhost:9080/sandbox/#proj:projectId=gpiocontrol_demo_c_slave) +2. Press "Source" button to download the archive file. + +### Compilation guide for ESP8266 demo (tested against Ubuntu 14.04 and Node MCU) + +1. Install Prerequisites + + sudo apt-get install autoconf libtool bison build-essential gawk git gperf flex texinfo libncurses5-dev libc6-dev-amd64 python-serial libexpat-dev python-setuptools + +2. Download and install cmake: + + wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz + tar xvf cmake-3.7.2.tar.gz + cd cmake-3.7.2/ + ./bootstrap && make + sudo make install + +3. Set the `ESPRESSIF_HOME` variable. +This variable will be used throughout the installation process, and denotes a directory where ESP8266 SDK and toolchain will be placed. +You are free to set it to whatever you like. + + sudo mkdir /opt/Espressif/ + sudo chown -R $USER:$USER /opt/Espressif/ + export ESPRESSIF_HOME=/opt/Espressif/ + +4. Install toolchain + + cd $ESPRESSIF_HOME + git clone -b lx106-g++ git://github.com/jcmvbkbc/crosstool-NG.git + cd crosstool-NG + ./bootstrap && ./configure --prefix=$(pwd) + make + sudo make install + ./ct-ng xtensa-lx106-elf + ./ct-ng build + +5. Add path to toolchain binaries to your `.bashrc`: + + echo "export PATH=$ESPRESSIF_HOME/crosstool-NG/builds/xtensa-lx106-elf/bin:\$PATH" >> ~/.bashrc + source ~/.bashrc + +6. Install ESP8266 RTOS SDK + + cd $ESPRESSIF_HOME + export ESP_SDK_HOME=$ESPRESSIF_HOME/esp-rtos-sdk + git clone https://github.com/espressif/esp_iot_rtos_sdk.git $ESP_SDK_HOME + cd $ESP_SDK_HOME + git checkout 169a436ce10155015d056eab80345447bfdfade5 + wget -O lib/libhal.a https://github.com/esp8266/esp8266-wiki/raw/master/libs/libhal.a + cd $ESP_SDK_HOME/include/lwip/arch + sed -i 's:#include "c_types.h"://#include "c_types.h":' $ESP_SDK_HOME/include/lwip/arch/cc.h + +7. Install esptool.py + + cd $ESPRESSIF_HOME + git clone https://github.com/espressif/esptool.git + cd esptool + sudo python setup.py install + +8. Unpack the C application and the Kaa SDK + + tar xvf gpiocontrol_demo.tar.gz + cd CGPIODemo/ + tar xvf libs/kaa/kaa-c-ep-sdk-*.tar.gz -C libs/kaa/ + +9. Build an application + + mkdir build + cd build + cmake -DKAA_PLATFORM=esp8266 -DCMAKE_TOOLCHAIN_FILE=../libs/kaa/toolchains/esp8266.cmake -DWIFI_SSID= -DWIFI_PASSWORD= -DDEMO_ACCESS_TOKEN= .. + make +You need to specify your Wifi AP name and password. +Also, you need to set the demo access token that you will use in the Android application. It can be any string. + +10. Prepare the binary + + esptool.py elf2image demo_client + +11. Flash the board + + sudo esptool.py write_flash 0x00000 demo_client-0x00000.bin 0x40000 demo_client-0x40000.bin + +12. Connect LEDs to your ESP8266 board. The demo code uses the GPIO4 and GPIO5. +After flashing the ESP8266 will automatically connect to the AP and will listen for events from the Kaa server. + +### Run Android application + +1. Open the APK file on your Android device +2. Press "+" and enter the demo access token +3. Select the ESP8266 endpoint +4. Use GUI to turn on/off the leds on ESP board -## Flash the board - sudo esptool.py write_flash 0x00000 demo_client-0x00000.bin 0x40000 demo_client-0x40000.bin \ No newline at end of file diff --git a/libs/kaa/UNTAR_KAA_SDK_HERE b/libs/kaa/UNTAR_KAA_SDK_HERE deleted file mode 100644 index e69de29..0000000 diff --git a/src/kaa_demo.c b/src/kaa_demo.c deleted file mode 100644 index 6c33233..0000000 --- a/src/kaa_demo.c +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Copyright 2014-2016 CyberVision, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "target_gpio_led.h" -#include "target.h" - -#define DEMO_USER "user" -#define DEMO_TOKEN "token" - -static kaa_client_t *kaa_client = NULL; - -static int gpio_led[NUM_GPIO_LEDS]; - -/* - * Event callback-s. - */ -static void kaa_device_info_request(void *context - , kaa_remote_control_ecf_device_info_request_t *event - , kaa_endpoint_id_p source) -{ - (void)context; - (void)source; - - kaa_remote_control_ecf_device_info_response_t *response = kaa_remote_control_ecf_device_info_response_create(); - - response->device_name = kaa_string_copy_create(TARGET_DEVICE_NAME); - response->model = kaa_string_copy_create(TARGET_MODEL_NAME); - response->gpio_status = kaa_list_create(); - - for (int i = 0; i < NUM_GPIO_LEDS; ++i) { - kaa_remote_control_ecf_gpio_status_t *gio_status = kaa_remote_control_ecf_gpio_status_create(); - gio_status->id = i; - gio_status->status = gpio_led[i]; - kaa_list_push_back(response->gpio_status, (void*)gio_status); - } - - kaa_event_manager_send_kaa_remote_control_ecf_device_info_response(kaa_client_get_context(kaa_client)->event_manager, response, NULL); - - response->destroy(response); // Destroying event that was successfully sent - event->destroy(event); -} - -static void kaa_gpio_toggle_request(void *context - , kaa_remote_control_ecf_gpio_toggle_request_t *event - , kaa_endpoint_id_p source) -{ - (void)context; - (void)source; - - if (event->gpio->id >= NUM_GPIO_LEDS) { - event->destroy(event); - return; - } - - demo_printf("Toggling GPIO: id = %d...\r\n", event->gpio->id); - - target_gpio_led_toggle(event->gpio->id, event->gpio->status); - gpio_led[event->gpio->id] = event->gpio->status; - - event->destroy(event); -} - -int main(void) -{ - int rc = target_initialize(); - if (rc < 0) { - return 1; - } - - target_gpio_led_init(); - - /** - * Initialize Kaa client. - */ - kaa_error_t error_code = kaa_client_create(&kaa_client, NULL); - if (error_code) { - return error_code; - } - - error_code = kaa_profile_manager_set_endpoint_access_token(kaa_client_get_context(kaa_client)->profile_manager, - DEMO_TOKEN); - - error_code = kaa_user_manager_default_attach_to_user(kaa_client_get_context(kaa_client)->user_manager - , DEMO_USER - , DEMO_TOKEN); - if (error_code) { - goto exit; - } - - error_code = kaa_event_manager_set_kaa_remote_control_ecf_device_info_request_listener(kaa_client_get_context(kaa_client)->event_manager, - kaa_device_info_request, - NULL); - - if (error_code) { - goto exit; - } - - error_code = kaa_event_manager_set_kaa_remote_control_ecf_gpio_toggle_request_listener(kaa_client_get_context(kaa_client)->event_manager, - kaa_gpio_toggle_request, - NULL); - - if (error_code) { - goto exit; - } - - demo_printf("Start Kaa\r\n"); - /** - * Start Kaa client main loop. - */ - error_code = kaa_client_start(kaa_client, 0, NULL, 0); - if (error_code) { - goto exit; - } - -exit: - /** - * Destroy Kaa client. - */ - kaa_client_destroy(kaa_client); - - return error_code; -} diff --git a/target/esp8266/CMakeLists.txt b/target/esp8266/CMakeLists.txt deleted file mode 100644 index c8dba62..0000000 --- a/target/esp8266/CMakeLists.txt +++ /dev/null @@ -1,72 +0,0 @@ -# -# Copyright 2014-2016 CyberVision, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -cmake_minimum_required(VERSION 2.8) - -if(NOT DEFINED ESP_RTOS_SDK) - set(ESP_RTOS_SDK /opt/Espressif/esp-rtos-sdk) -endif() - -exec_program(xtensa-lx106-elf-gcc . - ARGS -print-libgcc-file-name - OUTPUT_VARIABLE ESP8266_LIBGCC) - -add_library(target_support - STATIC - target.c - target_gpio_led.c - driver/uart.c - driver/gpio.c) - -target_include_directories(target_support PUBLIC driver) -target_include_directories(target_support PUBLIC .) -target_include_directories(target_support PUBLIC - ${ESP_RTOS_SDK}/extra_include - ${ESP_RTOS_SDK}/include - ${ESP_RTOS_SDK}/include/lwip - ${ESP_RTOS_SDK}/include/lwip/ipv4 - ${ESP_RTOS_SDK}/include/lwip/ipv6 - ${ESP_RTOS_SDK}/include/espressif/ - ${ESP_RTOS_SDK}/include/espressif/esp8266) -# specify linker script -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ld/eagle.rom.addr.v6.ld ${CMAKE_BINARY_DIR}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ld/eagle.app.v6.ld ${CMAKE_BINARY_DIR}) - -# ESP8266 RTOS SDK dependencies -target_link_libraries(target_support PUBLIC - ${ESP_RTOS_SDK}/lib/libfreertos.a - ${ESP_RTOS_SDK}/lib/libhal.a - ${ESP_RTOS_SDK}/lib/libpp.a - ${ESP_RTOS_SDK}/lib/libphy.a - ${ESP_RTOS_SDK}/lib/libnet80211.a - ${ESP_RTOS_SDK}/lib/libwpa.a - ${ESP_RTOS_SDK}/lib/liblwip.a - ${ESP_RTOS_SDK}/lib/libmain.a - ${ESP_RTOS_SDK}/lib/libssl.a - ${ESP8266_LIBGCC} - -T${CMAKE_CURRENT_SOURCE_DIR}/ld/eagle.app.v6.ld - ) - -message(STATUS "WiFi AP: ${WIFI_SSID}") -message(STATUS "WiFi Pass: ${WIFI_PASSWORD}") - -# Expose WiFi credentials -target_compile_definitions(target_support - PUBLIC - -DWIFI_SSID="${WIFI_SSID}" - -DWIFI_PASSWORD="${WIFI_PASSWORD}" - -DDEMO_ACCESS_TOKEN="${DEMO_ACCESS_TOKEN}") - diff --git a/target/esp8266/driver/gpio.c b/target/esp8266/driver/gpio.c deleted file mode 100644 index f15b153..0000000 --- a/target/esp8266/driver/gpio.c +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (C) 2014 -2016 Espressif System - * - */ - -#include "espressif/esp_common.h" -#include "freertos/portmacro.h" -#include "gpio.h" - -void ICACHE_FLASH_ATTR -gpio_config(GPIO_ConfigTypeDef *pGPIOConfig) -{ - uint16_t gpio_pin_mask = pGPIOConfig->GPIO_Pin; - uint32_t io_reg; - uint8_t io_num = 0; - uint32_t pin_reg; - - if (pGPIOConfig->GPIO_Mode == GPIO_Mode_Input) { - GPIO_AS_INPUT(gpio_pin_mask); - } else if (pGPIOConfig->GPIO_Mode == GPIO_Mode_Output) { - GPIO_AS_OUTPUT(gpio_pin_mask); - } - - do { - if ((gpio_pin_mask >> io_num) & 0x1) { - io_reg = GPIO_PIN_REG(io_num); - - if ((0x1 << io_num) & (GPIO_Pin_0 | GPIO_Pin_2 | GPIO_Pin_4 | GPIO_Pin_5)) { - PIN_FUNC_SELECT(io_reg, 0); - } else { - PIN_FUNC_SELECT(io_reg, 3); - } - - if (pGPIOConfig->GPIO_Pullup) { - PIN_PULLUP_EN(io_reg); - } else { - PIN_PULLUP_DIS(io_reg); - } - - if (pGPIOConfig->GPIO_Mode == GPIO_Mode_Out_OD) { - portENTER_CRITICAL(); - - pin_reg = GPIO_REG_READ(GPIO_PIN_ADDR(io_num)); - pin_reg &= (~GPIO_PIN_DRIVER_MASK); - pin_reg |= (GPIO_PAD_DRIVER_ENABLE << GPIO_PIN_DRIVER_LSB); - GPIO_REG_WRITE(GPIO_PIN_ADDR(io_num), pin_reg); - - portEXIT_CRITICAL(); - } else if (pGPIOConfig->GPIO_Mode == GPIO_Mode_Sigma_Delta) { - portENTER_CRITICAL(); - - pin_reg = GPIO_REG_READ(GPIO_PIN_ADDR(io_num)); - pin_reg &= (~GPIO_PIN_SOURCE_MASK); - pin_reg |= (0x1 << GPIO_PIN_SOURCE_LSB); - GPIO_REG_WRITE(GPIO_PIN_ADDR(io_num), pin_reg); - GPIO_REG_WRITE(GPIO_SIGMA_DELTA_ADDRESS, SIGMA_DELTA_ENABLE); - - portEXIT_CRITICAL(); - } - - gpio_pin_intr_state_set(io_num, pGPIOConfig->GPIO_IntrType); - } - - io_num++; - } while (io_num < 16); -} - - -/* - * Change GPIO pin output by setting, clearing, or disabling pins. - * In general, it is expected that a bit will be set in at most one - * of these masks. If a bit is clear in all masks, the output state - * remains unchanged. - * - * There is no particular ordering guaranteed; so if the order of - * writes is significant, calling code should divide a single call - * into multiple calls. - */ -void ICACHE_FLASH_ATTR -gpio_output_conf(uint32_t set_mask, uint32_t clear_mask, uint32_t enable_mask, uint32_t disable_mask) -{ - GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, set_mask); - GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, clear_mask); - GPIO_REG_WRITE(GPIO_ENABLE_W1TS_ADDRESS, enable_mask); - GPIO_REG_WRITE(GPIO_ENABLE_W1TC_ADDRESS, disable_mask); -} - -/* - * Sample the value of GPIO input pins and returns a bitmask. - */ -uint32_t ICACHE_FLASH_ATTR -gpio_input_get(void) -{ - return GPIO_REG_READ(GPIO_IN_ADDRESS); -} - -/* - * Register an application-specific interrupt handler for GPIO pin - * interrupts. Once the interrupt handler is called, it will not - * be called again until after a call to gpio_intr_ack. Any GPIO - * interrupts that occur during the interim are masked. - * - * The application-specific handler is called with a mask of - * pending GPIO interrupts. After processing pin interrupts, the - * application-specific handler may wish to use gpio_intr_pending - * to check for any additional pending interrupts before it returns. - */ -void ICACHE_FLASH_ATTR -gpio_intr_handler_register(void *fn) -{ - _xt_isr_attach(ETS_GPIO_INUM, fn); -} - -/* - only highlevel and lowlevel intr can use for wakeup -*/ -void ICACHE_FLASH_ATTR -gpio_pin_wakeup_enable(uint32_t i, GPIO_INT_TYPE intr_state) -{ - uint32_t pin_reg; - - if ((intr_state == GPIO_PIN_INTR_LOLEVEL) || (intr_state == GPIO_PIN_INTR_HILEVEL)) { - portENTER_CRITICAL(); - - pin_reg = GPIO_REG_READ(GPIO_PIN_ADDR(i)); - pin_reg &= (~GPIO_PIN_INT_TYPE_MASK); - pin_reg |= (intr_state << GPIO_PIN_INT_TYPE_LSB); - pin_reg |= GPIO_PIN_WAKEUP_ENABLE_SET(GPIO_WAKEUP_ENABLE); - GPIO_REG_WRITE(GPIO_PIN_ADDR(i), pin_reg); - - portEXIT_CRITICAL(); - } -} - -void ICACHE_FLASH_ATTR -gpio_pin_wakeup_disable(void) -{ - uint8_t i; - uint32_t pin_reg; - - for (i = 0; i < GPIO_PIN_COUNT; i++) { - pin_reg = GPIO_REG_READ(GPIO_PIN_ADDR(i)); - - if (pin_reg & GPIO_PIN_WAKEUP_ENABLE_MASK) { - pin_reg &= (~GPIO_PIN_INT_TYPE_MASK); - pin_reg |= (GPIO_PIN_INTR_DISABLE << GPIO_PIN_INT_TYPE_LSB); - pin_reg &= ~(GPIO_PIN_WAKEUP_ENABLE_SET(GPIO_WAKEUP_ENABLE)); - GPIO_REG_WRITE(GPIO_PIN_ADDR(i), pin_reg); - } - } -} - -void ICACHE_FLASH_ATTR -gpio_pin_intr_state_set(uint32_t i, GPIO_INT_TYPE intr_state) -{ - uint32_t pin_reg; - - portENTER_CRITICAL(); - - pin_reg = GPIO_REG_READ(GPIO_PIN_ADDR(i)); - pin_reg &= (~GPIO_PIN_INT_TYPE_MASK); - pin_reg |= (intr_state << GPIO_PIN_INT_TYPE_LSB); - GPIO_REG_WRITE(GPIO_PIN_ADDR(i), pin_reg); - - portEXIT_CRITICAL(); -} - -void ICACHE_FLASH_ATTR -gpio16_output_conf(void) -{ - WRITE_PERI_REG(PAD_XPD_DCDC_CONF, - (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32_t)0x1); // mux configuration for XPD_DCDC to output rtc_gpio0 - - WRITE_PERI_REG(RTC_GPIO_CONF, - (READ_PERI_REG(RTC_GPIO_CONF) & (uint32_t)0xfffffffe) | (uint32_t)0x0); //mux configuration for out enable - - WRITE_PERI_REG(RTC_GPIO_ENABLE, - (READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32_t)0xfffffffe) | (uint32_t)0x1); //out enable -} - -void ICACHE_FLASH_ATTR -gpio16_output_set(uint8_t value) -{ - WRITE_PERI_REG(RTC_GPIO_OUT, - (READ_PERI_REG(RTC_GPIO_OUT) & (uint32_t)0xfffffffe) | (uint32_t)(value & 1)); -} - -void ICACHE_FLASH_ATTR -gpio16_input_conf(void) -{ - WRITE_PERI_REG(PAD_XPD_DCDC_CONF, - (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32_t)0x1); // mux configuration for XPD_DCDC and rtc_gpio0 connection - - WRITE_PERI_REG(RTC_GPIO_CONF, - (READ_PERI_REG(RTC_GPIO_CONF) & (uint32_t)0xfffffffe) | (uint32_t)0x0); //mux configuration for out enable - - WRITE_PERI_REG(RTC_GPIO_ENABLE, - READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32_t)0xfffffffe); //out disable -} - -uint8_t ICACHE_FLASH_ATTR -gpio16_input_get(void) -{ - return (uint8_t)(READ_PERI_REG(RTC_GPIO_IN_DATA) & 1); -} - diff --git a/target/esp8266/driver/gpio.h b/target/esp8266/driver/gpio.h deleted file mode 100644 index 1a6ebe4..0000000 --- a/target/esp8266/driver/gpio.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2014 -2016 Espressif System - * - */ - -#ifndef __GPIO_H__ -#define __GPIO_H__ - -#define GPIO_Pin_0 (BIT(0)) /* Pin 0 selected */ -#define GPIO_Pin_1 (BIT(1)) /* Pin 1 selected */ -#define GPIO_Pin_2 (BIT(2)) /* Pin 2 selected */ -#define GPIO_Pin_3 (BIT(3)) /* Pin 3 selected */ -#define GPIO_Pin_4 (BIT(4)) /* Pin 4 selected */ -#define GPIO_Pin_5 (BIT(5)) /* Pin 5 selected */ -#define GPIO_Pin_6 (BIT(6)) /* Pin 6 selected */ -#define GPIO_Pin_7 (BIT(7)) /* Pin 7 selected */ -#define GPIO_Pin_8 (BIT(8)) /* Pin 8 selected */ -#define GPIO_Pin_9 (BIT(9)) /* Pin 9 selected */ -#define GPIO_Pin_10 (BIT(10)) /* Pin 10 selected */ -#define GPIO_Pin_11 (BIT(11)) /* Pin 11 selected */ -#define GPIO_Pin_12 (BIT(12)) /* Pin 12 selected */ -#define GPIO_Pin_13 (BIT(13)) /* Pin 13 selected */ -#define GPIO_Pin_14 (BIT(14)) /* Pin 14 selected */ -#define GPIO_Pin_15 (BIT(15)) /* Pin 15 selected */ -#define GPIO_Pin_All (0xFFFF) /* All pins selected */ - -#define GPIO_PIN_REG_0 PERIPHS_IO_MUX_GPIO0_U -#define GPIO_PIN_REG_1 PERIPHS_IO_MUX_U0TXD_U -#define GPIO_PIN_REG_2 PERIPHS_IO_MUX_GPIO2_U -#define GPIO_PIN_REG_3 PERIPHS_IO_MUX_U0RXD_U -#define GPIO_PIN_REG_4 PERIPHS_IO_MUX_GPIO4_U -#define GPIO_PIN_REG_5 PERIPHS_IO_MUX_GPIO5_U -#define GPIO_PIN_REG_6 PERIPHS_IO_MUX_SD_CLK_U -#define GPIO_PIN_REG_7 PERIPHS_IO_MUX_SD_DATA0_U -#define GPIO_PIN_REG_8 PERIPHS_IO_MUX_SD_DATA1_U -#define GPIO_PIN_REG_9 PERIPHS_IO_MUX_SD_DATA2_U -#define GPIO_PIN_REG_10 PERIPHS_IO_MUX_SD_DATA3_U -#define GPIO_PIN_REG_11 PERIPHS_IO_MUX_SD_CMD_U -#define GPIO_PIN_REG_12 PERIPHS_IO_MUX_MTDI_U -#define GPIO_PIN_REG_13 PERIPHS_IO_MUX_MTCK_U -#define GPIO_PIN_REG_14 PERIPHS_IO_MUX_MTMS_U -#define GPIO_PIN_REG_15 PERIPHS_IO_MUX_MTDO_U - -#define GPIO_PIN_REG(i) \ - (i==0) ? GPIO_PIN_REG_0: \ - (i==1) ? GPIO_PIN_REG_1: \ - (i==2) ? GPIO_PIN_REG_2: \ - (i==3) ? GPIO_PIN_REG_3: \ - (i==4) ? GPIO_PIN_REG_4: \ - (i==5) ? GPIO_PIN_REG_5: \ - (i==6) ? GPIO_PIN_REG_6: \ - (i==7) ? GPIO_PIN_REG_7: \ - (i==8) ? GPIO_PIN_REG_8: \ - (i==9) ? GPIO_PIN_REG_9: \ - (i==10)? GPIO_PIN_REG_10: \ - (i==11)? GPIO_PIN_REG_11: \ - (i==12)? GPIO_PIN_REG_12: \ - (i==13)? GPIO_PIN_REG_13: \ - (i==14)? GPIO_PIN_REG_14: \ - GPIO_PIN_REG_15 - -#define GPIO_PIN_ADDR(i) (GPIO_PIN0_ADDRESS + i*4) - -#define GPIO_ID_IS_PIN_REGISTER(reg_id) \ - (((reg_id) >= GPIO_ID_PIN0) && ((reg_id) <= GPIO_ID_PIN(GPIO_PIN_COUNT-1))) - -#define GPIO_REGID_TO_PINIDX(reg_id) ((reg_id) - GPIO_ID_PIN0) - -typedef enum { - GPIO_PIN_INTR_DISABLE = 0, - GPIO_PIN_INTR_POSEDGE = 1, - GPIO_PIN_INTR_NEGEDGE = 2, - GPIO_PIN_INTR_ANYEGDE = 3, - GPIO_PIN_INTR_LOLEVEL = 4, - GPIO_PIN_INTR_HILEVEL = 5 -} GPIO_INT_TYPE; - -typedef enum { - GPIO_Mode_Input = 0x0, - GPIO_Mode_Out_OD, - GPIO_Mode_Output, - GPIO_Mode_Sigma_Delta, -} GPIOMode_TypeDef; - -typedef enum { - GPIO_PullUp_DIS = 0x0, - GPIO_PullUp_EN = 0x1, -} GPIO_Pullup_IF; - -typedef struct { - uint16_t GPIO_Pin; - GPIOMode_TypeDef GPIO_Mode; - GPIO_Pullup_IF GPIO_Pullup; - GPIO_INT_TYPE GPIO_IntrType; -} GPIO_ConfigTypeDef; - -#define GPIO_OUTPUT_SET(gpio_no, bit_value) \ - gpio_output_conf((bit_value) << (gpio_no), \ - ((~(bit_value)) & 0x01) << (gpio_no), 1 << (gpio_no), 0) - -#define GPIO_OUTPUT(gpio_bits, bit_value) do {\ - if (bit_value) gpio_output_conf((gpio_bits), 0, (gpio_bits), 0);\ - else gpio_output_conf(0, (gpio_bits), (gpio_bits), 0) \ - } while(0) - -#define GPIO_DIS_OUTPUT(gpio_no) gpio_output_conf(0, 0, 0, 1 << (gpio_no)) -#define GPIO_AS_INPUT(gpio_bits) gpio_output_conf(0, 0, 0, gpio_bits) -#define GPIO_AS_OUTPUT(gpio_bits) gpio_output_conf(0, 0, gpio_bits, 0) -#define GPIO_INPUT_GET(gpio_no) ((gpio_input_get() >> (gpio_no)) & BIT0) - -void gpio16_output_conf(void); -void gpio16_output_set(uint8_t value); -void gpio16_input_conf(void); -uint8_t gpio16_input_get(void); - -void gpio_output_conf(uint32_t set_mask, uint32_t clear_mask, uint32_t enable_mask, uint32_t disable_mask); -void gpio_intr_handler_register(void *fn); -void gpio_pin_wakeup_enable(uint32_t i, GPIO_INT_TYPE intr_state); -void gpio_pin_wakeup_disable(void); -void gpio_pin_intr_state_set(uint32_t i, GPIO_INT_TYPE intr_state); -uint32_t gpio_input_get(void); - -#endif diff --git a/target/esp8266/driver/uart.c b/target/esp8266/driver/uart.c deleted file mode 100644 index 1425b4e..0000000 --- a/target/esp8266/driver/uart.c +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright (C) 2014 -2016 Espressif System - * - */ - - -#include "esp_common.h" -#include "uart.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/queue.h" - - -enum { - UART_EVENT_RX_CHAR, - UART_EVENT_MAX -}; - -typedef struct _os_event_ { - uint32 event; - uint32 param; -} os_event_t; - -xTaskHandle xUartTaskHandle; -xQueueHandle xQueueUart; - -LOCAL STATUS -uart_tx_one_char(uint8 uart, uint8 TxChar) -{ - while (true) { - uint32 fifo_cnt = READ_PERI_REG(UART_STATUS(uart)) & (UART_TXFIFO_CNT << UART_TXFIFO_CNT_S); - - if ((fifo_cnt >> UART_TXFIFO_CNT_S & UART_TXFIFO_CNT) < 126) { - break; - } - } - - WRITE_PERI_REG(UART_FIFO(uart) , TxChar); - return OK; -} - -LOCAL void -uart1_write_char(char c) -{ - if (c == '\n') { - uart_tx_one_char(UART1, '\r'); - uart_tx_one_char(UART1, '\n'); - } else if (c == '\r') { - } else { - uart_tx_one_char(UART1, c); - } -} - -void -uart0_write_char(char c) -{ - if (c == '\n') { - uart_tx_one_char(UART0, '\r'); - uart_tx_one_char(UART0, '\n'); - } else if (c == '\r') { - } else { - uart_tx_one_char(UART0, c); - } -} - -void ICACHE_FLASH_ATTR -UART_SetWordLength(UART_Port uart_no, UART_WordLength len) -{ - SET_PERI_REG_BITS(UART_CONF0(uart_no), UART_BIT_NUM, len, UART_BIT_NUM_S); -} - -void ICACHE_FLASH_ATTR -UART_SetStopBits(UART_Port uart_no, UART_StopBits bit_num) -{ - SET_PERI_REG_BITS(UART_CONF0(uart_no), UART_STOP_BIT_NUM, bit_num, UART_STOP_BIT_NUM_S); -} - -void ICACHE_FLASH_ATTR -UART_SetLineInverse(UART_Port uart_no, UART_LineLevelInverse inverse_mask) -{ - CLEAR_PERI_REG_MASK(UART_CONF0(uart_no), UART_LINE_INV_MASK); - SET_PERI_REG_MASK(UART_CONF0(uart_no), inverse_mask); -} - -void ICACHE_FLASH_ATTR -UART_SetParity(UART_Port uart_no, UART_ParityMode Parity_mode) -{ - CLEAR_PERI_REG_MASK(UART_CONF0(uart_no), UART_PARITY | UART_PARITY_EN); - - if (Parity_mode == USART_Parity_None) { - } else { - SET_PERI_REG_MASK(UART_CONF0(uart_no), Parity_mode | UART_PARITY_EN); - } -} - -void ICACHE_FLASH_ATTR -UART_SetBaudrate(UART_Port uart_no, uint32 baud_rate) -{ - uart_div_modify(uart_no, UART_CLK_FREQ / baud_rate); -} - -//only when USART_HardwareFlowControl_RTS is set , will the rx_thresh value be set. -void ICACHE_FLASH_ATTR -UART_SetFlowCtrl(UART_Port uart_no, UART_HwFlowCtrl flow_ctrl, uint8 rx_thresh) -{ - if (flow_ctrl & USART_HardwareFlowControl_RTS) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_U0RTS); - SET_PERI_REG_BITS(UART_CONF1(uart_no), UART_RX_FLOW_THRHD, rx_thresh, UART_RX_FLOW_THRHD_S); - SET_PERI_REG_MASK(UART_CONF1(uart_no), UART_RX_FLOW_EN); - } else { - CLEAR_PERI_REG_MASK(UART_CONF1(uart_no), UART_RX_FLOW_EN); - } - - if (flow_ctrl & USART_HardwareFlowControl_CTS) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_UART0_CTS); - SET_PERI_REG_MASK(UART_CONF0(uart_no), UART_TX_FLOW_EN); - } else { - CLEAR_PERI_REG_MASK(UART_CONF0(uart_no), UART_TX_FLOW_EN); - } -} - -void ICACHE_FLASH_ATTR -UART_WaitTxFifoEmpty(UART_Port uart_no) //do not use if tx flow control enabled -{ - while (READ_PERI_REG(UART_STATUS(uart_no)) & (UART_TXFIFO_CNT << UART_TXFIFO_CNT_S)); -} - -void ICACHE_FLASH_ATTR -UART_ResetFifo(UART_Port uart_no) -{ - SET_PERI_REG_MASK(UART_CONF0(uart_no), UART_RXFIFO_RST | UART_TXFIFO_RST); - CLEAR_PERI_REG_MASK(UART_CONF0(uart_no), UART_RXFIFO_RST | UART_TXFIFO_RST); -} - -void ICACHE_FLASH_ATTR -UART_ClearIntrStatus(UART_Port uart_no, uint32 clr_mask) -{ - WRITE_PERI_REG(UART_INT_CLR(uart_no), clr_mask); -} - -void ICACHE_FLASH_ATTR -UART_SetIntrEna(UART_Port uart_no, uint32 ena_mask) -{ - SET_PERI_REG_MASK(UART_INT_ENA(uart_no), ena_mask); -} - -void ICACHE_FLASH_ATTR -UART_intr_handler_register(void *fn) -{ - _xt_isr_attach(ETS_UART_INUM, fn); -} - -void ICACHE_FLASH_ATTR -UART_SetPrintPort(UART_Port uart_no) -{ - if (uart_no == 1) { - os_install_putc1(uart1_write_char); - } else { - os_install_putc1(uart0_write_char); - } -} - -void ICACHE_FLASH_ATTR -UART_ParamConfig(UART_Port uart_no, UART_ConfigTypeDef *pUARTConfig) -{ - if (uart_no == UART1) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_U1TXD_BK); - } else { - PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U); - PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD); - PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD); - } - - UART_SetFlowCtrl(uart_no, pUARTConfig->flow_ctrl, pUARTConfig->UART_RxFlowThresh); - UART_SetBaudrate(uart_no, pUARTConfig->baud_rate); - - WRITE_PERI_REG(UART_CONF0(uart_no), - ((pUARTConfig->parity == USART_Parity_None) ? 0x0 : (UART_PARITY_EN | pUARTConfig->parity)) - | (pUARTConfig->stop_bits << UART_STOP_BIT_NUM_S) - | (pUARTConfig->data_bits << UART_BIT_NUM_S) - | ((pUARTConfig->flow_ctrl & USART_HardwareFlowControl_CTS) ? UART_TX_FLOW_EN : 0x0) - | pUARTConfig->UART_InverseMask); - - UART_ResetFifo(uart_no); -} - -void ICACHE_FLASH_ATTR -UART_IntrConfig(UART_Port uart_no, UART_IntrConfTypeDef *pUARTIntrConf) -{ - - uint32 reg_val = 0; - UART_ClearIntrStatus(uart_no, UART_INTR_MASK); - reg_val = READ_PERI_REG(UART_CONF1(uart_no)) & ~((UART_RX_FLOW_THRHD << UART_RX_FLOW_THRHD_S) | UART_RX_FLOW_EN) ; - - reg_val |= ((pUARTIntrConf->UART_IntrEnMask & UART_RXFIFO_TOUT_INT_ENA) ? - ((((pUARTIntrConf->UART_RX_TimeOutIntrThresh)&UART_RX_TOUT_THRHD) << UART_RX_TOUT_THRHD_S) | UART_RX_TOUT_EN) : 0); - - reg_val |= ((pUARTIntrConf->UART_IntrEnMask & UART_RXFIFO_FULL_INT_ENA) ? - (((pUARTIntrConf->UART_RX_FifoFullIntrThresh)&UART_RXFIFO_FULL_THRHD) << UART_RXFIFO_FULL_THRHD_S) : 0); - - reg_val |= ((pUARTIntrConf->UART_IntrEnMask & UART_TXFIFO_EMPTY_INT_ENA) ? - (((pUARTIntrConf->UART_TX_FifoEmptyIntrThresh)&UART_TXFIFO_EMPTY_THRHD) << UART_TXFIFO_EMPTY_THRHD_S) : 0); - - WRITE_PERI_REG(UART_CONF1(uart_no), reg_val); - CLEAR_PERI_REG_MASK(UART_INT_ENA(uart_no), UART_INTR_MASK); - SET_PERI_REG_MASK(UART_INT_ENA(uart_no), pUARTIntrConf->UART_IntrEnMask); -} - -LOCAL void -uart0_rx_intr_handler(void *para) -{ - /* uart0 and uart1 intr combine togther, when interrupt occur, see reg 0x3ff20020, bit2, bit0 represents - * uart1 and uart0 respectively - */ - (void)para; - uint8 uart_no = UART0;//UartDev.buff_uart_no; - uint8 fifo_len = 0; - uint8 buf_idx = 0; - - uint32 uart_intr_status = READ_PERI_REG(UART_INT_ST(uart_no)) ; - - while (uart_intr_status != 0x0) { - if (UART_FRM_ERR_INT_ST == (uart_intr_status & UART_FRM_ERR_INT_ST)) { - //printf("FRM_ERR\r\n"); - WRITE_PERI_REG(UART_INT_CLR(uart_no), UART_FRM_ERR_INT_CLR); - } else if (UART_RXFIFO_FULL_INT_ST == (uart_intr_status & UART_RXFIFO_FULL_INT_ST)) { - printf("full\r\n"); - fifo_len = (READ_PERI_REG(UART_STATUS(UART0)) >> UART_RXFIFO_CNT_S)&UART_RXFIFO_CNT; - buf_idx = 0; - - while (buf_idx < fifo_len) { - uart_tx_one_char(UART0, READ_PERI_REG(UART_FIFO(UART0)) & 0xFF); - buf_idx++; - } - - WRITE_PERI_REG(UART_INT_CLR(UART0), UART_RXFIFO_FULL_INT_CLR); - } else if (UART_RXFIFO_TOUT_INT_ST == (uart_intr_status & UART_RXFIFO_TOUT_INT_ST)) { - printf("tout\r\n"); - fifo_len = (READ_PERI_REG(UART_STATUS(UART0)) >> UART_RXFIFO_CNT_S)&UART_RXFIFO_CNT; - buf_idx = 0; - - while (buf_idx < fifo_len) { - uart_tx_one_char(UART0, READ_PERI_REG(UART_FIFO(UART0)) & 0xFF); - buf_idx++; - } - - WRITE_PERI_REG(UART_INT_CLR(UART0), UART_RXFIFO_TOUT_INT_CLR); - } else if (UART_TXFIFO_EMPTY_INT_ST == (uart_intr_status & UART_TXFIFO_EMPTY_INT_ST)) { - printf("empty\n\r"); - WRITE_PERI_REG(UART_INT_CLR(uart_no), UART_TXFIFO_EMPTY_INT_CLR); - CLEAR_PERI_REG_MASK(UART_INT_ENA(UART0), UART_TXFIFO_EMPTY_INT_ENA); - } else { - //skip - } - - uart_intr_status = READ_PERI_REG(UART_INT_ST(uart_no)) ; - } -} - -void ICACHE_FLASH_ATTR -uart_init_new(void) -{ - UART_WaitTxFifoEmpty(UART0); - UART_WaitTxFifoEmpty(UART1); - - UART_ConfigTypeDef uart_config; - uart_config.baud_rate = BIT_RATE_115200; - uart_config.data_bits = UART_WordLength_8b; - uart_config.parity = USART_Parity_None; - uart_config.stop_bits = USART_StopBits_1; - uart_config.flow_ctrl = USART_HardwareFlowControl_None; - uart_config.UART_RxFlowThresh = 120; - uart_config.UART_InverseMask = UART_None_Inverse; - UART_ParamConfig(UART0, &uart_config); - - UART_IntrConfTypeDef uart_intr; - uart_intr.UART_IntrEnMask = UART_RXFIFO_TOUT_INT_ENA | UART_FRM_ERR_INT_ENA | UART_RXFIFO_FULL_INT_ENA | UART_TXFIFO_EMPTY_INT_ENA; - uart_intr.UART_RX_FifoFullIntrThresh = 10; - uart_intr.UART_RX_TimeOutIntrThresh = 2; - uart_intr.UART_TX_FifoEmptyIntrThresh = 20; - UART_IntrConfig(UART0, &uart_intr); - - UART_SetPrintPort(UART0); - UART_intr_handler_register(uart0_rx_intr_handler); - ETS_UART_INTR_ENABLE(); - - /* - UART_SetWordLength(UART0,UART_WordLength_8b); - UART_SetStopBits(UART0,USART_StopBits_1); - UART_SetParity(UART0,USART_Parity_None); - UART_SetBaudrate(UART0,74880); - UART_SetFlowCtrl(UART0,USART_HardwareFlowControl_None,0); - */ - -} - -int uart_getchar(void) -{ - // Wait until data arrives to RX FIFO - while (!((READ_PERI_REG(UART_STATUS(UART0)) >> UART_RXFIFO_CNT_S) & UART_RXFIFO_CNT)); - - return READ_PERI_REG(UART_FIFO(UART0)) & 0xFF; -} diff --git a/target/esp8266/driver/uart.h b/target/esp8266/driver/uart.h deleted file mode 100644 index 6df029c..0000000 --- a/target/esp8266/driver/uart.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2010 -2011 Espressif System - * - */ - -#ifndef __UART_H__ -#define __UART_H__ -#define ETS_UART_INTR_ENABLE() _xt_isr_unmask(1 << ETS_UART_INUM) -#define ETS_UART_INTR_DISABLE() _xt_isr_mask(1 << ETS_UART_INUM) -#define UART_INTR_MASK 0x1ff -#define UART_LINE_INV_MASK (0x3f<<19) - -typedef enum { - UART_WordLength_5b = 0x0, - UART_WordLength_6b = 0x1, - UART_WordLength_7b = 0x2, - UART_WordLength_8b = 0x3 -} UART_WordLength; - -typedef enum { - USART_StopBits_1 = 0x1, - USART_StopBits_1_5 = 0x2, - USART_StopBits_2 = 0x3, -} UART_StopBits; - -typedef enum { - UART0 = 0x0, - UART1 = 0x1, -} UART_Port; - -typedef enum { - USART_Parity_None = 0x2, - USART_Parity_Even = 0x0, - USART_Parity_Odd = 0x1 -} UART_ParityMode; - -typedef enum { - PARITY_DIS = 0x0, - PARITY_EN = 0x2 -} UartExistParity; - -typedef enum { - BIT_RATE_300 = 300, - BIT_RATE_600 = 600, - BIT_RATE_1200 = 1200, - BIT_RATE_2400 = 2400, - BIT_RATE_4800 = 4800, - BIT_RATE_9600 = 9600, - BIT_RATE_19200 = 19200, - BIT_RATE_38400 = 38400, - BIT_RATE_57600 = 57600, - BIT_RATE_74880 = 74880, - BIT_RATE_115200 = 115200, - BIT_RATE_230400 = 230400, - BIT_RATE_460800 = 460800, - BIT_RATE_921600 = 921600, - BIT_RATE_1843200 = 1843200, - BIT_RATE_3686400 = 3686400, -} UART_BautRate; //you can add any rate you need in this range - -typedef enum { - USART_HardwareFlowControl_None = 0x0, - USART_HardwareFlowControl_RTS = 0x1, - USART_HardwareFlowControl_CTS = 0x2, - USART_HardwareFlowControl_CTS_RTS = 0x3 -} UART_HwFlowCtrl; - -typedef enum { - UART_None_Inverse = 0x0, - UART_Rxd_Inverse = UART_RXD_INV, - UART_CTS_Inverse = UART_CTS_INV, - UART_Txd_Inverse = UART_TXD_INV, - UART_RTS_Inverse = UART_RTS_INV, -} UART_LineLevelInverse; - -typedef struct { - UART_BautRate baud_rate; - UART_WordLength data_bits; - UART_ParityMode parity; // chip size in byte - UART_StopBits stop_bits; - UART_HwFlowCtrl flow_ctrl; - uint8 UART_RxFlowThresh ; - uint32 UART_InverseMask; -} UART_ConfigTypeDef; - -typedef struct { - uint32 UART_IntrEnMask; - uint8 UART_RX_TimeOutIntrThresh; - uint8 UART_TX_FifoEmptyIntrThresh; - uint8 UART_RX_FifoFullIntrThresh; -} UART_IntrConfTypeDef; - -//======================================= -void UART_WaitTxFifoEmpty(UART_Port uart_no); //do not use if tx flow control enabled -void UART_ResetFifo(UART_Port uart_no); -void UART_ClearIntrStatus(UART_Port uart_no, uint32 clr_mask); -void UART_SetIntrEna(UART_Port uart_no, uint32 ena_mask); -void UART_intr_handler_register(void *fn); -void UART_SetPrintPort(UART_Port uart_no); -void UART_ParamConfig(UART_Port uart_no, UART_ConfigTypeDef *pUARTConfig); -void UART_IntrConfig(UART_Port uart_no, UART_IntrConfTypeDef *pUARTIntrConf); -void UART_SetWordLength(UART_Port uart_no, UART_WordLength len); -void UART_SetStopBits(UART_Port uart_no, UART_StopBits bit_num); -void UART_SetParity(UART_Port uart_no, UART_ParityMode Parity_mode) ; -void UART_SetBaudrate(UART_Port uart_no, uint32 baud_rate); -void UART_SetFlowCtrl(UART_Port uart_no, UART_HwFlowCtrl flow_ctrl, uint8 rx_thresh); -void UART_SetLineInverse(UART_Port uart_no, UART_LineLevelInverse inverse_mask) ; -void uart_init_new(void); -int uart_getchar(void); - -#endif diff --git a/target/esp8266/driver/uart_register.h b/target/esp8266/driver/uart_register.h deleted file mode 100644 index 6398879..0000000 --- a/target/esp8266/driver/uart_register.h +++ /dev/null @@ -1,128 +0,0 @@ -//Generated at 2012-07-03 18:44:06 -/* - * Copyright (c) 2010 - 2011 Espressif System - * - */ - -#ifndef UART_REGISTER_H_INCLUDED -#define UART_REGISTER_H_INCLUDED -#define REG_UART_BASE( i ) (0x60000000+(i)*0xf00) -//version value:32'h062000 - -#define UART_FIFO( i ) (REG_UART_BASE( i ) + 0x0) -#define UART_RXFIFO_RD_BYTE 0x000000FF -#define UART_RXFIFO_RD_BYTE_S 0 - -#define UART_INT_RAW( i ) (REG_UART_BASE( i ) + 0x4) -#define UART_RXFIFO_TOUT_INT_RAW (BIT(8)) -#define UART_BRK_DET_INT_RAW (BIT(7)) -#define UART_CTS_CHG_INT_RAW (BIT(6)) -#define UART_DSR_CHG_INT_RAW (BIT(5)) -#define UART_RXFIFO_OVF_INT_RAW (BIT(4)) -#define UART_FRM_ERR_INT_RAW (BIT(3)) -#define UART_PARITY_ERR_INT_RAW (BIT(2)) -#define UART_TXFIFO_EMPTY_INT_RAW (BIT(1)) -#define UART_RXFIFO_FULL_INT_RAW (BIT(0)) - -#define UART_INT_ST( i ) (REG_UART_BASE( i ) + 0x8) -#define UART_RXFIFO_TOUT_INT_ST (BIT(8)) -#define UART_BRK_DET_INT_ST (BIT(7)) -#define UART_CTS_CHG_INT_ST (BIT(6)) -#define UART_DSR_CHG_INT_ST (BIT(5)) -#define UART_RXFIFO_OVF_INT_ST (BIT(4)) -#define UART_FRM_ERR_INT_ST (BIT(3)) -#define UART_PARITY_ERR_INT_ST (BIT(2)) -#define UART_TXFIFO_EMPTY_INT_ST (BIT(1)) -#define UART_RXFIFO_FULL_INT_ST (BIT(0)) - -#define UART_INT_ENA( i ) (REG_UART_BASE( i ) + 0xC) -#define UART_RXFIFO_TOUT_INT_ENA (BIT(8)) -#define UART_BRK_DET_INT_ENA (BIT(7)) -#define UART_CTS_CHG_INT_ENA (BIT(6)) -#define UART_DSR_CHG_INT_ENA (BIT(5)) -#define UART_RXFIFO_OVF_INT_ENA (BIT(4)) -#define UART_FRM_ERR_INT_ENA (BIT(3)) -#define UART_PARITY_ERR_INT_ENA (BIT(2)) -#define UART_TXFIFO_EMPTY_INT_ENA (BIT(1)) -#define UART_RXFIFO_FULL_INT_ENA (BIT(0)) - -#define UART_INT_CLR( i ) (REG_UART_BASE( i ) + 0x10) -#define UART_RXFIFO_TOUT_INT_CLR (BIT(8)) -#define UART_BRK_DET_INT_CLR (BIT(7)) -#define UART_CTS_CHG_INT_CLR (BIT(6)) -#define UART_DSR_CHG_INT_CLR (BIT(5)) -#define UART_RXFIFO_OVF_INT_CLR (BIT(4)) -#define UART_FRM_ERR_INT_CLR (BIT(3)) -#define UART_PARITY_ERR_INT_CLR (BIT(2)) -#define UART_TXFIFO_EMPTY_INT_CLR (BIT(1)) -#define UART_RXFIFO_FULL_INT_CLR (BIT(0)) - -#define UART_CLKDIV( i ) (REG_UART_BASE( i ) + 0x14) -#define UART_CLKDIV_CNT 0x000FFFFF -#define UART_CLKDIV_S 0 - -#define UART_AUTOBAUD( i ) (REG_UART_BASE( i ) + 0x18) -#define UART_GLITCH_FILT 0x000000FF -#define UART_GLITCH_FILT_S 8 -#define UART_AUTOBAUD_EN (BIT(0)) - -#define UART_STATUS( i ) (REG_UART_BASE( i ) + 0x1C) -#define UART_TXD (BIT(31)) -#define UART_RTSN (BIT(30)) -#define UART_DTRN (BIT(29)) -#define UART_TXFIFO_CNT 0x000000FF -#define UART_TXFIFO_CNT_S 16 -#define UART_RXD (BIT(15)) -#define UART_CTSN (BIT(14)) -#define UART_DSRN (BIT(13)) -#define UART_RXFIFO_CNT 0x000000FF -#define UART_RXFIFO_CNT_S 0 - -#define UART_CONF0( i ) (REG_UART_BASE( i ) + 0x20) -#define UART_TXFIFO_RST (BIT(18)) -#define UART_RXFIFO_RST (BIT(17)) -#define UART_IRDA_EN (BIT(16)) -#define UART_TX_FLOW_EN (BIT(15)) -#define UART_LOOPBACK (BIT(14)) -#define UART_IRDA_RX_INV (BIT(13)) -#define UART_IRDA_TX_INV (BIT(12)) -#define UART_IRDA_WCTL (BIT(11)) -#define UART_IRDA_TX_EN (BIT(10)) -#define UART_IRDA_DPLX (BIT(9)) -#define UART_TXD_BRK (BIT(8)) -#define UART_SW_DTR (BIT(7)) -#define UART_SW_RTS (BIT(6)) -#define UART_STOP_BIT_NUM 0x00000003 -#define UART_STOP_BIT_NUM_S 4 -#define UART_BIT_NUM 0x00000003 -#define UART_BIT_NUM_S 2 -#define UART_PARITY_EN (BIT(1)) -#define UART_PARITY (BIT(0)) - -#define UART_CONF1( i ) (REG_UART_BASE( i ) + 0x24) -#define UART_RX_TOUT_EN (BIT(31)) -#define UART_RX_TOUT_THRHD 0x0000007F -#define UART_RX_TOUT_THRHD_S 24 -#define UART_RX_FLOW_EN (BIT(23)) -#define UART_RX_FLOW_THRHD 0x0000007F -#define UART_RX_FLOW_THRHD_S 16 -#define UART_TXFIFO_EMPTY_THRHD 0x0000007F -#define UART_TXFIFO_EMPTY_THRHD_S 8 -#define UART_RXFIFO_FULL_THRHD 0x0000007F -#define UART_RXFIFO_FULL_THRHD_S 0 - -#define UART_LOWPULSE( i ) (REG_UART_BASE( i ) + 0x28) -#define UART_LOWPULSE_MIN_CNT 0x000FFFFF -#define UART_LOWPULSE_MIN_CNT_S 0 - -#define UART_HIGHPULSE( i ) (REG_UART_BASE( i ) + 0x2C) -#define UART_HIGHPULSE_MIN_CNT 0x000FFFFF -#define UART_HIGHPULSE_MIN_CNT_S 0 - -#define UART_PULSE_NUM( i ) (REG_UART_BASE( i ) + 0x30) -#define UART_PULSE_NUM_CNT 0x0003FF -#define UART_PULSE_NUM_CNT_S 0 - -#define UART_DATE( i ) (REG_UART_BASE( i ) + 0x78) -#define UART_ID( i ) (REG_UART_BASE( i ) + 0x7C) -#endif // UART_REGISTER_H_INCLUDED diff --git a/target/esp8266/ld/eagle.app.v6.ld b/target/esp8266/ld/eagle.app.v6.ld deleted file mode 100644 index 5f50bb9..0000000 --- a/target/esp8266/ld/eagle.app.v6.ld +++ /dev/null @@ -1,225 +0,0 @@ -/* This linker script generated from xt-genldscripts.tpp for LSP . */ -/* Linker Script for ld -N */ -MEMORY -{ - dport0_0_seg : org = 0x3FF00000, len = 0x10 - dram0_0_seg : org = 0x3FFE8000, len = 0x14000 - iram1_0_seg : org = 0x40100000, len = 0x8000 - irom0_0_seg : org = 0x40240000, len = 0x3C000 -} - -PHDRS -{ - dport0_0_phdr PT_LOAD; - dram0_0_phdr PT_LOAD; - dram0_0_bss_phdr PT_LOAD; - iram1_0_phdr PT_LOAD; - irom0_0_phdr PT_LOAD; -} - -/* Default entry point: */ -ENTRY(call_user_start) -EXTERN(_DebugExceptionVector) -EXTERN(_DoubleExceptionVector) -EXTERN(_KernelExceptionVector) -EXTERN(_NMIExceptionVector) -EXTERN(_UserExceptionVector) -PROVIDE(_memmap_vecbase_reset = 0x40000000); -/* Various memory-map dependent cache attribute settings: */ -_memmap_cacheattr_wb_base = 0x00000110; -_memmap_cacheattr_wt_base = 0x00000110; -_memmap_cacheattr_bp_base = 0x00000220; -_memmap_cacheattr_unused_mask = 0xFFFFF00F; -_memmap_cacheattr_wb_trapnull = 0x2222211F; -_memmap_cacheattr_wba_trapnull = 0x2222211F; -_memmap_cacheattr_wbna_trapnull = 0x2222211F; -_memmap_cacheattr_wt_trapnull = 0x2222211F; -_memmap_cacheattr_bp_trapnull = 0x2222222F; -_memmap_cacheattr_wb_strict = 0xFFFFF11F; -_memmap_cacheattr_wt_strict = 0xFFFFF11F; -_memmap_cacheattr_bp_strict = 0xFFFFF22F; -_memmap_cacheattr_wb_allvalid = 0x22222112; -_memmap_cacheattr_wt_allvalid = 0x22222112; -_memmap_cacheattr_bp_allvalid = 0x22222222; -PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull); - -SECTIONS -{ - - .dport0.rodata : ALIGN(4) - { - _dport0_rodata_start = ABSOLUTE(.); - *(.dport0.rodata) - *(.dport.rodata) - _dport0_rodata_end = ABSOLUTE(.); - } >dport0_0_seg :dport0_0_phdr - - .dport0.literal : ALIGN(4) - { - _dport0_literal_start = ABSOLUTE(.); - *(.dport0.literal) - *(.dport.literal) - _dport0_literal_end = ABSOLUTE(.); - } >dport0_0_seg :dport0_0_phdr - - .dport0.data : ALIGN(4) - { - _dport0_data_start = ABSOLUTE(.); - *(.dport0.data) - *(.dport.data) - _dport0_data_end = ABSOLUTE(.); - } >dport0_0_seg :dport0_0_phdr - - .data : ALIGN(4) - { - _data_start = ABSOLUTE(.); - *(.data) - *(.data.*) - *(.gnu.linkonce.d.*) - *(.data1) - *(.sdata) - *(.sdata.*) - *(.gnu.linkonce.s.*) - *(.sdata2) - *(.sdata2.*) - *(.gnu.linkonce.s2.*) - *(.jcr) - _data_end = ABSOLUTE(.); - } >dram0_0_seg :dram0_0_phdr - - .rodata : ALIGN(4) - { - _rodata_start = ABSOLUTE(.); - *(.rodata) - *(.rodata.*) - *(.gnu.linkonce.r.*) - *(.rodata1) - __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); - *(.xt_except_table) - *(.gcc_except_table) - *(.gnu.linkonce.e.*) - *(.gnu.version_r) - *(.eh_frame) - /* C++ constructor and destructor tables, properly ordered: */ - KEEP (*crtbegin.o(.ctors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*(.ctors)) - KEEP (*crtbegin.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*(.dtors)) - /* C++ exception handlers table: */ - __XT_EXCEPTION_DESCS__ = ABSOLUTE(.); - *(.xt_except_desc) - *(.gnu.linkonce.h.*) - __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.); - *(.xt_except_desc_end) - *(.dynamic) - *(.gnu.version_d) - . = ALIGN(4); /* this table MUST be 4-byte aligned */ - _bss_table_start = ABSOLUTE(.); - LONG(_bss_start) - LONG(_bss_end) - _bss_table_end = ABSOLUTE(.); - _rodata_end = ABSOLUTE(.); - } >dram0_0_seg :dram0_0_phdr - - .UserExceptionVector.literal : AT(LOADADDR(.rodata) + (ADDR(.UserExceptionVector.literal) - ADDR(.rodata))) ALIGN(4) - { - _UserExceptionVector_literal_start = ABSOLUTE(.); - *(.UserExceptionVector.literal) - _UserExceptionVector_literal_end = ABSOLUTE(.); - } >dram0_0_seg :dram0_0_phdr - - .bss ALIGN(8) (NOLOAD) : ALIGN(4) - { - . = ALIGN (8); - _bss_start = ABSOLUTE(.); - *(.dynsbss) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.sb.*) - *(.scommon) - *(.sbss2) - *(.sbss2.*) - *(.gnu.linkonce.sb2.*) - *(.dynbss) - *(.bss) - *(.bss.*) - *(.gnu.linkonce.b.*) - *(COMMON) - . = ALIGN (8); - _bss_end = ABSOLUTE(.); - _heap_start = ABSOLUTE(.); -/* _stack_sentry = ALIGN(0x8); */ - } >dram0_0_seg :dram0_0_bss_phdr -/* __stack = 0x3ffc8000; */ - - .irom0.text : ALIGN(4) - { - _irom0_text_start = ABSOLUTE(.); - *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text) - *libkaac.a:(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) - *libdemo_client_s.a:(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) - *libextension_bootstrap.a:(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) - *libextension_user.a:(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) - *libextension_event.a:(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) - *libmbedtls.a:(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) - *libtarget_support.a:(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) - _irom0_text_end = ABSOLUTE(.); - } >irom0_0_seg :irom0_0_phdr - - .text : ALIGN(4) - { - _stext = .; - _text_start = ABSOLUTE(.); - *(.UserEnter.text) - . = ALIGN(16); - *(.DebugExceptionVector.text) - . = ALIGN(16); - *(.NMIExceptionVector.text) - . = ALIGN(16); - *(.KernelExceptionVector.text) - LONG(0) - LONG(0) - LONG(0) - LONG(0) - . = ALIGN(16); - *(.UserExceptionVector.text) - LONG(0) - LONG(0) - LONG(0) - LONG(0) - . = ALIGN(16); - *(.DoubleExceptionVector.text) - LONG(0) - LONG(0) - LONG(0) - LONG(0) - . = ALIGN (16); - *(.entry.text) - *(.init.literal) - *(.init) - *( .literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) - *(.fini.literal) - *(.fini) - *(.gnu.version) - _text_end = ABSOLUTE(.); - _etext = .; - } >iram1_0_seg :iram1_0_phdr - - .lit4 : ALIGN(4) - { - _lit4_start = ABSOLUTE(.); - *(*.lit4) - *(.lit4.*) - *(.gnu.linkonce.lit4.*) - _lit4_end = ABSOLUTE(.); - } >iram1_0_seg :iram1_0_phdr - -} - -/* get ROM code address */ -INCLUDE "eagle.rom.addr.v6.ld" - diff --git a/target/esp8266/ld/eagle.rom.addr.v6.ld b/target/esp8266/ld/eagle.rom.addr.v6.ld deleted file mode 100644 index d25880e..0000000 --- a/target/esp8266/ld/eagle.rom.addr.v6.ld +++ /dev/null @@ -1,54 +0,0 @@ -PROVIDE ( SPI_sector_erase = 0x400040c0 ); -PROVIDE ( SPI_page_program = 0x40004174 ); -PROVIDE ( SPI_read_data = 0x400042ac ); -PROVIDE ( SPI_read_status = 0x400043c8 ); -PROVIDE ( SPI_write_status = 0x40004400 ); -PROVIDE ( SPI_write_enable = 0x4000443c ); -PROVIDE ( Wait_SPI_Idle = 0x4000448c ); -PROVIDE ( Enable_QMode = 0x400044c0 ); -PROVIDE ( Disable_QMode = 0x40004508 ); - -PROVIDE ( Cache_Read_Enable = 0x40004678 ); -PROVIDE ( Cache_Read_Disable = 0x400047f0 ); - -PROVIDE ( lldesc_build_chain = 0x40004f40 ); -PROVIDE ( lldesc_num2link = 0x40005050 ); -PROVIDE ( lldesc_set_owner = 0x4000507c ); - -PROVIDE ( __adddf3 = 0x4000c538 ); -PROVIDE ( __addsf3 = 0x4000c180 ); -PROVIDE ( __divdf3 = 0x4000cb94 ); -PROVIDE ( __divdi3 = 0x4000ce60 ); -PROVIDE ( __divsi3 = 0x4000dc88 ); -PROVIDE ( __extendsfdf2 = 0x4000cdfc ); -PROVIDE ( __fixdfsi = 0x4000ccb8 ); -PROVIDE ( __fixunsdfsi = 0x4000cd00 ); -PROVIDE ( __fixunssfsi = 0x4000c4c4 ); -PROVIDE ( __floatsidf = 0x4000e2f0 ); -PROVIDE ( __floatsisf = 0x4000e2ac ); -PROVIDE ( __floatunsidf = 0x4000e2e8 ); -PROVIDE ( __floatunsisf = 0x4000e2a4 ); -PROVIDE ( __muldf3 = 0x4000c8f0 ); -PROVIDE ( __muldi3 = 0x40000650 ); -PROVIDE ( __mulsf3 = 0x4000c3dc ); -PROVIDE ( __subdf3 = 0x4000c688 ); -PROVIDE ( __subsf3 = 0x4000c268 ); -PROVIDE ( __truncdfsf2 = 0x4000cd5c ); -PROVIDE ( __udivdi3 = 0x4000d310 ); -PROVIDE ( __udivsi3 = 0x4000e21c ); -PROVIDE ( __umoddi3 = 0x4000d770 ); -PROVIDE ( __umodsi3 = 0x4000e268 ); -PROVIDE ( __umulsidi3 = 0x4000dcf0 ); - -PROVIDE ( bzero = 0x40002ae8 ); -PROVIDE ( memcmp = 0x400018d4 ); -PROVIDE ( memcpy = 0x400018b4 ); -PROVIDE ( memmove = 0x400018c4 ); -PROVIDE ( memset = 0x400018a4 ); - -PROVIDE ( strcmp = 0x40002aa8 ); -PROVIDE ( strcpy = 0x40002a88 ); -PROVIDE ( strlen = 0x40002ac8 ); -PROVIDE ( strncmp = 0x40002ab8 ); -PROVIDE ( strncpy = 0x40002a98 ); -PROVIDE ( strstr = 0x40002ad8 ); diff --git a/target/esp8266/target.c b/target/esp8266/target.c deleted file mode 100644 index 1ba8d9b..0000000 --- a/target/esp8266/target.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2014-2016 CyberVision, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include - -#include -#include - -#include "uart.h" - -#define MAIN_STACK_SIZE 512 - -extern int main(void); - -static void main_task(void *pvParameters); -static int wifi_init(void); -static int wifi_connect(const char *ssid, const char *pwd); -static void uart_init(void); - -int target_initialize(void) -{ - - if (wifi_init()) { - printf("Error initialising wifi!\r\n"); - return 1; - } - - if (wifi_connect(WIFI_SSID, WIFI_PASSWORD)) { - printf("Couldn't connect to \"%s\" with password \"%s\"\r\n", WIFI_SSID, WIFI_PASSWORD); - return 1; - } - - return 0; -} - -void ICACHE_FLASH_ATTR user_init() -{ - uart_init(); - target_gpio_led_init(); - portBASE_TYPE error = xTaskCreate(main_task, (const signed char *)"main_task", - MAIN_STACK_SIZE, NULL, 2, NULL ); - if (error < 0) { - printf("Error creating main_task! Error code: %ld\r\n", error); - } -} - -static void main_task(void *pvParameters) -{ - (void)pvParameters; - main(); - for (;;); -} - - -static void uart_init(void) -{ - uart_init_new(); - UART_SetPrintPort(UART0); -} - -static int wifi_init(void) -{ - if (!wifi_set_opmode_current(0x01)) { - return 1; - } - - return 0; -} - -static int wifi_connect(const char *ssid, const char *pwd) -{ - struct station_config sta_cfg; - memset(&sta_cfg, 0, sizeof(sta_cfg)); - strcpy((char *)sta_cfg.ssid, ssid); - strcpy((char *)sta_cfg.password, pwd); - if (!wifi_station_set_config_current(&sta_cfg)) { - return 1; - } - - if (!wifi_station_connect()) { - return 1; - } - - uint8 status = STATION_IDLE; - do { - status = wifi_station_get_connect_status(); - } while (status == STATION_CONNECTING); - - switch (status) { - case STATION_WRONG_PASSWORD: - case STATION_NO_AP_FOUND: - case STATION_CONNECT_FAIL: { - wifi_station_disconnect(); - return 1; - } - case STATION_GOT_IP: - case STATION_IDLE: - break; - default: - break; - } - - return 0; -} - -/* Required, don't touch */ -void ets_putc(char c) -{ - os_putc(c); -} - -int getchar(void) -{ - return uart_getchar(); -} - diff --git a/target/esp8266/target.h b/target/esp8266/target.h deleted file mode 100644 index 06e2d4d..0000000 --- a/target/esp8266/target.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2014-2016 CyberVision, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * - * This header provides several bindings for ESP8266 target that abstracts - * an implementation of its features. Right now it contains only - * console and target initialisation routines, but it can be extended - * if required. - * - */ - -#ifndef ESP8266_SUPPORT_H_ -#define ESP8266_SUPPORT_H_ - -#include -#include - -/* Demo print routine. printf implementation is available on this platform. */ -#define demo_printf(msg, ...) printf((msg), ##__VA_ARGS__) - -#define NUM_GPIO_LEDS 2 - -#define TARGET_DEVICE_NAME "ESP8266" -#define TARGET_MODEL_NAME "01" - -/** - * Initializes a target. 0 means success, negative values - errors. - * - * For this particular target this will eventually try to connect to - * the WiFi spot using SSID and password supplied during build. - */ -int target_initialize(void); - -/** - * The ESP8266 SDK does not define getchar() anywhere - * (except for useless chain of defines which does not work, however), - * but it is required to read user input in some demos, - * so it is implemented here. - */ -#undef getchar -int getchar(void); - -#endif //ESP8266_SUPPORT_H_ diff --git a/target/esp8266/target_gpio_led.c b/target/esp8266/target_gpio_led.c deleted file mode 100644 index ded3f9e..0000000 --- a/target/esp8266/target_gpio_led.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2014-2016 CyberVision, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "target_gpio_led.h" - -#include - -#include "gpio.h" -#include "target.h" -#include "gpio_register.h" - -#define BIT(nr) (1UL << (nr)) - -// GPIO4 and GPIO5 is used for demo -static unsigned int demo_gpio_id[NUM_GPIO_LEDS] = {4, 5}; - -void target_gpio_led_init(void) -{ - GPIO_ConfigTypeDef pGPIOConfig; - - pGPIOConfig.GPIO_IntrType = GPIO_PIN_INTR_DISABLE; - pGPIOConfig.GPIO_Mode = GPIO_Mode_Output; - pGPIOConfig.GPIO_Pullup = GPIO_PullUp_EN; - - for (unsigned int i = 0; i < NUM_GPIO_LEDS; i++) { - pGPIOConfig.GPIO_Pin = (BIT(demo_gpio_id[i])); - gpio_config(&pGPIOConfig); - - GPIO_OUTPUT_SET(demo_gpio_id[i], 0); - } -} - -void target_gpio_led_toggle(uint32_t id, bool status) -{ - if (id >= NUM_GPIO_LEDS) { - return; - } - - if (status) { - GPIO_OUTPUT_SET(demo_gpio_id[id], 1); - } else { - GPIO_OUTPUT_SET(demo_gpio_id[id], 0); - } -} diff --git a/target/esp8266/target_gpio_led.h b/target/esp8266/target_gpio_led.h deleted file mode 100644 index c573bc4..0000000 --- a/target/esp8266/target_gpio_led.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2014-2016 CyberVision, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * - * This header defines generic API to access - * GPIO LEDs on embedded targets. - */ - -#ifndef TARGET_GPIO_LED_H -#define TARGET_GPIO_LED_H - -#include -#include - -/** - * Platform-specific GPIO LEDs initalization. - * - */ -void target_gpio_led_init(void); - -/** - * Toggles output for GPIO LED id. - * - * @param [in] id Id of the LED to toggle. Should be less that NUM_GPIO_LEDS. - * @param [in] status Sets the status of the LED. - * - */ -void target_gpio_led_toggle(uint32_t id, bool status); - -#endif // TARGET_GPIO_LED_H -