BEEP-8 SDK 1.0.0
Loading...
Searching...
No Matches
sys.h File Reference

System utility functions for the BEEP-8 system. More...

#include <b8/type.h>

Go to the source code of this file.

Macros

#define B8_SYS_ASSERT(expr_, comment_)
 Assert macro for system checks.
 

Functions

void b8SysHalt (void)
 Halt the system.
 
void b8SysReset (void)
 Reset the system.
 
void b8SysPuts (const char *str)
 Output a string.
 
void b8SysPutHex (u32 data)
 Output a hexadecimal number.
 
void b8SysPutNum (s32 data)
 Output a decimal number.
 
void b8SysPutCR (void)
 Output a carriage return.
 
u32 b8SysGetCpuClock (void)
 Get the CPU clock speed.
 
int b8SysSetupIrqWait (u32 irq)
 Set up an IRQ wait handler.
 
int b8SysIrqWait (u32 irq)
 Wait for an IRQ.
 

Detailed Description

System utility functions for the BEEP-8 system.

This file provides various system utility functions and macros for the BEEP-8 system. It includes functions for system halt, reset, outputting strings and numbers, and handling interrupts.

Functions provided:

  • b8SysHalt: Halt the system
  • b8SysReset: Reset the system
  • b8SysPuts: Output a string
  • b8SysPutHex: Output a hexadecimal number
  • b8SysPutNum: Output a decimal number
  • b8SysPutCR: Output a carriage return
  • b8SysGetCpuClock: Get the CPU clock speed
  • b8SysSetupIrqWait: Set up an IRQ wait handler
  • b8SysIrqWait: Wait for an IRQ

These functions are intended for use under special conditions, such as in the bootloader, operating system, or for handling exceptional halts. They should not be used in regular application code.

Macro Definition Documentation

◆ B8_SYS_ASSERT

#define B8_SYS_ASSERT ( expr_,
comment_ )
Value:
do { \
if (!(expr_)) { \
b8SysPuts( "[B8_SYS_ASSERT]" );\
b8SysPuts( comment_ );\
b8SysPutCR();\
asm("hlt");\
} \
} while(0)

Assert macro for system checks.

This macro checks the given expression and if it evaluates to false, it outputs an assertion message and halts the system.

Parameters
expr_The expression to evaluate.
comment_A custom comment to include in the assertion message.

Function Documentation

◆ b8SysGetCpuClock()

u32 b8SysGetCpuClock ( void )
extern

Get the CPU clock speed.

This function returns the current CPU clock speed.

Returns
The CPU clock speed.

◆ b8SysHalt()

void b8SysHalt ( void )
extern

Halt the system.

This function outputs a halt message and then halts the system.

◆ b8SysIrqWait()

int b8SysIrqWait ( u32 irq)
extern

Wait for an IRQ.

This function waits for the specified IRQ to occur.

Parameters
irqThe IRQ number to wait for.
Returns
0 on success; an error code on failure.

◆ b8SysPutCR()

void b8SysPutCR ( void )
extern

Output a carriage return.

This function outputs a newline character to the system console.

◆ b8SysPutHex()

void b8SysPutHex ( u32 data)
extern

Output a hexadecimal number.

This function outputs the given 32-bit hexadecimal number to the system console.

Parameters
dataThe hexadecimal number to output.

◆ b8SysPutNum()

void b8SysPutNum ( s32 data)
extern

Output a decimal number.

This function outputs the given 32-bit decimal number to the system console.

Parameters
dataThe decimal number to output.

◆ b8SysPuts()

void b8SysPuts ( const char * str)
extern

Output a string.

This function outputs the given string to the system console.

Parameters
strThe string to output.

◆ b8SysReset()

void b8SysReset ( void )
extern

Reset the system.

This function resets the system by calling the b8rst function.

◆ b8SysSetupIrqWait()

int b8SysSetupIrqWait ( u32 irq)
extern

Set up an IRQ wait handler.

This function sets up an IRQ wait handler for the specified IRQ.

Parameters
irqThe IRQ number to set up.
Returns
0 on success; an error code on failure.