maixbit
Constants
const ( P00Pin= 0 P01Pin= 1 P02Pin= 2 P03Pin= 3 P04Pin= 4 P05Pin= 5 P06Pin= 6 P07Pin= 7 P08Pin= 8 P09Pin= 9 P10Pin= 10 P11Pin= 11 P12Pin= 12 P13Pin= 13 P14Pin= 14 P15Pin= 15 P16Pin= 16 P17Pin= 17 P18Pin= 18 P19Pin= 19 P20Pin= 20 P21Pin= 21 P22Pin= 22 P23Pin= 23 P24Pin= 24 P25Pin= 25 P26Pin= 26 P27Pin= 27 P28Pin= 28 P29Pin= 29 P30Pin= 30 P31Pin= 31 P32Pin= 32 P33Pin= 33 P34Pin= 34 P35Pin= 35 P36Pin= 36 P37Pin= 37 P38Pin= 38 P39Pin= 39 P40Pin= 40 P41Pin= 41 P42Pin= 42 P43Pin= 43 P44Pin= 44 P45Pin= 45 P46Pin= 46 P47Pin= 47 )
K210 IO pins.
const ( FUNC_JTAG_TCLKFPIOAFunction= 0// JTAG Test Clock FUNC_JTAG_TDIFPIOAFunction= 1// JTAG Test Data In FUNC_JTAG_TMSFPIOAFunction= 2// JTAG Test Mode Select FUNC_JTAG_TDOFPIOAFunction= 3// JTAG Test Data Out FUNC_SPI0_D0FPIOAFunction= 4// SPI0 Data 0 FUNC_SPI0_D1FPIOAFunction= 5// SPI0 Data 1 FUNC_SPI0_D2FPIOAFunction= 6// SPI0 Data 2 FUNC_SPI0_D3FPIOAFunction= 7// SPI0 Data 3 FUNC_SPI0_D4FPIOAFunction= 8// SPI0 Data 4 FUNC_SPI0_D5FPIOAFunction= 9// SPI0 Data 5 FUNC_SPI0_D6FPIOAFunction= 10// SPI0 Data 6 FUNC_SPI0_D7FPIOAFunction= 11// SPI0 Data 7 FUNC_SPI0_SS0FPIOAFunction= 12// SPI0 Chip Select 0 FUNC_SPI0_SS1FPIOAFunction= 13// SPI0 Chip Select 1 FUNC_SPI0_SS2FPIOAFunction= 14// SPI0 Chip Select 2 FUNC_SPI0_SS3FPIOAFunction= 15// SPI0 Chip Select 3 FUNC_SPI0_ARBFPIOAFunction= 16// SPI0 Arbitration FUNC_SPI0_SCLKFPIOAFunction= 17// SPI0 Serial Clock FUNC_UARTHS_RXFPIOAFunction= 18// UART High speed Receiver FUNC_UARTHS_TXFPIOAFunction= 19// UART High speed Transmitter FUNC_RESV6FPIOAFunction= 20// Reserved function FUNC_RESV7FPIOAFunction= 21// Reserved function FUNC_CLK_SPI1FPIOAFunction= 22// Clock SPI1 FUNC_CLK_I2C1FPIOAFunction= 23// Clock I2C1 FUNC_GPIOHS0FPIOAFunction= 24// GPIO High speed 0 FUNC_GPIOHS1FPIOAFunction= 25// GPIO High speed 1 FUNC_GPIOHS2FPIOAFunction= 26// GPIO High speed 2 FUNC_GPIOHS3FPIOAFunction= 27// GPIO High speed 3 FUNC_GPIOHS4FPIOAFunction= 28// GPIO High speed 4 FUNC_GPIOHS5FPIOAFunction= 29// GPIO High speed 5 FUNC_GPIOHS6FPIOAFunction= 30// GPIO High speed 6 FUNC_GPIOHS7FPIOAFunction= 31// GPIO High speed 7 FUNC_GPIOHS8FPIOAFunction= 32// GPIO High speed 8 FUNC_GPIOHS9FPIOAFunction= 33// GPIO High speed 9 FUNC_GPIOHS10FPIOAFunction= 34// GPIO High speed 10 FUNC_GPIOHS11FPIOAFunction= 35// GPIO High speed 11 FUNC_GPIOHS12FPIOAFunction= 36// GPIO High speed 12 FUNC_GPIOHS13FPIOAFunction= 37// GPIO High speed 13 FUNC_GPIOHS14FPIOAFunction= 38// GPIO High speed 14 FUNC_GPIOHS15FPIOAFunction= 39// GPIO High speed 15 FUNC_GPIOHS16FPIOAFunction= 40// GPIO High speed 16 FUNC_GPIOHS17FPIOAFunction= 41// GPIO High speed 17 FUNC_GPIOHS18FPIOAFunction= 42// GPIO High speed 18 FUNC_GPIOHS19FPIOAFunction= 43// GPIO High speed 19 FUNC_GPIOHS20FPIOAFunction= 44// GPIO High speed 20 FUNC_GPIOHS21FPIOAFunction= 45// GPIO High speed 21 FUNC_GPIOHS22FPIOAFunction= 46// GPIO High speed 22 FUNC_GPIOHS23FPIOAFunction= 47// GPIO High speed 23 FUNC_GPIOHS24FPIOAFunction= 48// GPIO High speed 24 FUNC_GPIOHS25FPIOAFunction= 49// GPIO High speed 25 FUNC_GPIOHS26FPIOAFunction= 50// GPIO High speed 26 FUNC_GPIOHS27FPIOAFunction= 51// GPIO High speed 27 FUNC_GPIOHS28FPIOAFunction= 52// GPIO High speed 28 FUNC_GPIOHS29FPIOAFunction= 53// GPIO High speed 29 FUNC_GPIOHS30FPIOAFunction= 54// GPIO High speed 30 FUNC_GPIOHS31FPIOAFunction= 55// GPIO High speed 31 FUNC_GPIO0FPIOAFunction= 56// GPIO pin 0 FUNC_GPIO1FPIOAFunction= 57// GPIO pin 1 FUNC_GPIO2FPIOAFunction= 58// GPIO pin 2 FUNC_GPIO3FPIOAFunction= 59// GPIO pin 3 FUNC_GPIO4FPIOAFunction= 60// GPIO pin 4 FUNC_GPIO5FPIOAFunction= 61// GPIO pin 5 FUNC_GPIO6FPIOAFunction= 62// GPIO pin 6 FUNC_GPIO7FPIOAFunction= 63// GPIO pin 7 FUNC_UART1_RXFPIOAFunction= 64// UART1 Receiver FUNC_UART1_TXFPIOAFunction= 65// UART1 Transmitter FUNC_UART2_RXFPIOAFunction= 66// UART2 Receiver FUNC_UART2_TXFPIOAFunction= 67// UART2 Transmitter FUNC_UART3_RXFPIOAFunction= 68// UART3 Receiver FUNC_UART3_TXFPIOAFunction= 69// UART3 Transmitter FUNC_SPI1_D0FPIOAFunction= 70// SPI1 Data 0 FUNC_SPI1_D1FPIOAFunction= 71// SPI1 Data 1 FUNC_SPI1_D2FPIOAFunction= 72// SPI1 Data 2 FUNC_SPI1_D3FPIOAFunction= 73// SPI1 Data 3 FUNC_SPI1_D4FPIOAFunction= 74// SPI1 Data 4 FUNC_SPI1_D5FPIOAFunction= 75// SPI1 Data 5 FUNC_SPI1_D6FPIOAFunction= 76// SPI1 Data 6 FUNC_SPI1_D7FPIOAFunction= 77// SPI1 Data 7 FUNC_SPI1_SS0FPIOAFunction= 78// SPI1 Chip Select 0 FUNC_SPI1_SS1FPIOAFunction= 79// SPI1 Chip Select 1 FUNC_SPI1_SS2FPIOAFunction= 80// SPI1 Chip Select 2 FUNC_SPI1_SS3FPIOAFunction= 81// SPI1 Chip Select 3 FUNC_SPI1_ARBFPIOAFunction= 82// SPI1 Arbitration FUNC_SPI1_SCLKFPIOAFunction= 83// SPI1 Serial Clock FUNC_SPI_PERIPHERAL_D0FPIOAFunction= 84// SPI Peripheral Data 0 FUNC_SPI_PERIPHERAL_SSFPIOAFunction= 85// SPI Peripheral Select FUNC_SPI_PERIPHERAL_SCLKFPIOAFunction= 86// SPI Peripheral Serial Clock FUNC_I2S0_MCLKFPIOAFunction= 87// I2S0 Main Clock FUNC_I2S0_SCLKFPIOAFunction= 88// I2S0 Serial Clock(BCLK) FUNC_I2S0_WSFPIOAFunction= 89// I2S0 Word Select(LRCLK) FUNC_I2S0_IN_D0FPIOAFunction= 90// I2S0 Serial Data Input 0 FUNC_I2S0_IN_D1FPIOAFunction= 91// I2S0 Serial Data Input 1 FUNC_I2S0_IN_D2FPIOAFunction= 92// I2S0 Serial Data Input 2 FUNC_I2S0_IN_D3FPIOAFunction= 93// I2S0 Serial Data Input 3 FUNC_I2S0_OUT_D0FPIOAFunction= 94// I2S0 Serial Data Output 0 FUNC_I2S0_OUT_D1FPIOAFunction= 95// I2S0 Serial Data Output 1 FUNC_I2S0_OUT_D2FPIOAFunction= 96// I2S0 Serial Data Output 2 FUNC_I2S0_OUT_D3FPIOAFunction= 97// I2S0 Serial Data Output 3 FUNC_I2S1_MCLKFPIOAFunction= 98// I2S1 Main Clock FUNC_I2S1_SCLKFPIOAFunction= 99// I2S1 Serial Clock(BCLK) FUNC_I2S1_WSFPIOAFunction= 100// I2S1 Word Select(LRCLK) FUNC_I2S1_IN_D0FPIOAFunction= 101// I2S1 Serial Data Input 0 FUNC_I2S1_IN_D1FPIOAFunction= 102// I2S1 Serial Data Input 1 FUNC_I2S1_IN_D2FPIOAFunction= 103// I2S1 Serial Data Input 2 FUNC_I2S1_IN_D3FPIOAFunction= 104// I2S1 Serial Data Input 3 FUNC_I2S1_OUT_D0FPIOAFunction= 105// I2S1 Serial Data Output 0 FUNC_I2S1_OUT_D1FPIOAFunction= 106// I2S1 Serial Data Output 1 FUNC_I2S1_OUT_D2FPIOAFunction= 107// I2S1 Serial Data Output 2 FUNC_I2S1_OUT_D3FPIOAFunction= 108// I2S1 Serial Data Output 3 FUNC_I2S2_MCLKFPIOAFunction= 109// I2S2 Main Clock FUNC_I2S2_SCLKFPIOAFunction= 110// I2S2 Serial Clock(BCLK) FUNC_I2S2_WSFPIOAFunction= 111// I2S2 Word Select(LRCLK) FUNC_I2S2_IN_D0FPIOAFunction= 112// I2S2 Serial Data Input 0 FUNC_I2S2_IN_D1FPIOAFunction= 113// I2S2 Serial Data Input 1 FUNC_I2S2_IN_D2FPIOAFunction= 114// I2S2 Serial Data Input 2 FUNC_I2S2_IN_D3FPIOAFunction= 115// I2S2 Serial Data Input 3 FUNC_I2S2_OUT_D0FPIOAFunction= 116// I2S2 Serial Data Output 0 FUNC_I2S2_OUT_D1FPIOAFunction= 117// I2S2 Serial Data Output 1 FUNC_I2S2_OUT_D2FPIOAFunction= 118// I2S2 Serial Data Output 2 FUNC_I2S2_OUT_D3FPIOAFunction= 119// I2S2 Serial Data Output 3 FUNC_RESV0FPIOAFunction= 120// Reserved function FUNC_RESV1FPIOAFunction= 121// Reserved function FUNC_RESV2FPIOAFunction= 122// Reserved function FUNC_RESV3FPIOAFunction= 123// Reserved function FUNC_RESV4FPIOAFunction= 124// Reserved function FUNC_RESV5FPIOAFunction= 125// Reserved function FUNC_I2C0_SCLKFPIOAFunction= 126// I2C0 Serial Clock FUNC_I2C0_SDAFPIOAFunction= 127// I2C0 Serial Data FUNC_I2C1_SCLKFPIOAFunction= 128// I2C1 Serial Clock FUNC_I2C1_SDAFPIOAFunction= 129// I2C1 Serial Data FUNC_I2C2_SCLKFPIOAFunction= 130// I2C2 Serial Clock FUNC_I2C2_SDAFPIOAFunction= 131// I2C2 Serial Data FUNC_CMOS_XCLKFPIOAFunction= 132// DVP System Clock FUNC_CMOS_RSTFPIOAFunction= 133// DVP System Reset FUNC_CMOS_PWDNFPIOAFunction= 134// DVP Power Down Mode FUNC_CMOS_VSYNCFPIOAFunction= 135// DVP Vertical Sync FUNC_CMOS_HREFFPIOAFunction= 136// DVP Horizontal Reference output FUNC_CMOS_PCLKFPIOAFunction= 137// Pixel Clock FUNC_CMOS_D0FPIOAFunction= 138// Data Bit 0 FUNC_CMOS_D1FPIOAFunction= 139// Data Bit 1 FUNC_CMOS_D2FPIOAFunction= 140// Data Bit 2 FUNC_CMOS_D3FPIOAFunction= 141// Data Bit 3 FUNC_CMOS_D4FPIOAFunction= 142// Data Bit 4 FUNC_CMOS_D5FPIOAFunction= 143// Data Bit 5 FUNC_CMOS_D6FPIOAFunction= 144// Data Bit 6 FUNC_CMOS_D7FPIOAFunction= 145// Data Bit 7 FUNC_SCCB_SCLKFPIOAFunction= 146// SCCB Serial Clock FUNC_SCCB_SDAFPIOAFunction= 147// SCCB Serial Data FUNC_UART1_CTSFPIOAFunction= 148// UART1 Clear To Send FUNC_UART1_DSRFPIOAFunction= 149// UART1 Data Set Ready FUNC_UART1_DCDFPIOAFunction= 150// UART1 Data Carrier Detect FUNC_UART1_RIFPIOAFunction= 151// UART1 Ring Indicator FUNC_UART1_SIR_INFPIOAFunction= 152// UART1 Serial Infrared Input FUNC_UART1_DTRFPIOAFunction= 153// UART1 Data Terminal Ready FUNC_UART1_RTSFPIOAFunction= 154// UART1 Request To Send FUNC_UART1_OUT2FPIOAFunction= 155// UART1 User-designated Output 2 FUNC_UART1_OUT1FPIOAFunction= 156// UART1 User-designated Output 1 FUNC_UART1_SIR_OUTFPIOAFunction= 157// UART1 Serial Infrared Output FUNC_UART1_BAUDFPIOAFunction= 158// UART1 Transmit Clock Output FUNC_UART1_REFPIOAFunction= 159// UART1 Receiver Output Enable FUNC_UART1_DEFPIOAFunction= 160// UART1 Driver Output Enable FUNC_UART1_RS485_ENFPIOAFunction= 161// UART1 RS485 Enable FUNC_UART2_CTSFPIOAFunction= 162// UART2 Clear To Send FUNC_UART2_DSRFPIOAFunction= 163// UART2 Data Set Ready FUNC_UART2_DCDFPIOAFunction= 164// UART2 Data Carrier Detect FUNC_UART2_RIFPIOAFunction= 165// UART2 Ring Indicator FUNC_UART2_SIR_INFPIOAFunction= 166// UART2 Serial Infrared Input FUNC_UART2_DTRFPIOAFunction= 167// UART2 Data Terminal Ready FUNC_UART2_RTSFPIOAFunction= 168// UART2 Request To Send FUNC_UART2_OUT2FPIOAFunction= 169// UART2 User-designated Output 2 FUNC_UART2_OUT1FPIOAFunction= 170// UART2 User-designated Output 1 FUNC_UART2_SIR_OUTFPIOAFunction= 171// UART2 Serial Infrared Output FUNC_UART2_BAUDFPIOAFunction= 172// UART2 Transmit Clock Output FUNC_UART2_REFPIOAFunction= 173// UART2 Receiver Output Enable FUNC_UART2_DEFPIOAFunction= 174// UART2 Driver Output Enable FUNC_UART2_RS485_ENFPIOAFunction= 175// UART2 RS485 Enable FUNC_UART3_CTSFPIOAFunction= 176// UART3 Clear To Send FUNC_UART3_DSRFPIOAFunction= 177// UART3 Data Set Ready FUNC_UART3_DCDFPIOAFunction= 178// UART3 Data Carrier Detect FUNC_UART3_RIFPIOAFunction= 179// UART3 Ring Indicator FUNC_UART3_SIR_INFPIOAFunction= 180// UART3 Serial Infrared Input FUNC_UART3_DTRFPIOAFunction= 181// UART3 Data Terminal Ready FUNC_UART3_RTSFPIOAFunction= 182// UART3 Request To Send FUNC_UART3_OUT2FPIOAFunction= 183// UART3 User-designated Output 2 FUNC_UART3_OUT1FPIOAFunction= 184// UART3 User-designated Output 1 FUNC_UART3_SIR_OUTFPIOAFunction= 185// UART3 Serial Infrared Output FUNC_UART3_BAUDFPIOAFunction= 186// UART3 Transmit Clock Output FUNC_UART3_REFPIOAFunction= 187// UART3 Receiver Output Enable FUNC_UART3_DEFPIOAFunction= 188// UART3 Driver Output Enable FUNC_UART3_RS485_ENFPIOAFunction= 189// UART3 RS485 Enable FUNC_TIMER0_TOGGLE1FPIOAFunction= 190// TIMER0 Toggle Output 1 FUNC_TIMER0_TOGGLE2FPIOAFunction= 191// TIMER0 Toggle Output 2 FUNC_TIMER0_TOGGLE3FPIOAFunction= 192// TIMER0 Toggle Output 3 FUNC_TIMER0_TOGGLE4FPIOAFunction= 193// TIMER0 Toggle Output 4 FUNC_TIMER1_TOGGLE1FPIOAFunction= 194// TIMER1 Toggle Output 1 FUNC_TIMER1_TOGGLE2FPIOAFunction= 195// TIMER1 Toggle Output 2 FUNC_TIMER1_TOGGLE3FPIOAFunction= 196// TIMER1 Toggle Output 3 FUNC_TIMER1_TOGGLE4FPIOAFunction= 197// TIMER1 Toggle Output 4 FUNC_TIMER2_TOGGLE1FPIOAFunction= 198// TIMER2 Toggle Output 1 FUNC_TIMER2_TOGGLE2FPIOAFunction= 199// TIMER2 Toggle Output 2 FUNC_TIMER2_TOGGLE3FPIOAFunction= 200// TIMER2 Toggle Output 3 FUNC_TIMER2_TOGGLE4FPIOAFunction= 201// TIMER2 Toggle Output 4 FUNC_CLK_SPI2FPIOAFunction= 202// Clock SPI2 FUNC_CLK_I2C2FPIOAFunction= 203// Clock I2C2 FUNC_INTERNAL0FPIOAFunction= 204// Internal function signal 0 FUNC_INTERNAL1FPIOAFunction= 205// Internal function signal 1 FUNC_INTERNAL2FPIOAFunction= 206// Internal function signal 2 FUNC_INTERNAL3FPIOAFunction= 207// Internal function signal 3 FUNC_INTERNAL4FPIOAFunction= 208// Internal function signal 4 FUNC_INTERNAL5FPIOAFunction= 209// Internal function signal 5 FUNC_INTERNAL6FPIOAFunction= 210// Internal function signal 6 FUNC_INTERNAL7FPIOAFunction= 211// Internal function signal 7 FUNC_INTERNAL8FPIOAFunction= 212// Internal function signal 8 FUNC_INTERNAL9FPIOAFunction= 213// Internal function signal 9 FUNC_INTERNAL10FPIOAFunction= 214// Internal function signal 10 FUNC_INTERNAL11FPIOAFunction= 215// Internal function signal 11 FUNC_INTERNAL12FPIOAFunction= 216// Internal function signal 12 FUNC_INTERNAL13FPIOAFunction= 217// Internal function signal 13 FUNC_INTERNAL14FPIOAFunction= 218// Internal function signal 14 FUNC_INTERNAL15FPIOAFunction= 219// Internal function signal 15 FUNC_INTERNAL16FPIOAFunction= 220// Internal function signal 16 FUNC_INTERNAL17FPIOAFunction= 221// Internal function signal 17 FUNC_CONSTANTFPIOAFunction= 222// Constant function FUNC_INTERNAL18FPIOAFunction= 223// Internal function signal 18 FUNC_DEBUG0FPIOAFunction= 224// Debug function 0 FUNC_DEBUG1FPIOAFunction= 225// Debug function 1 FUNC_DEBUG2FPIOAFunction= 226// Debug function 2 FUNC_DEBUG3FPIOAFunction= 227// Debug function 3 FUNC_DEBUG4FPIOAFunction= 228// Debug function 4 FUNC_DEBUG5FPIOAFunction= 229// Debug function 5 FUNC_DEBUG6FPIOAFunction= 230// Debug function 6 FUNC_DEBUG7FPIOAFunction= 231// Debug function 7 FUNC_DEBUG8FPIOAFunction= 232// Debug function 8 FUNC_DEBUG9FPIOAFunction= 233// Debug function 9 FUNC_DEBUG10FPIOAFunction= 234// Debug function 10 FUNC_DEBUG11FPIOAFunction= 235// Debug function 11 FUNC_DEBUG12FPIOAFunction= 236// Debug function 12 FUNC_DEBUG13FPIOAFunction= 237// Debug function 13 FUNC_DEBUG14FPIOAFunction= 238// Debug function 14 FUNC_DEBUG15FPIOAFunction= 239// Debug function 15 FUNC_DEBUG16FPIOAFunction= 240// Debug function 16 FUNC_DEBUG17FPIOAFunction= 241// Debug function 17 FUNC_DEBUG18FPIOAFunction= 242// Debug function 18 FUNC_DEBUG19FPIOAFunction= 243// Debug function 19 FUNC_DEBUG20FPIOAFunction= 244// Debug function 20 FUNC_DEBUG21FPIOAFunction= 245// Debug function 21 FUNC_DEBUG22FPIOAFunction= 246// Debug function 22 FUNC_DEBUG23FPIOAFunction= 247// Debug function 23 FUNC_DEBUG24FPIOAFunction= 248// Debug function 24 FUNC_DEBUG25FPIOAFunction= 249// Debug function 25 FUNC_DEBUG26FPIOAFunction= 250// Debug function 26 FUNC_DEBUG27FPIOAFunction= 251// Debug function 27 FUNC_DEBUG28FPIOAFunction= 252// Debug function 28 FUNC_DEBUG29FPIOAFunction= 253// Debug function 29 FUNC_DEBUG30FPIOAFunction= 254// Debug function 30 FUNC_DEBUG31FPIOAFunction= 255// Debug function 31 )
Every pin on the Kendryte K210 is assigned to an FPIOA function. Each pin can be configured with every function below.
const ( D0= P00// JTAG_TCLK D1= P01// JTAG_TDI D2= P02// JTAG_TMS D3= P03// JTAG_TDO D4= P04// UARTHS_RX D5= P05// UARTHS_TX D6= P06// RESV0 D7= P07// RESV0 D8= P08// GPIO1 D9= P09// GPIO2 D10= P10// GPIO3 D11= P11// GPIO4 D12= P12// GPIO5 D13= P13// GPIO6 D14= P14// GPIO7 D15= P15// GPIO8 D16= P16// GPIOHS0 D17= P17// GPIOHS1 D18= P18// GPIOHS2 D19= P19// GPIOHS3 D20= P20// GPIOHS4 D21= P21// GPIOHS5 D22= P22// GPIOHS6 D23= P23// GPIOHS7 D24= P24// GPIOHS8 D25= P25// GPIOHS9 D26= P26// GPIOHS10 / SPI0_SDI D27= P27// GPIOHS11 / SPI0_SCLK D28= P28// GPIOHS12 / SPI0_SDO D29= P29// GPIOHS13 D30= P30// GPIOHS14 D31= P31// GPIOHS15 D32= P32// GPIOHS16 D33= P33// GPIOHS17 D34= P34// GPIOHS18 D35= P35// GPIOHS19 )
Pins on the MAix Bit.
const ( LED= LED1 LED1= LED_RED LED2= LED_GREEN LED3= LED_BLUE LED_RED= D13 LED_GREEN= D12 LED_BLUE= D14 )
const ( UART_TX_PIN= D5 UART_RX_PIN= D4 )
Default pins for UARTHS.
const ( SPI0_SCK_PIN= D27 SPI0_SDO_PIN= D28 SPI0_SDI_PIN= D26 )
SPI pins.
const ( I2C0_SDA_PIN= D34 I2C0_SCL_PIN= D35 )
I2C pins.
const ( TWI_FREQ_100KHZ= 100000 TWI_FREQ_400KHZ= 400000 )
TWI_FREQ is the I2C bus speed. Normally either 100 kHz, or 400 kHz for high-speed bus.
Deprecated: use 100 * machine.KHz or 400 * machine.KHz instead.
const ( // I2CReceive indicates target has received a message from the controller. I2CReceiveI2CTargetEvent= iota // I2CRequest indicates the controller is expecting a message from the target. I2CRequest // I2CFinish indicates the controller has ended the transaction. // // I2C controllers can chain multiple receive/request messages without // relinquishing the bus by doing 'restarts'. I2CFinish indicates the // bus has been relinquished by an I2C 'stop'. I2CFinish )
const ( // I2CModeController represents an I2C peripheral in controller mode. I2CModeControllerI2CMode= iota // I2CModeTarget represents an I2C peripheral in target mode. I2CModeTarget )
const Device = deviceName
Device is the running program’s chip name, such as “ATSAMD51J19A” or “nrf52840”. It is not the same as the CPU name.
The constant is some hardcoded default value if the program does not target a particular chip but instead runs in WebAssembly for example.
const ( KHz= 1000 MHz= 1000_000 GHz= 1000_000_000 )
Generic constants.
const NoPin = Pin(0xff)
NoPin explicitly indicates “not a pin”. Use this pin if you want to leave one of the pins in a peripheral unconfigured (if supported by the hardware).
const ( PinInputPinMode= iota PinInputPullup PinInputPulldown PinOutput )
Pin modes.
const ( PinInputPullUp= PinInputPullup PinInputPullDown= PinInputPulldown )
Deprecated: use PinInputPullup and PinInputPulldown instead.
const ( PinRisingPinChange= 1 << iota PinFalling PinToggle= PinRising | PinFalling )
GPIOHS pin interrupt events.
const ( Mode0= 0 Mode1= 1 Mode2= 2 Mode3= 3 )
SPI phase and polarity configs CPOL and CPHA
const ( // ParityNone means to not use any parity checking. This is // the most common setting. ParityNoneUARTParity= iota // ParityEven means to expect that the total number of 1 bits sent // should be an even number. ParityEven // ParityOdd means to expect that the total number of 1 bits sent // should be an odd number. ParityOdd )
Variables
var DefaultUART = UART0
var ( SPI0= &SPI{ Bus: kendryte.SPI0, } SPI1= &SPI{ Bus: kendryte.SPI1, } )
SPI on the MAix Bit.
var ( ErrTimeoutRNG= errors.New("machine: RNG Timeout") ErrClockRNG= errors.New("machine: RNG Clock Error") ErrSeedRNG= errors.New("machine: RNG Seed Error") ErrInvalidInputPin= errors.New("machine: invalid input pin") ErrInvalidOutputPin= errors.New("machine: invalid output pin") ErrInvalidClockPin= errors.New("machine: invalid clock pin") ErrInvalidDataPin= errors.New("machine: invalid data pin") ErrNoPinChangeChannel= errors.New("machine: no channel available for pin interrupt") )
var ( UART0= &_UART0 _UART0= UART{Bus: kendryte.UARTHS, Buffer: NewRingBuffer()} )
var ( I2C0= (*I2C)(unsafe.Pointer(kendryte.I2C0)) I2C1= (*I2C)(unsafe.Pointer(kendryte.I2C1)) I2C2= (*I2C)(unsafe.Pointer(kendryte.I2C2)) )
var ( ErrPWMPeriodTooLong = errors.New("pwm: period too long") )
var Serial = DefaultUART
Serial is implemented via the default (usually the first) UART on the chip.
var ( ErrTxInvalidSliceSize= errors.New("SPI write and read slices must be same size") errSPIInvalidMachineConfig= errors.New("SPI port was not configured properly by the machine") )
func CPUFrequency
func CPUFrequency() uint32
func InitSerial
func InitSerial()
func NewRingBuffer
func NewRingBuffer() *RingBuffer
NewRingBuffer returns a new ring buffer.
type ADC
type ADC struct { Pin Pin }
type ADCConfig
type ADCConfig struct { Referenceuint32// analog reference voltage (AREF) in millivolts Resolutionuint32// number of bits for a single conversion (e.g., 8, 10, 12) Samplesuint32// number of samples for a single conversion (e.g., 4, 8, 16, 32) SampleTimeuint32// sample time, in microseconds (µs) }
ADCConfig holds ADC configuration parameters. If left unspecified, the zero value of each parameter will use the peripheral’s default settings.
type FPIOAFunction
type FPIOAFunction uint8
type I2C
type I2C struct { Bus kendryte.I2C_Type }
I2C on the K210.
func (*I2C) Configure
func (i2c *I2C) Configure(config I2CConfig) error
Configure is intended to setup the I2C interface.
func (*I2C) ReadRegister
func (i2c *I2C) ReadRegister(address uint8, register uint8, data []byte) error
ReadRegister transmits the register, restarts the connection as a read operation, and reads the response.
Many I2C-compatible devices are organized in terms of registers. This method is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority.
func (*I2C) SetBaudRate
func (i2c *I2C) SetBaudRate(br uint32) error
SetBaudRate sets the communication speed for I2C.
func (*I2C) Tx
func (i2c *I2C) Tx(addr uint16, w, r []byte) error
Tx does a single I2C transaction at the specified address. It clocks out the given address, writes the bytes in w, reads back len(r) bytes and stores them in r, and generates a stop condition on the bus.
func (*I2C) WriteRegister
func (i2c *I2C) WriteRegister(address uint8, register uint8, data []byte) error
WriteRegister transmits first the register and then the data to the peripheral device.
Many I2C-compatible devices are organized in terms of registers. This method is a shortcut to easily write to such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority.
type I2CConfig
type I2CConfig struct { Frequencyuint32 SCLPin SDAPin }
I2CConfig is used to store config info for I2C.
type I2CMode
type I2CMode int
I2CMode determines if an I2C peripheral is in Controller or Target mode.
type I2CTargetEvent
type I2CTargetEvent uint8
I2CTargetEvent reflects events on the I2C bus
type NullSerial
type NullSerial struct { }
NullSerial is a serial version of /dev/null (or null router): it drops everything that is written to it.
func (NullSerial) Buffered
func (ns NullSerial) Buffered() int
Buffered returns how many bytes are buffered in the UART. It always returns 0 as there are no bytes to read.
func (NullSerial) Configure
func (ns NullSerial) Configure(config UARTConfig) error
Configure does nothing: the null serial has no configuration.
func (NullSerial) ReadByte
func (ns NullSerial) ReadByte() (byte, error)
ReadByte always returns an error because there aren’t any bytes to read.
func (NullSerial) Write
func (ns NullSerial) Write(p []byte) (n int, err error)
Write is a no-op: none of the data is being written and it will not return an error.
func (NullSerial) WriteByte
func (ns NullSerial) WriteByte(b byte) error
WriteByte is a no-op: the null serial doesn’t write bytes.
type PDMConfig
type PDMConfig struct { Stereobool DINPin CLKPin }
type PWMConfig
type PWMConfig struct { // PWM period in nanosecond. Leaving this zero will pick a reasonable period // value for use with LEDs. // If you want to configure a frequency instead of a period, you can use the // following formula to calculate a period from a frequency: // // period = 1e9 / frequency // Period uint64 }
PWMConfig allows setting some configuration while configuring a PWM peripheral. A zero PWMConfig is ready to use for simple applications such as dimming LEDs.
type Pin
type Pin uint8
Pin is a single pin on a chip, which may be connected to other hardware devices. It can either be used directly as GPIO pin or it can be used in other peripherals like ADC, I2C, etc.
func (Pin) Configure
func (p Pin) Configure(config PinConfig)
Configure this pin with the given configuration. The pin must already be set as GPIO or GPIOHS pin.
func (Pin) FPIOAFunction
func (p Pin) FPIOAFunction() FPIOAFunction
FPIOAFunction returns the current FPIOA function of the pin.
func (Pin) Get
func (p Pin) Get() bool
Get returns the current value of a GPIO pin.
func (Pin) High
func (p Pin) High()
High sets this GPIO pin to high, assuming it has been configured as an output pin. It is hardware dependent (and often undefined) what happens if you set a pin to high that is not configured as an output pin.
func (Pin) Low
func (p Pin) Low()
Low sets this GPIO pin to low, assuming it has been configured as an output pin. It is hardware dependent (and often undefined) what happens if you set a pin to low that is not configured as an output pin.
func (Pin) Set
func (p Pin) Set(high bool)
Set the pin to high or low.
func (Pin) SetFPIOAFunction
func (p Pin) SetFPIOAFunction(f FPIOAFunction)
SetFPIOAFunction is used to configure the pin for one of the FPIOA functions. Each pin on the Kendryte K210 can be configured with any of the available FPIOA functions.
func (Pin) SetInterrupt
func (p Pin) SetInterrupt(change PinChange, callback func(Pin)) error
SetInterrupt sets an interrupt to be executed when a particular pin changes state. The pin should already be configured as an input, including a pull up or down if no external pull is provided.
You can pass a nil func to unset the pin change interrupt. If you do so, the change parameter is ignored and can be set to any value (such as 0). If the pin is already configured with a callback, you must first unset this pins interrupt before you can set a new callback.
type PinChange
type PinChange uint8
type PinConfig
type PinConfig struct { Mode PinMode }
type PinMode
type PinMode uint8
PinMode sets the direction and pull mode of the pin. For example, PinOutput sets the pin as an output and PinInputPullup sets the pin as an input with a pull-up.
type RingBuffer
type RingBuffer struct { rxbuffer[bufferSize]volatile.Register8 headvolatile.Register8 tailvolatile.Register8 }
RingBuffer is ring buffer implementation inspired by post at https://www.embeddedrelated.com/showthread/comp.arch.embedded/77084-1.php
func (*RingBuffer) Clear
func (rb *RingBuffer) Clear()
Clear resets the head and tail pointer to zero.
func (*RingBuffer) Get
func (rb *RingBuffer) Get() (byte, bool)
Get returns a byte from the buffer. If the buffer is empty, the method will return a false as the second value.
func (*RingBuffer) Put
func (rb *RingBuffer) Put(val byte) bool
Put stores a byte in the buffer. If the buffer is already full, the method will return false.
func (*RingBuffer) Used
func (rb *RingBuffer) Used() uint8
Used returns how many bytes in buffer have been used.
type SPI
type SPI struct { Bus *kendryte.SPI_Type }
func (*SPI) Configure
func (spi *SPI) Configure(config SPIConfig) error
Configure is intended to setup the SPI interface. Only SPI controller 0 and 1 can be used because SPI2 is a special peripheral-mode controller and SPI3 is used for flashing.
func (*SPI) Transfer
func (spi *SPI) Transfer(w byte) (byte, error)
Transfer writes/reads a single byte using the SPI interface.
func (*SPI) Tx
func (spi *SPI) Tx(w, r []byte) error
Tx handles read/write operation for SPI interface. Since SPI is a synchronous write/read interface, there must always be the same number of bytes written as bytes read. The Tx method knows about this, and offers a few different ways of calling it.
This form sends the bytes in tx buffer, putting the resulting bytes read into the rx buffer. Note that the tx and rx buffers must be the same size:
spi.Tx(tx, rx)
This form sends the tx buffer, ignoring the result. Useful for sending “commands” that return zeros until all the bytes in the command packet have been received:
spi.Tx(tx, nil)
This form sends zeros, putting the result into the rx buffer. Good for reading a “result packet”:
spi.Tx(nil, rx)
type SPIConfig
type SPIConfig struct { Frequencyuint32 SCKPin SDOPin SDIPin LSBFirstbool Modeuint8 }
SPIConfig is used to store config info for SPI.
type UART
type UART struct { Bus*kendryte.UARTHS_Type Buffer*RingBuffer }
func (*UART) Buffered
func (uart *UART) Buffered() int
Buffered returns the number of bytes currently stored in the RX buffer.
func (*UART) Configure
func (uart *UART) Configure(config UARTConfig)
func (*UART) Read
func (uart *UART) Read(data []byte) (n int, err error)
Read from the RX buffer.
func (*UART) ReadByte
func (uart *UART) ReadByte() (byte, error)
ReadByte reads a single byte from the RX buffer. If there is no data in the buffer, returns an error.
func (*UART) Receive
func (uart *UART) Receive(data byte)
Receive handles adding data to the UART’s data buffer. Usually called by the IRQ handler for a machine.
func (*UART) Write
func (uart *UART) Write(data []byte) (n int, err error)
Write data over the UART’s Tx. This function blocks until the data is finished being sent.
func (*UART) WriteByte
func (uart *UART) WriteByte(c byte) error
WriteByte writes a byte of data over the UART’s Tx. This function blocks until the data is finished being sent.
type UARTConfig
type UARTConfig struct { BaudRateuint32 TXPin RXPin RTSPin CTSPin }
UARTConfig is a struct with which a UART (or similar object) can be configured. The baud rate is usually respected, but TX and RX may be ignored depending on the chip and the type of object.
type UARTParity
type UARTParity uint8
UARTParity is the parity setting to be used for UART communication.