GlobLib
HAL and API libraries for MCUs and hardware.

This module contains error code definitions for all libraries. More...

Files

file  stm32f103cb_debug.h
 Header file for stm32f103cb DEBUG.
 

Enumerations

Functions

void MCU_printError (mcu_error error)
 Print a given error number as a character stream. More...
 
void MCU_debugEnable (void(*output_handle)(uint8_t))
 Enables the debug feature. More...
 
void MCU_debugDisable (void)
 Disables the debug feature. More...
 
uint8_t MCU_debugIsEnabled (void)
 Checks if debug is enabled. More...
 

Detailed Description

This module contains error code definitions for all libraries.

Each low level module has an error handling feature

Author
Stuart Ianna
Version
0.1
Date
May 2018
Warning
None
Bug:
None
Todo:
  • Formulate a more efficient way of printing errors.
Compilers
  • arm-none-eabi-gcc (15:4.9.3+svn231177-1) 4.9.3 20150529 (prerelease)
Minimum working example
//Include a USART module to demonstrate an error message and error
//Create a serial structure
USART serial;
int main(void){
//Setup port 1
USART_setup(&serial,USART_1);
//Enable debug feature and set serial put as output stream
MCU_debugEnable(serial.put);
//GENERATE AN ERROR CONDITION, port "43" doesn't exist, this outputs an error
USART_setup(&serial,43);
while(1){
//Print a random error to test functionallity
//Wait a bit for data to transmit
for(int i = 0; i < 0x7FFFF; i++);
}
return 0;
}

Enumeration Type Documentation

enum mcu_error

Error enumerators for the Debug peripheral.

These values are used to quantify errors which occur during configuration of each module When debugging is enabled through MCU_debugEnable(), these determine which string is passed to the error output stream

Enumerator
E_GPIO_NOERROR 

ERROR GPIO: No Error.

E_GPIO_ISR 

ERROR GPIO: ISR EXTI line in use.

E_GPIO_PORT 

ERROR GPIO: Port doesn't exist.

E_GPIO_PIN 

ERROR GPIO: Pin doesn't exist.

E_GPIO_TRIGGER 

ERROR GPIO: ISR trigger doesn't exist.

E_MCU_UNDEFINED 

ERROR MCU: Unknown error code.

E_USART_NOERROR 

Error USART: No Error.

E_USART_NOPORT 

Error USART: Port doesn't exist.

E_USART_NOBAUD 

Error USART: Baud rate not available.

E_USART_NOSTOP 

Error USART: Stop bits don't exist.

E_USART_NODATA 

Error USART: Data frame not available.

E_USART_NOPARITY 

Error USART: Parity option not available.

E_USART_NOINT 

Error USART: Interrupt option doesn't exist.

E_I2C_NOERROR 

ERROR I2C: No Error.

E_I2C_PORT 

ERROR I2C: Port doesn't exist.

E_I2C_WRITE 

ERROR I2C: Timeout during put()

E_I2C_READ 

ERROR I2C: Timeout during get()

E_I2C_START 

ERROR I2C: Timeout during start()

E_I2C_STOP 

ERROR I2C: Timeout during stop()

E_CLOCK_NOERROR 

Error clock: No error.

E_CLOCK_NOSPEED 

Error clock: Clock speed doesn't exist.

E_SYSTICK_NOERROR 

Error systick: No error.

E_SYSTICK_TOOLONG 

Error systick: Timeout value is too short.

E_TIMER_NOERROR 

Error timer: No error.

E_TIMER_NOTIMER 

Error timer: Timer doesn't exist.

E_TIMER_NOCHANNEL 

Error timer: Channel doesn't exist.

E_TIMER_PERIOD 

Error timer: Period too long / frequency too high.

E_TIMER_PULSE 

Error timer: Pulse too long.

E_ADC_NOERROR 

Error ADC: No error.

E_ADC_PORT 

Error ADC: Port doesn't exist with ADC.

E_ADC_PIN 

Error ADC: No ADC on pin.

E_IWDG_NOERROR 

Error IWDG: No error.

E_IWDG_PERIOD 

Error IWDG: Period too long.

E_FLASH_NOERROR 

Error FLASH: No error.

E_FLASH_PAGE 

Error FLASH: Page number out of bounds.

E_RTC_NOERROR 

Error RTC: No error.

E_RTC_PRELOAD 

Error RTC: Invalid period specified.

E_SPI_NOERROR 

Error SPI: No error.

E_SPI_PORT 

Error SPI: Port doesn't exist.

Definition at line 44 of file stm32f103cb_debug.h.

Function Documentation

void MCU_debugDisable ( void  )

Disables the debug feature.

This will set any previous function pointer for the output stream to NULL.

Returns
none

Definition at line 88 of file stm32f103cb_debug.c.

void MCU_debugEnable ( void(*)(uint8_t)  output_handle)

Enables the debug feature.

This sets the function pointer for the output stream utalized by MCU_printError().

This has to be called before any debug feature will work.

Parameters
output_handleFuntion pointer to the output stream.
Returns
none

Definition at line 82 of file stm32f103cb_debug.c.

uint8_t MCU_debugIsEnabled ( void  )

Checks if debug is enabled.

This funtion is used internally in modules before calling MCU_printError().

Returns
1 if debug is enable, 0 if debug is not enabled.

Definition at line 94 of file stm32f103cb_debug.c.

void MCU_printError ( mcu_error  error)

Print a given error number as a character stream.

This used the function pointer set with MCU_debugEnable to print the error definition as a stream of characters. The message matches the values set in mcu_error.

This is called automattically when an error has occured in the module. It can also be used manually from the return value of configuration functions (if available)

Parameters
errorThe error number to display.
Returns
none

Definition at line 105 of file stm32f103cb_debug.c.