Constant | Description |
---|---|
LED_ON | Nonification led on |
LED_OFF | Nonification led off |
LED_BLINK | Nonification led pattern |
LED_SHORTBLINK | Nonification led pattern |
LED_ALARM | Nonification led pattern |
Constant | Description |
---|---|
BTN_A | Button define |
BTN_LEFT | Button define |
BTN_UP | Button define |
BTN_DOWN | Button define |
BTN_RIGHT | Button define |
BTN_B | Button define |
Constant | Description |
---|---|
PIN_IN | Pin set as input |
PIN_OUT | Pin set as output |
PIN_ALT | Pin set to its alternate function |
PIN_NOPULL | Pin set as input with pulldown |
PIN_PULLUP | Pin set as input with pullup |
PIN_PULLDOWN | Pin set as input with no pull resistor |
sys.hw.lockSleep([num]val);
Sets sleep lock value. On 1 system wont go to sleep.
Return: None
sys.hw.wakeLcd();
Turns on the LCD screen.
Return: None
sys.hw.getLcdState();
Gets state of lcd.
Return: 1 if lcd is on, otherwise 0
sys.hw.setLed([num]led_type);
Sets notification led to a given pattern, uses: LED_ON, LED_OFF ,LED_BLINK, LED_SHORTBLINK, LED_ALARM
Return: None
sys.hw.getUsbState();
Gets state of usb port. Useful for determining if the SDA is connected to PC.
Return: 1 when powered from usb, otherwise 0
System resources:
Resource define | Description |
---|---|
EXT_EXP_PORT | External expansion connector |
INT_EXP_PORT | Internal expansion connector |
USB_PORT | USB port (ftdi serial) |
SERIAL_PORT | internal/external serial port |
Locks area automatically freed on app close.
sys.hw.claim([num]Resource);
Claims given hardware resouce for currently running app.
Return: [num] 1 - error, 0 - ok
sys.hw.free([num]Resource);
Frees given hardware resouce. Return: [num] 1 - error, 0 - ok
sys.hw.getLock([num]Resource);
Frees given hardware resouce. Return: [num] 1 - locked, 0 - free
Internal expansion connector pinout:
MCU pin | Exc pin number | Exc pin number | MCU pin |
---|---|---|---|
PD15 | 01 | 09 | PB15 |
PD14 | 02 | 10 | PB14 |
PD13 | 03 | 11 | PB13 |
PD12 | 04 | GND | - |
PD11 | 05 | Vcc (3.3V) | - |
PD10 | 06 | 14 | PE12 |
PD09 | 07 | 15 | PE13 |
PD08 | 08 | 16 | PE14 |
Dot marks the pin no. 1
sys.hw.iPinDef([num]Pin, [num]type, [num]pullUp);
Sets direction of internal expansion pins. Uses defines: PIN_IN, PIN_OUT, PIN_ALT, PIN_NOPULL, PIN_PULLUP, PIN_PULDOWN Pin number is number of pin on the connector, can be read from schematics.
Return: None
sys.hw.iPinSet([num]Pin, [num]val);
Sets state of internal expansion pin. Value 1 sets the pin high, value 0 sets it low. Pin number is number of pin on the connector, can be read from schematics.
Return: None
sys.hw.iPinGet([num]Pin);
Gets state of internal expansion pin. Pin number is number of pin on the connector, can be read from schematics.
Return: 1 if the pin is high, 0 if it is low.
External expansion connector pinout:
Exc pin number | MCU pin | Alt Function |
---|---|---|
1 | GND | |
2 | PA1 | ADC_IN |
3 | 3.3V | |
4 | PE15 | I/O |
5 | PB10 | Tx |
6 | PB11 | Rx |
Pin no. 1 is the one closest ot the charging LED
sys.hw.ePinDef([num]Pin, [num]type, [num]pullUp);
Sets direction of external expansion pins. Uses defines: PIN_IN, PIN_OUT, PIN_ALT, PIN_NOPULL, PIN_PULLUP, PIN_PULDOWN Pin number is number of pin on the connector, can be read from schematics.
Return: None
sys.hw.ePinSet([num]Pin, [num]val);
Sets state of external expansion pin. Value 1 sets the pin high, value 0 sets it low. Pin number is number of pin on the connector, can be read from schematics.
Return: None
sys.hw.ePinGet([num]Pin);
Gets state of external expansion pin. Pin number is number of pin on the connector, can be read from schematics.
Return: 1 if the pin is high, 0 if it is low.
sys.hw.eADCRead();
Gets state of external expansion pin. Pin number is number of pin on the connector, can be read from schematics.
Return: [float] measured voltage in volts.
sys.hw.btn.getEvent([num]btn);
Return last button event.
Return: [num] event define (EV_NONE, EV_PRESSED, EV_HOLD, EV_RELEASED)
sys.hw.btn.clrEvent([num]btn);
Sets button event to EV_NONE
Return: None
sys.hw.btn.stdbyEn([num]val);
Enables button readout with LCD off. When this is enabled, SDA won't go in deep sleep.
Return: None
Could be used for all the transmission modes.
sys.com.qAdd([num]data);
Queues given hex value to transmit buffer. Max 32 bytes.
Return: [num] 1-ok, 0-full buffer
sys.com.qClr();
Clears transmit buffer.
Return: None
sys.com.usbTrs([str]data);
Sends given string to usb serial port.
Return: None
sys.com.usbTrsQ();
Sends previously stored queue to the initialized serial port. Queue can be filled with sys.srlTrsQAdd and cleared with sys.srlTrsQClr. Max 32 bytes.
Return: None
sys.com.usbSetBd([num] bd);
Sets baud rate of the usb-serial port
Return: none
sys.com.usbRcv([num]timeout);
Gets string (max 512 bytes) from USB serial port. If nothing is sent during timeout (in ms), empty string is returned.
Return: [str] data
sys.com.usbRcvIT();
Initializes usb serial port receive operation in non-blocking mode Returns 1 if ok, 0 if error occurred
Return: [num] result
sys.com.usbGetRd();
Gets transmission ready flag. Returns 1 if data is pending, 2 if whole line of data is pending
Return: [num] ready
sys.com.usbGetStr();
Gets the pending string and resets the serial interface for another ready flag.
Return: [str] pending
sys.com.usbGetBytes();
Gets the bytes from a serial interface and stores them in local buffer (512 Bytes max)
Return: [num] bytes used
sys.com.usbGetByte([num] index);
Reads the byte value from a serial interface local buffer (512 Bytes)
Return: [num] byte value (0 - 255, -1 when error occurs)
Code to init the internal expansion port serial interface:
sys.hw.iPinDef(15, PIN_ALT, PIN_NOPULL);
sys.hw.iPinDef(16, PIN_OUT, PIN_NOPULL);
Code to init the external expansion port serial interface:
sys.hw.ePinDef(5, PIN_ALT, PIN_NOPULL);
sys.hw.ePinDef(6, PIN_ALT, PIN_NOPULL);
sys.com.uartTrs([str]data);
Sends given string to serial port on internal or external expansion connector. Depends on what is initialized.
Return: None
sys.com.uartTrsQ();
Sends previously stored queue to the initialized serial port. Max 32 bytes.
Return: None
sys.com.uartRcv([num]timeout);
Gets string (max 512 bytes) from currently initialized serial port. If nothing is sent during timeout (in ms), empty string is returned.
Return: [str] data
sys.com.uartSetBd([num] bd);
Sets baud rate of the uart expansion port
Return: none
For more flexible serial interface operations
sys.com.uartRcvIT();
Initializes serial port receive operation in non-blocking mode
Return: [num] result (1 if ok, 0 if error occurred)
sys.com.uartGetRd();
Gets transmission ready flag. Returns 1 if data is pending, 2 if whole line of data is pending
Return: [num] ready
sys.com.uartGetStr();
Gets the pending string and resets the serial interface for another ready flag.
Return: [str] pending
sys.com.uartGetBytes();
Gets the bytes from a serial interface and stores them in local buffer (512 Bytes)
Return: [num] bytes used
sys.com.uartGetByte([num] index);
Gets the byte value from a serial interface local buffer (512 Bytes)
Return: [num] byte value (0 - 255, -1 when error occurs)
sys.com.uartRdClb([str] callback, [num] val);
Registers callback on expansion uart, when rd flag goes to val, application will be waken up and callback will be called. Application can fully resume by calling sys.os.arise(); Serial port needs to be previously configured for IT receive. Setting val to zero will disable the callback.
Return: [num] success