Functions | |
int | System_SetActive (int state) |
Sets whether the System subsystem is active. | |
int | System_GetActive () |
Returns the active state of the subsystem. | |
int | System_GetFreeMemory (void) |
Returns the free size of the heap. | |
int | System_GetSerialNumber (void) |
Gets the board's Serial Number. | |
int | System_SetSerialNumber (int serial) |
Sets the Serial Number. | |
int | System_SetSamba (int sure) |
Returns the board to SAM-BA mode. | |
int | System_SetName (char *name) |
Gives the board a name. | |
char * | System_GetName () |
Read the board's name. | |
int | System_SetReset (int sure) |
Reset the board. |
int System_GetActive | ( | void | ) |
Returns the active state of the subsystem.
if(System_GetActive()) { // System is active } else { // System is inactive }
int System_GetFreeMemory | ( | void | ) |
Returns the free size of the heap.
The heap size is set in config.h in the constant CONTROLLER_HEAPSIZE. Any calls to Malloc will take their memory from the heap. This allows you to check how much heap is remaining.
// see how much memory is available int freemem = System_GetFreeMemory();
char* System_GetName | ( | void | ) |
Read the board's name.
char* board_name = System_GetName();
int System_GetSerialNumber | ( | void | ) |
Gets the board's Serial Number.
Each board has a serial number, although it's not necessarily unique as you can reset it as you please.
The serial number is used to determine the Ethernet MAC address, so boards on the same network need to have unique serial numbers.
// get this board's serial number int sernum = System_GetSerialNumber();
int System_SetActive | ( | int | state | ) |
Sets whether the System subsystem is active.
state | An integer specifying the state system |
// enable the System subsystem System_SetActive(1);
int System_SetName | ( | char * | name | ) |
Gives the board a name.
The name must be alpha-numeric - only letters and numbers. It can help you determine one board from another when there are more than one connected to your system.
name | A string specifying the board's name |
// give the board a special name System_SetName("my very special controller");
int System_SetReset | ( | int | sure | ) |
Reset the board.
Will reboot the board if the parameter sure is true.
sure | confirms the request is true. |
// reboot System_SetReset(1);
int System_SetSamba | ( | int | sure | ) |
Returns the board to SAM-BA mode.
When a board is in SAM-BA mode, it is ready to have new firmware uploaded to it. Upon successful completion, the board will be reset and begin running SAM-BA. This function does not clear the GPNVM2 bit, so if you unplug/replug you'll be running your old code again.
sure | Confirm you're sure you want to do this. |
// prepare to be uploaded System_SetSamba(1);
int System_SetSerialNumber | ( | int | serial | ) |
Sets the Serial Number.
Note that this can be changed by the user at any time, but that it is used in the Network subsystem to form the last two bytes of the network MAC address, so ideally units on the same network should have unique serial numbers.
// set the serial number to 12345 System_SetSerialNumber(12345);