Skip to content

Latest commit

 

History

History
115 lines (97 loc) · 2.85 KB

API.md

File metadata and controls

115 lines (97 loc) · 2.85 KB

Aixt Application Programmimg Interface

Digital I/O (Pins)

Pin setup

pin_setup(pin_name, mode)
  • pin_name could change depending on the microcontroller.
  • mode:
    • in
    • out

Pin output

pin_high(pin_name)
pin_low(pin_name)
pin_toggle(pin_name)    
// not available for all devices
pin_write(pin_name, value)
  • value is an integer to be written in the pin
    • 0 or low
    • 1 or high

Pin input

x = pin_read(pin_name)

pin_read returns an integer (0 or 1)

Analog to Digital Converter (ADC inputs)

The syntax for all the ADC functions is: adcx_function_name(), being x the identifing number in case of multiple ADCs. You can ommit the x for refering to the first ADC or in the case of having only one.

ADC setup

adc_setup(setup_value_1, setup_value_2, ... )   // equals to adc1_setup(...)

ADC reading

x = adc_read(channel)
  • channel is an identifing number of the ADC input

Pulse Width Modulation (PWM outputs)

The syntax for all the PWM functions is: pwmx_function_name(), being x the identifing number in case of multiple PWM outputs. You can ommit the x for refering to the first PWM output or in the case of having only one.

PWM setup

pwm1_setup(setup_value_1, setup_value_2, ... )  //or just pwm_setup(...)

PWM duty cycle

pwm_write(duty)  //or pwm1_duty(duty)
  • duty is the duty cycle in percentage (0 - 100)

Serial comunication (UART)

The UART used to be the standard stream output, so the functions print(), println() and input() work directly on the default UART. The default UART could change depending on the board or microcontroller, please refer to the especific dom¿cumentation. The syntax for most of UART functions is: uartx_function_name(), being x the identifing number in case of multiple UARTs. You can ommit the x for refering to the first UART or in the case of having only one.

UART setup

uart_setup(baud_rate)   // the same of uart1_setup(baud_rate)
  • baud_rate configurate the comunication speed

Serial receiving

str1 = input()          // read a string from the default UART
str2 = uart2_input()    // read a string from UART2
str2 = uart1_read()    // read a single Byte from UART1

Serial transmitting

print(message)      // print a string to the default UART
println(message)    // print a string plus a line-new character to the default UART
uart2_print(message)    // print a string to the UART2
uart1_println(message)  // print a string plus a line-new character to the UART1
uart2_write(message)    // send binary data (in Bytes) to UART2

Timming

sleep(s)    // delay in seconds
sleep_ms(ms)    // delay in milliseconds
sleep_us(us)    // delay in microseconds