PowerBlocks SDK
 
Loading...
Searching...
No Matches
system.c File Reference

Access parts of the base system. More...

#include "system.h"
#include "FreeRTOS.h"
#include "task.h"
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "utils/log.h"
#include "exceptions.h"
#include "gpio.h"

Functions

void main ()
 
void system_delay_int (uint64_t ticks)
 Sleeps for a certain number of ticks.
 
void * system_aligned_malloc (uint32_t bytes, uint32_t alignment)
 Allocate memory with alignment.
 
void system_aligned_free (void *ptr)
 Free allocated memory with alignment.
 
void system_initialize ()
 Initializes the system.
 
void system_get_boot_path (const char *device, char *buffer, size_t length)
 Looks in the argv command line for a specific boot path.
 

Detailed Description

Access parts of the base system.

Access parts of the base system. Like time and such.

Author
Samuel Fitzsimons (rainbain)
Date
2025 @license MIT (see LICENSE file)

Function Documentation

◆ system_aligned_free()

void system_aligned_free ( void * ptr)

Free allocated memory with alignment.

Free allocated memory with alignment.

◆ system_aligned_malloc()

void * system_aligned_malloc ( uint32_t bytes,
uint32_t alignment )

Allocate memory with alignment.

Allocate memory aligned to a certain number of bytes. A lot of hardware requires aligned memory. Usually 32 bytes.

Must be a power of 2.

Offsets the pointer by the alignment and stores the original unaligned pointer before the pointer returned.

◆ system_delay_int()

void system_delay_int ( uint64_t ticks)

Sleeps for a certain number of ticks.

Waits for a certain number of ticks to elapse.

No interrupts version.

Recommend using FreeRTOS vTaskDelay instead.

Parameters
ticksNumber of ticks to wait for

◆ system_get_boot_path()

void system_get_boot_path ( const char * device,
char * buffer,
size_t length )

Looks in the argv command line for a specific boot path.

When mounting a file system, this can be used to change the directory into the one the program was launched from if the file system is the one its running from.

For example passing a device of "sd" into device, it will fill buffer with the /apps/my_app/ path if the game was launched from the sd. If not it will return / into it.

Parameters
deviceBoot device
bufferOutputted path buffer
lengthLength of path buffer.

◆ system_initialize()

void system_initialize ( )

Initializes the system.

Initializes the system. Called from start.s, so this all happens before the C program starts running.