Microchip® Advanced Software Framework

board_monitor.h File Reference

SAM4L-EK Board Monitor Control.

Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"
#include "usart.h"
#include "board.h"
#include "sysclk.h"

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

CPU Source.

Enumerator
CPU_SRC_NA 

Default configuration for CPU source.

CPU_SRC_RCSYS 

RCSYS.

CPU_SRC_OSC0 

OSC0.

CPU_SRC_PLL 

PLL.

CPU_SRC_DFLL 

DFLL.

CPU_SRC_RC1M 

RC1M.

CPU_SRC_RC4M 

RC4M.

CPU_SRC_RC80M 

RC80M.

CPU_SRC_CRIPOSC 

CRIPOSC.

Power scaling definitions.

Enumerator
POWER_SCALING_NA 

Default Power Scaling Configuration.

POWER_SCALING_PS0 

PS0 Power Scaling Configuration.

POWER_SCALING_PS1 

PS1 Power Scaling Configuration.

POWER_SCALING_PS2 

PS2 Power Scaling Configuration.

Sleep Mode definitions.

Enumerator
SLEEP_MODE_NA 

Default configuration for sleep Mode.

SLEEP_MODE_RUN 

Run Mode.

SLEEP_MODE_0 

Sleep Mode 0.

SLEEP_MODE_1 

Sleep Mode 1.

SLEEP_MODE_2 

Sleep Mode 2.

SLEEP_MODE_3 

Sleep Mode 3.

SLEEP_MODE_WAIT 

Wait Mode.

SLEEP_MODE_RETENTION 

Retention Mode.

SLEEP_MODE_BACKUP 

Backup Mode.

void bm_ctrl ( bool  state)

Enable/disable the board monitor.

Parameters
statetrue 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)
bool bm_get_firmware_version ( uint8_t *  fw_minor_version,
uint8_t *  fw_major_version 
)

Get Firmware Version.

Parameters
fw_minor_versionFirmware Version (in ascii format).
fw_major_versionFirmware 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.

Parameters
sleep_modeSleep Mode Desired.
currentCurrent 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 ui_init().

void bm_led_clr ( uint32_t  led)

Turn-off a LED of the board monitor.

Parameters
ledled 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.

Parameters
ledled 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.

Parameters
ledled 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.

Parameters
statetrue 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().

Referenced by ui_host_connection_event(), ui_host_enum_event(), and ui_init().

void bm_mouse_pointer_move ( uint32_t  x,
uint32_t  y 
)

Send new mouse pointer position.

Parameters
xx position. Range is [0; 127].
yy 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().

Referenced by ui_host_sof_event().

void bm_print_txt ( uint8_t *  str,
uint8_t  str_length 
)

Print Text On Board Monitor.

Parameters
strString pattern.
str_lengthString 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.

Parameters
statetrue 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.

Parameters
power_scalingPower scaling.
sleep_modeSleep mode.
cpu_freqCPU frequency.
cpu_srcCPU 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().

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.

Parameters
frameFrame to be sent.
timeout_msTimeout 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.

Parameters
timeout_msTimeout 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().