kendryte / kendryte-standalone-sdk

Standalone SDK for kendryte K210
https://kendryte.com
Apache License 2.0
445 stars 162 forks source link

Can't set pins > 31 as GPIO #113

Open CyanBlob opened 4 years ago

CyanBlob commented 4 years ago

Make sure you read and understand this document. Use one of the two templates below and delete the rest.

Expected behavior

We should be able to use all physical pins as GPIOHS pins

Actual behavior

As it stands, only pins 0-31 can be used as GPIOHS. This is because, for whatever reason, in the following code:

fpioa_set_function(3, FUNC_GPIOHS3);
gpiohs_set_drive_mode(3, GPIO_DM_OUTPUT);
gpiohs_set_pin(3, GPIO_PV_HIGH);

the physical pin is identified by the enum FUNC_GPIOHS3 instead of the first argument to fpioa_set_function. That enum is limited to FUNC_GPIOHS0 - FUNC_GPIOHS31, so pins 32-35 are unusable.

My expectation for how this would work is that the following would turn on pin 35:

fpioa_set_function(35, FUNC_GPIOHS1);
gpiohs_set_drive_mode(35, GPIO_DM_OUTPUT);
gpiohs_set_pin(35, GPIO_PV_HIGH);

This behavior would allow setting any 32 hardware pins to GPIOHS at a time. Is there a hardware limitation as to why physical pins > 31 can't be used?

Document version

Standalone SDK version 0.5.6

Hardware

Sipeed MAiX BiT

System

What system do you use? Arch Linux, running PlatformIO 4.3.4 with the standalone SDK version 0.5.6