ESP-WROVER-KIT GPIO problem.
Posted: Wed Feb 28, 2018 3:19 pm
Hi all,
Im in trouble configuring/using GPIO pins on the ESP-WROVER-KIT.
code fragment :
I cannot figure out how to make the gpio's work. The signal from the rmt peripheral on gpio18 is exact as I intended, but no activity on GPIO 16 nor 17... (with logic analyser).
Am I missing some initialisation? Has it something to do with multithreading ? I'm looking at nkolban's github site and find no missing links in my program.
Thanks in advance,
Paul
Im in trouble configuring/using GPIO pins on the ESP-WROVER-KIT.
code fragment :
Code: Select all
DCCGen::DCCGen( gpio_num_t RailcomGPIONum /* = GPIO_NUM_16 */,
gpio_num_t PowerGPIONum /* = GPIO_NUM_17 */,
gpio_num_t DccGPIONum /* = GPIO_NUM_18 */,
rmt_channel_t channel /* = RMT_CHANNEL_0 */
)
: m_bContinue(true)
, m_PowerState(PowerOn)
, m_PowerGPIONum(PowerGPIONum)
, m_RailcomGPIONum(RailcomGPIONum)
, m_DccGPIONum(DccGPIONum)
, m_Channel(channel)
{
memset(&m_gpioConfig, 0, sizeof(gpio_config_t));
m_gpioConfig.pin_bit_mask = ((1ULL << m_RailcomGPIONum) | (1ULL << m_PowerGPIONum));
m_gpioConfig.mode = GPIO_MODE_OUTPUT;
m_gpioConfig.pull_up_en = GPIO_PULLUP_ENABLE;
m_gpioConfig.pull_down_en = GPIO_PULLDOWN_DISABLE;
m_gpioConfig.intr_type = GPIO_INTR_DISABLE;
ESP_ERROR_CHECK(gpio_config(&m_gpioConfig));
ESP_ERROR_CHECK(gpio_set_level(m_PowerGPIONum, 0));
ESP_ERROR_CHECK(gpio_set_level(m_RailcomGPIONum, 0));
.
. (some other irrelevant code)
.
m_thread = thread([this]{threadFunc();});
}
void DCCGen::threadFunc()
{
.
. (other irrelevant code)
.
while(m_bContinue)
{
// send the preamble_items
ESP_ERROR_CHECK(rmt_write_items(m_rmtConfig.channel, preamble_items, PREAMBLE_NBR_CYCLES, false));
// meanwhile (we have 1856 µS to spend...)
usleep(28);
// Shutdown power
gpio_set_level(m_PowerGPIONum, 0);
usleep(2);
// Short the outputs
gpio_set_level(m_RailcomGPIONum, 1);
usleep(439);
// un-Short outputs
gpio_set_level(m_RailcomGPIONum, 0);
usleep(2);
// Power up Power
if(m_PowerState == PowerOn)
{
gpio_set_level(m_PowerGPIONum, 1);
}
if(nullptr == (pNextMessage = getNextDccMessage()))
{
pNextMessage = &IdleMessage;
}
ItemCount = pNextMessage->getItemCount();
ItemCount = (ItemCount > 64) ? 64 : ItemCount;
memcpy(pItems, pNextMessage->getItems(), ItemCount * sizeof(rmt_item32_t));
// wait until preamble finished
ESP_ERROR_CHECK(rmt_wait_tx_done(m_rmtConfig.channel, PREAMBLE_WAIT_TIME));
// send dcc data and wait until end of transmission
ESP_ERROR_CHECK(rmt_write_items(m_rmtConfig.channel, pItems, ItemCount, true));
}
ESP_ERROR_CHECK(rmt_driver_uninstall(m_rmtConfig.channel));
}
} // namespace TBTIoT
Am I missing some initialisation? Has it something to do with multithreading ? I'm looking at nkolban's github site and find no missing links in my program.
Thanks in advance,
Paul