Skip to content

Commit

Permalink
Various fixes for ESP32 (#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSoundy authored and josesimoes committed Mar 13, 2018
1 parent f7d7917 commit 7a1b881
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
matrix:
- BOARD_NAME: 'STM32'
- BOARD_NAME: 'ESP32_DEVKITC'
BUILD_OPTIONS: '-DTARGET_SERIES=ESP32 -DRTOS=FREERTOS -DNF_FEATURE_DEBUGGER=TRUE -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.SerialCommunication=ON'
BUILD_OPTIONS: '-DTARGET_SERIES=ESP32 -DRTOS=FREERTOS -DNF_FEATURE_DEBUGGER=TRUE -DAPI_Windows.Devices.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON -DAPI_System.Net=OFF'
- BOARD_NAME: 'NANOCLR_WINDOWS'

matrix:
Expand Down
1 change: 1 addition & 0 deletions targets/FreeRTOS/ESP32_DevKitC/nanoCLR/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ list(APPEND TARGET_ESP32_NANOCLR_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/nanoHAL.cp

# append target HAL source files
list(APPEND TARGET_ESP32_NANOCLR_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/targetHAL_Time.cpp")
list(APPEND TARGET_ESP32_NANOCLR_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/targetHAL_Network.cpp")

# append target PAL source files
list(APPEND TARGET_ESP32_NANOCLR_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/targetPAL_Events.cpp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,40 +205,53 @@ HRESULT Library_win_dev_gpio_native_Windows_Devices_Gpio_GpioPin::NativeSetDrive
NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER);
}

gpio_mode_t mode = GPIO_MODE_DISABLE;
gpio_pullup_t pull_up_en = GPIO_PULLUP_DISABLE;
gpio_pulldown_t pull_down_en = GPIO_PULLDOWN_DISABLE;
gpio_int_type_t intr_type = GPIO_INTR_ANYEDGE;

switch (driveMode)
{
case GpioPinDriveMode_Input :
gpio_set_direction( (gpio_num_t)pinNumber, GPIO_MODE_INPUT); // 0 - GpioPinDriveMode_Input
gpio_set_pull_mode( (gpio_num_t)pinNumber, GPIO_FLOATING);
case GpioPinDriveMode_Input :
mode = GPIO_MODE_INPUT;
break;
case GpioPinDriveMode_InputPullDown :
gpio_set_direction( (gpio_num_t)pinNumber, GPIO_MODE_INPUT); // 1 - GpioPinDriveMode_InputPullDown
gpio_set_pull_mode( (gpio_num_t)pinNumber, GPIO_PULLDOWN_ONLY);
mode = GPIO_MODE_INPUT;
pull_down_en = GPIO_PULLDOWN_ENABLE;
break;
case GpioPinDriveMode_InputPullUp :
gpio_set_direction( (gpio_num_t)pinNumber, GPIO_MODE_INPUT); // 2 - GpioPinDriveMode_InputPullUp
gpio_set_pull_mode( (gpio_num_t)pinNumber, GPIO_PULLUP_ONLY);
pull_up_en = GPIO_PULLUP_ENABLE;
break;
case GpioPinDriveMode_Output :
gpio_set_direction( (gpio_num_t)pinNumber, GPIO_MODE_OUTPUT); // 3 - GpioPinDriveMode_Output
gpio_set_pull_mode( (gpio_num_t)pinNumber, GPIO_FLOATING);
mode = GPIO_MODE_OUTPUT;
break;
case GpioPinDriveMode_OutputOpenDrain :
gpio_set_direction( (gpio_num_t)pinNumber, GPIO_MODE_OUTPUT_OD); // 4 - GpioPinDriveMode_OutputOpenDrain
driveMode = GPIO_MODE_OUTPUT_OD;
break;
case GpioPinDriveMode_OutputOpenDrainPullUp :
gpio_set_direction( (gpio_num_t)pinNumber, GPIO_MODE_OUTPUT_OD); // 5 - GpioPinDriveMode_OutputOpenDrainPullUp
gpio_set_pull_mode( (gpio_num_t)pinNumber, GPIO_PULLUP_ONLY);
mode = GPIO_MODE_OUTPUT_OD;
pull_up_en = GPIO_PULLUP_ENABLE;
break;
case GpioPinDriveMode_OutputOpenSource:
mode = GPIO_MODE_OUTPUT_OD;
break;
// 6 - GpioPinDriveMode_OutputOpenSource
// 7 - GpioPinDriveMode_OutputOpenSourcePullDown
default : gpio_set_direction( (gpio_num_t)pinNumber, GPIO_MODE_INPUT_OUTPUT);
case GpioPinDriveMode_OutputOpenSourcePullDown:
mode = GPIO_MODE_OUTPUT_OD;
pull_down_en = GPIO_PULLDOWN_ENABLE;
break;
}

gpio_set_intr_type((gpio_num_t)pinNumber, GPIO_INTR_ANYEDGE);
gpio_config_t GPIOConfig;

// Enabler interrupts for all pins
GPIOConfig.pin_bit_mask = (1ULL << pinNumber);
GPIOConfig.mode = mode;
GPIOConfig.pull_up_en = pull_up_en;
GPIOConfig.pull_down_en = pull_down_en;
GPIOConfig.intr_type = intr_type;

gpio_config( &GPIOConfig );

// Enable interrupts for all pins
Add_Gpio_Interrupt( (gpio_num_t)pinNumber );

// save pin reference
Expand Down
3 changes: 3 additions & 0 deletions targets/FreeRTOS/ESP32_DevKitC/nanoCLR/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ void IRAM_ATTR main_task(void *pvParameter)
//
void app_main()
{
// Switch off logging so as not to interfere with WireProtocol over Uart0
esp_log_level_set("*", ESP_LOG_NONE);

initialise_wifi_smart_config();

Esp32FlashDriver_InitializeDevice(0);
Expand Down

0 comments on commit 7a1b881

Please sign in to comment.