SAM4L-EK Board Monitor Control.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
Data Structures | |
struct | sam4l_status_msg_t |
struct | sam4l_status_t |
Enumerations | |
enum | cpu_src_t { CPU_SRC_NA = 0, CPU_SRC_RCSYS = 1, CPU_SRC_OSC0 = 2, CPU_SRC_PLL = 3, CPU_SRC_DFLL = 4, CPU_SRC_RC1M = 5, CPU_SRC_RC4M = 6, CPU_SRC_RC80M = 7, CPU_SRC_CRIPOSC = 8 } |
CPU Source. More... | |
enum | power_scaling_t { POWER_SCALING_NA = 0, POWER_SCALING_PS0 = 1, POWER_SCALING_PS1 = 2, POWER_SCALING_PS2 = 3 } |
Power scaling definitions. More... | |
enum | sleep_mode_t { SLEEP_MODE_NA = 0, SLEEP_MODE_RUN = 1, SLEEP_MODE_0 = 2, SLEEP_MODE_1 = 3, SLEEP_MODE_2 = 4, SLEEP_MODE_3 = 5, SLEEP_MODE_WAIT = 6, SLEEP_MODE_RETENTION = 7, SLEEP_MODE_BACKUP = 8 } |
Sleep Mode definitions. More... | |
Functions | |
void | bm_ctrl (bool state) |
Enable/disable the board monitor. More... | |
bool | bm_get_fifo_free_size (uint16_t *free_size) |
Return the free size (in byte) of the board monitor command fifo. More... | |
bool | bm_get_firmware_version (uint8_t *fw_minor_version, uint8_t *fw_major_version) |
Get Firmware Version. More... | |
bool | bm_get_mcu_current (uint32_t *sleep_mode, float *current) |
Return Current Consumption Measured. More... | |
void | bm_init (void) |
Configure the board monitor. More... | |
void | bm_led_clr (uint32_t led) |
Turn-off a LED of the board monitor. More... | |
void | bm_led_set (uint32_t led) |
Turn-on a LED of the board monitor. More... | |
void | bm_led_tgl (uint32_t led) |
Toggle a LED of the board monitor. More... | |
void | bm_mouse_pointer_ctrl (bool state) |
Enable/disable the board monitor mouse-like pointer. More... | |
void | bm_mouse_pointer_move (uint32_t x, uint32_t y) |
Send new mouse pointer position. More... | |
void | bm_print_clear (void) |
Clear Print Text Area. More... | |
void | bm_print_txt (uint8_t *str, uint8_t str_length) |
Print Text On Board Monitor. More... | |
void | bm_pullup_twi (bool state) |
Enable/disable the pull-up on TWI lines. More... | |
void | bm_send_mcu_status (uint32_t power_scaling, uint32_t sleep_mode, uint32_t cpu_freq, uint32_t cpu_src) |
Send MCU power saving information to the board monitor, in order to get them displayed on the OLED screen. More... | |
void | bm_send_picouart_frame (uint8_t frame, uint32_t timeout_ms) |
Send PicoUart Frame. More... | |
void | bm_tgl_button (uint32_t timeout_ms) |
Force Toggle of Button Line. More... | |
enum cpu_src_t |
enum power_scaling_t |
enum sleep_mode_t |
Sleep Mode definitions.
void bm_ctrl | ( | bool | state | ) |
Enable/disable the board monitor.
state | true to enable, false to disable. |
References BM_CTRL, BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_USART_USART, usart_disable_tx(), usart_enable_tx(), usart_is_tx_empty(), and usart_putchar().
bool bm_get_fifo_free_size | ( | uint16_t * | free_size | ) |
Return the free size (in byte) of the board monitor command fifo.
free_size | free size in byte. |
References BM_MCU_GET_FIFO_FREE_SIZE, BM_MCU_RET_FIFO_FREE_SIZE, BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_USART_USART, delay_ms, usart_disable_rx(), usart_disable_tx(), usart_enable_rx(), usart_enable_tx(), usart_getchar(), usart_is_tx_empty(), and usart_putchar().
bool bm_get_firmware_version | ( | uint8_t * | fw_minor_version, |
uint8_t * | fw_major_version | ||
) |
Get Firmware Version.
fw_minor_version | Firmware Version (in ascii format). |
fw_major_version | Firmware Version (in ascii format). |
References BM_GET_FIRMWARE_VERSION, BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_RET_FIRMWARE_VERSION, BM_USART_USART, delay_ms, usart_disable_rx(), usart_disable_tx(), usart_enable_rx(), usart_enable_tx(), usart_getchar(), usart_is_tx_empty(), and usart_putchar().
bool bm_get_mcu_current | ( | uint32_t * | sleep_mode, |
float * | current | ||
) |
Return Current Consumption Measured.
sleep_mode | Sleep Mode Desired. |
current | Current Value Measured. |
References BM_MCU_GET_CURRENT, BM_MCU_RET_CURRENT, BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_USART_USART, usart_disable_rx(), usart_disable_tx(), usart_enable_rx(), usart_enable_tx(), usart_getchar(), usart_is_tx_empty(), and usart_putchar().
void bm_init | ( | void | ) |
Configure the board monitor.
Configure the board monitor.
References BM_USART_USART, sysclk_enable_peripheral_clock(), sysclk_get_peripheral_bus_hz(), and usart_init_rs232().
Referenced by main().
void bm_led_clr | ( | uint32_t | led | ) |
Turn-off a LED of the board monitor.
led | led number. Range is [0; 3]. |
References BM_LED_CLR, BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_USART_USART, usart_disable_tx(), usart_enable_tx(), usart_is_tx_empty(), and usart_putchar().
void bm_led_set | ( | uint32_t | led | ) |
Turn-on a LED of the board monitor.
led | led number. Range is [0; 3]. |
References BM_LED_SET, BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_USART_USART, usart_disable_tx(), usart_enable_tx(), usart_is_tx_empty(), and usart_putchar().
void bm_led_tgl | ( | uint32_t | led | ) |
Toggle a LED of the board monitor.
led | led number. Range is [0; 3]. |
References BM_LED_TGL, BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_USART_USART, usart_disable_tx(), usart_enable_tx(), usart_is_tx_empty(), and usart_putchar().
void bm_mouse_pointer_ctrl | ( | bool | state | ) |
Enable/disable the board monitor mouse-like pointer.
state | true to enable, false to disable. |
References BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_POINTER_CTRL, BM_USART_USART, usart_disable_tx(), usart_enable_tx(), usart_is_tx_empty(), and usart_putchar().
void bm_mouse_pointer_move | ( | uint32_t | x, |
uint32_t | y | ||
) |
Send new mouse pointer position.
x | x position. Range is [0; 127]. |
y | y position range is [0; 63]. |
References BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_POINTER_MOVE, BM_USART_USART, usart_disable_tx(), usart_enable_tx(), usart_is_tx_empty(), and usart_putchar().
void bm_print_clear | ( | void | ) |
Clear Print Text Area.
References BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_PRINT_CLEAR, BM_USART_USART, usart_disable_tx(), usart_enable_tx(), usart_is_tx_empty(), and usart_putchar().
void bm_print_txt | ( | uint8_t * | str, |
uint8_t | str_length | ||
) |
Print Text On Board Monitor.
str | String pattern. |
str_length | String length pattern. |
References BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_PRINT_TEXT, BM_PRINT_TEXT_SIZE, BM_USART_USART, usart_disable_tx(), usart_enable_tx(), usart_is_tx_empty(), and usart_putchar().
void bm_pullup_twi | ( | bool | state | ) |
Enable/disable the pull-up on TWI lines.
state | true to enable, false to disable. |
References BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_PULLUP_TWI, BM_USART_USART, usart_disable_tx(), usart_enable_tx(), usart_is_tx_empty(), and usart_putchar().
void bm_send_mcu_status | ( | uint32_t | power_scaling, |
uint32_t | sleep_mode, | ||
uint32_t | cpu_freq, | ||
uint32_t | cpu_src | ||
) |
Send MCU power saving information to the board monitor, in order to get them displayed on the OLED screen.
power_scaling | Power scaling. |
sleep_mode | Sleep mode. |
cpu_freq | CPU frequency. |
cpu_src | CPU source clock. |
References BM_MCU_STATUS, BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_USART_USART, usart_disable_tx(), usart_enable_tx(), usart_is_tx_empty(), and usart_putchar().
Referenced by main().
void bm_send_picouart_frame | ( | uint8_t | frame, |
uint32_t | timeout_ms | ||
) |
Send PicoUart Frame.
Note that the timeout countdown starts after a 500ms delay in order to keep a stable current measurement.
frame | Frame to be sent. |
timeout_ms | Timeout value in ms. |
References BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_PICOUART_SEND, BM_USART_USART, usart_disable_tx(), usart_enable_tx(), usart_is_tx_empty(), and usart_putchar().
void bm_tgl_button | ( | uint32_t | timeout_ms | ) |
Force Toggle of Button Line.
timeout_ms | Timeout value in ms. |
References BM_MSG_START_PATTERN, BM_MSG_STOP_PATTERN, BM_TGL_BUTTON, BM_USART_USART, usart_disable_tx(), usart_enable_tx(), usart_is_tx_empty(), and usart_putchar().