System information
This section describes the classes CMachineInfo and CKernelOptions, which provide information about the Raspberry Pi model, on which the application is running, and the runtime options, which can be defined in the file cmdline.txt on the SD card.
CMachineInfo
Normally there is exactly one instance of the class CMachineInfo in the system, which is created by the Circle system initialization code. If another instance is created, it acts as an alias for the first instance.
#include <circle/machineinfo.h>
-
class CMachineInfo
-
static CMachineInfo *CMachineInfo::Get(void)
Returns a pointer to the first instance of
CMachineInfo.
Model information
-
TMachineModel CMachineInfo::GetMachineModel(void) const
Returns the Raspberry Pi model, the application is running on. Possible values are:
MachineModelA
MachineModelBRelease1MB256
MachineModelBRelease2MB256
MachineModelBRelease2MB512
MachineModelAPlus
MachineModelBPlus
MachineModelZero
MachineModelZeroW
MachineModelZero2W
MachineModel2B
MachineModel3B
MachineModel3APlus
MachineModel3BPlus
MachineModelCM
MachineModelCM3
MachineModelCM3Plus
MachineModel4B
MachineModel400
MachineModelCM4
MachineModelCM4S
MachineModel5
MachineModel500
MachineModelCM5
MachineModelCM5Lite
MachineModelCM0
MachineModelUnknown
-
const char *CMachineInfo::GetMachineName(void) const
Returns the name of the Raspberry Pi model, the application is running on.
-
unsigned CMachineInfo::GetModelMajor(void) const
Returns the major version (1-4) of the Raspberry Pi model, the application is running on, or zero if it is unknown.
-
unsigned CMachineInfo::GetModelRevision(void) const
Returns the revision number (1-) of the Raspberry Pi model, the application is running on, or zero if it is unknown.
-
TSoCType CMachineInfo::GetSoCType(void) const
Returns the type of the SoC (System on a Chip), the application is running on. Possible values are:
SoCTypeBCM2835
SoCTypeBCM2836
SoCTypeBCM2837
SoCTypeBCM2711
SoCTypeBCM2712
SoCTypeUnknown
-
TSoCStepping CMachineInfo::GetSoCStepping(void) const
Returns the stepping of the SoC (System on a Chip), the application is running on. Possible values are:
SoCSteppingC1
SoCSteppingD0
SoCSteppingUnknown
-
unsigned CMachineInfo::GetRAMSize(void) const
Returns the size of the SDRAM in MBytes of the Raspberry Pi model, the application is running on, or zero if it is unknown.
-
const char *CMachineInfo::GetSoCName(void) const
Returns the name of the SoC (System on a Chip), the application is running on.
-
u32 CMachineInfo::GetRevisionRaw(void) const
Returns the raw revision code of the Raspberry Pi model, the application is running on.
Clocks and peripherals
-
unsigned CMachineInfo::GetActLEDInfo(void) const
Returns the information, about how the green Activity LED is connected to the system. The result has to be masked with
ACTLED_PIN_MASKto extract the GPIO pin number. If the result masked withACTLED_ACTIVE_LOWis not zero, the LED is on, when the value 0 is written to the GPIO pin. If the result masked withACTLED_VIRTUAL_PINis not zero, the LED is connected to a GPIO expander, which is controlled by the firmware.
-
unsigned CMachineInfo::GetClockRate(u32 nClockId) const
Returns the current frequency in Hz of the system clock, selected by
nClockId, which can have the following values:
CLOCK_ID_CORE
CLOCK_ID_ARM
CLOCK_ID_UART
CLOCK_ID_EMMC
CLOCK_ID_EMMC2
-
unsigned CMachineInfo::GetGPIOPin(TGPIOVirtualPin Pin) const
Returns the physical GPIO pin number of the PWM audio pins.
Pincan have the valuesGPIOPinAudioLeftorGPIOPinAudioRight.
-
unsigned CMachineInfo::GetGPIOClockSourceRate(unsigned nSourceId)
This method allows to enumerate the different clock sources for GPIO clocks. It returns the frequency in Hz of the GPIO clock source with the ID
nSourceId, which can be zero toGPIO_CLOCK_SOURCE_ID_MAX. The returned value isGPIO_CLOCK_SOURCE_UNUSED, if the clock source is unused.
-
unsigned CMachineInfo::GetDevice(TDeviceId DeviceId) const
Returns the device number of the default I2C master in the system.
DeviceIdhas to be set toDeviceI2CMaster.
-
boolean CMachineInfo::ArePWMChannelsSwapped(void) const
Returns
TRUE, if the left PWM audio channel is PWM1 (not PWM0).
DMA channels
-
unsigned CMachineInfo::AllocateDMAChannel(unsigned nChannel)
Allocates an available DMA channel from the platform DMA controller.
nChannelcan beDMA_CHANNEL_NORMAL(normal DMA engine requested),DMA_CHANNEL_LITE(lite (or normal) DMA engine requested),DMA_CHANNEL_EXTENDED(“large address” DMA4 engine requested, on Raspberry Pi 4 and 5 only) or an explicit channel number (0-15). Returns the allocated channel number orDMA_CHANNEL_NONEon failure.
-
void CMachineInfo::FreeDMAChannel(unsigned nChannel)
Release an allocated DMA channel.
nChannelis the channel number (0-15).
-
unsigned CMachineInfo::AllocateDMAChannelRP1(unsigned nChannel)
Allocates an available DMA channel from the RP1 southbridge of the Raspberry Pi 5.
nChannelcan beDMA_CHANNEL_RP1_NORMAL(normal (or fast) DMA channel requested) orDMA_CHANNEL_RP1_FAST(fast DMA channel requested) or an explicit channel number (0-7). Returns the allocated channel number orDMA_CHANNEL_NONEon failure.
Note
RP1 DMA channels 0 and 1 have the highest priority and a larger temporary storage and are therefore treated as “fast” channels.
-
void CMachineInfo::FreeDMAChannelRP1(unsigned nChannel)
Release an allocated DMA channel from the RP1 southbridge.
nChannelis the channel number (0-7).
CKernelOptions
The class CKernelOptions provides the values of runtime options, which can be defined in the file cmdline.txt on the SD card. The supported options are listed in doc/cmdline.txt. There is exactly one or no instance of this class in the system. Only relatively simple programs can work without an instance of CKernelOptions.
#include <circle/koptions.h>
-
class CKernelOptions
-
static CKernelOptions *CKernelOptions::Get(void)
Returns a pointer to the only instance of
CKernelOptions.
-
unsigned CKernelOptions::GetWidth(void) const
-
unsigned CKernelOptions::GetHeight(void) const
Return the requested width and height of the screen, or zero if not specified. These values will normally handed over to the constructor for the class
CScreenDevice.
-
const char *CKernelOptions::GetLogDevice(void) const
-
unsigned CKernelOptions::GetLogLevel(void) const
Return the name of the target device for the system log (default
tty1) and the log level (defaultLogDebug), to be handed over to the constructor of the classCLogger.
-
const char *CKernelOptions::GetKeyMap(void) const
Returns the country code of the requested keyboard map (option
keymap=). The default can be set with the system optionDEFAULT_KEYMAP.
-
unsigned CKernelOptions::GetUSBPowerDelay(void) const
Returns the requested USB power-on delay in milliseconds, or zero to use the default value.
-
boolean CKernelOptions::GetUSBFullSpeed(void) const
Returns
TRUE, if the optionusbspeed=fullis given in cmdline.txt.
-
const char *CKernelOptions::GetSoundDevice(void) const
Returns the configured sound device (option
sounddev=). Defaults to an empty string.
-
unsigned CKernelOptions::GetSoundOption(void) const
Returns the value configured with the option
soundopt=in cmdline.txt (0-2, default 0).
-
TCPUSpeed CKernelOptions::GetCPUSpeed(void) const
Returns
CPUSpeedMaximum, if the optionfast=trueis given in cmdline.txt, orCPUSpeedLowotherwise.
-
unsigned CKernelOptions::GetSoCMaxTemp(void) const
Returns the enforced maximal temperature of the SoC (option
socmaxtemp=) in degrees Celsius (default 60).
-
const unsigned *CKernelOptions::GetTouchScreen(void) const
Returns the calibration parameters for the touchscreen. The returned pointer refers to an array with four elements (min-x, max-x, min-y, max-y). It is
nullptr, if the optiontouchscreen=is not set.
-
unsigned CKernelOptions::GetBacklight(void) const
Returns the backlight level to be set on the Raspberry Pi Official 7” Touchscreen, or 0, if the option is not defined.
-
const char *CKernelOptions::GetAppOptionString(const char *pOption, const char *pDefault = nullptr) const
Returns the value of the application-defined option
pOptionas a pointer to a C-string, orpDefaultif the option is not found in the command line.
-
unsigned CKernelOptions::GetAppOptionDecimal(const char *pOption, unsigned nDefault = -1) const
Returns the value of the application-defined option
pOptionas a number, ornDefaultif the option is not found in the command line.
-
int CKernelOptions::GetAppOptionSignedDecimal(const char *pOption, int nDefault = -1) const
Returns the value of the application-defined option
pOptionas a number, ornDefaultif the option is not found in the command line.