For the most part, you can call Python Client Library functions the same way as C Peripheral Driver functions – python will even forgive you if your function call is followed by a semi-colon. Some key differences are outlined below using the peripheral pin select as an example.

Includes

#include “lpc17xx_pinsel.h” /* C */

import robovero.lpc17xx_pinsel # Python

Additionally, unless you want to append each function call with the name of the module containing it, you need to import functions and types individually by name.

from robovero.lpc17xx_pinsel import PINSEL_CFG_Type, PINSEL_ConfigPin

Enums

C enums are represented by classes in Python. The enumerators are class variables. Here is the declaration of a function that accepts an enumerated type as its sole argument.

void PINSEL_ConfigTraceFunc (FunctionalState NewState);

And here is how it is used in Python and C:

PINSEL_ConfigTraceFunc(ENABLE); /* C */

from robovero.lpc_types import FunctionalState # Python

PINSEL_ConfigTraceFunc(FunctionalState.ENABLE);

Structs

Structs in C are treated as classes in Python. The main differences are declaration and referencing.

Declaration

PINSEL_CFG_Type PinCfg; /* C */

PinCfg = PINSEL_CFG_Type() # Python

Referencing

PINSEL_ConfigPin(&PinCfg); /* C */

PINSEL_ConfigPin(PinCfg.ptr) # Python

Arrays

You can use lists, tuples, strings, etc. to store data in memory on the machine where python is running. In certain cases you need to store an array of data in RoboVero memory. One such case is to use the function UART_SEND which expects a pointer to an array of data. Here is one of many ways this can be achieved in C:

#include “string.h”

#include “lpc17xx_uart.h”

#include “lpc_types.h”

#include “LPC17xx.h”

#include “extras.h”

char msg[] = “RoboVero smash!”;

roboveroConfig();

UART_Send(LPC_UART1, msg, strlen(msg), BLOCKING);

The robovero.extras module contains a class called Array. The initialization functions takes the number of elements, width of each element, and initialization values (optional) as arguments. Values can be a string, list, or single value to copy to RoboVero memory. In case a single value is provided, it is used for each element in the array.

from robovero.extras import Array, roboveroConfig

from robovero.LPC17xx import LPC_UART1

from robovero.lpc17xx_uart import UART_Send

from robovero.lpc_types import TRANSFER_BLOCK_Type

_msg = “RoboVero smash!”

msg = Array(len(_msg), 1, _msg)

roboveroConfig()

UART_Send(LPC_UART1, msg.ptr, msg.length, TRANSFER_BLOCK_Type.BLOCKING)