muteki
Loading...
Searching...
No Matches
system.h File Reference

System management functions. More...

#include <muteki/common.h>

Go to the source code of this file.

Data Structures

struct  power_battery_status_t
 Current battery status. More...
 

Typedefs

typedef void(* timer1_callback_t) (void)
 Callback type for Timer1 interrupt.
 

Enumerations

enum  power_source_type_e { POWER_SOURCE_BATTERY = 1 , POWER_SOURCE_AC = 4 }
 Power status. More...
 

Functions

bool Buzzer (int frequency, short duration)
 Play a tone using the built in piezo speaker.
 
void SetTimer1IntHandler (timer1_callback_t callback, short interval)
 Set Timer1 interrupt handler.
 
timer1_callback_t GetTimer1IntHandler (short *interval)
 Get the Timer1 interrupt handler and custom interval.
 
void SysPowerOff (void)
 Power off the system immediately.
 
int GetBatteryType (void)
 Get the system power source type.
 
char * _GetSystemDirectory (char *buffer, size_t size)
 Get the DOS 8.3 path to the system configuration directory on user data partition.
 
short GetBatteryValue (short sbz, power_battery_status_t *output)
 Read the battery voltage and level.
 

Detailed Description

System management functions.

Enumeration Type Documentation

◆ power_source_type_e

Power status.

Enumerator
POWER_SOURCE_BATTERY 

System on battery power.

On systems without a charging circuit this will always be returned.

POWER_SOURCE_AC 

System on AC power.

Function Documentation

◆ _GetSystemDirectory()

char * _GetSystemDirectory ( char *  buffer,
size_t  size 
)
extern

Get the DOS 8.3 path to the system configuration directory on user data partition.

This function will also ensure that the path exists before returning it. Although if the function fails, no directory will be created.

Syscall Number
0x1010e
Parameters
bufferThe buffer to hold the path.
sizeThe size of the buffer.
Returns
The buffer that now contains the path, or NULL if the function fails.

◆ Buzzer()

bool Buzzer ( int  frequency,
short  duration 
)
extern

Play a tone using the built in piezo speaker.

This will block the execution.

Syscall Number
0x1002c
Parameters
frequencyFrequency of the tone in Hz.
durationDuration of the tone in milliseconds.
Return values
trueThe operation was completed successfully.

◆ GetBatteryType()

int GetBatteryType ( void  )
extern

Get the system power source type.

Syscall Number
0x10035

Parameters
None.

Returns
The system power source type.
See also
power_source_type_e

◆ GetBatteryValue()

short GetBatteryValue ( short  sbz,
power_battery_status_t output 
)
extern

Read the battery voltage and level.

Requires -lkrnllib when dynamically linking with the shims.

Warning
On some versions of Besta RTOS, the return value may be undefined if the struct that output points to is not zero filled.
Syscall Number
0x2001a
Parameters
sbzUnknown. Should be set to 0.
outputPointer to a battery status info struct that will contain the returned values.
Return values
0The operation was completed successfully.

◆ GetTimer1IntHandler()

timer1_callback_t GetTimer1IntHandler ( short *  interval)
extern

Get the Timer1 interrupt handler and custom interval.

Syscall Number
0x10030
Parameters
[out]intervalA pointer to a variable that will hold the timer interval. Must not be NULL.
Returns
The callback function previously registered with SetTimer1IntHandler().

◆ SetTimer1IntHandler()

void SetTimer1IntHandler ( timer1_callback_t  callback,
short  interval 
)
extern

Set Timer1 interrupt handler.

The callback function passed to this will be called once every time the timer fires. The exact interval can be manually specified.

Note
On all Arm-based machines I tested this is always emulated using a thread instead of using real hardware timers. For TLCS-900-based machines this is likely different and it's unknown whether the callback will be called in a way that's safe to the rest of the OS (e.g. calling the callback directly in timer ISR could break the OS).
Syscall Number
0x1002e
Parameters
callbackThe callback function called when timer fires, or NULL to unset a previously set callback.
intervalAn interval value in 10 milliseconds increments (1 means 10ms, 2 means 20, etc.), or defaulting to 1 when set to 0.

Parameters
None.

◆ SysPowerOff()

void SysPowerOff ( void  )
extern

Power off the system immediately.

Syscall Number
0x10032

Parameters
None.

Returns
None.