2.1 Initialization and Exit Function Calls

When using SAMD51 driver, you must always place two specific function calls in your program. Any application using the SAMD51 API should always start with call to DSCSAM_InitBoard and end with calls to DSCSAM_FreeBoard. These calls are important in initializing and freeing resources used by the driver. Here is an example of the framework for an application using the driver.

#include "Sam.h" 

ERRPARAMS errparams; // structure for returning error code and error string

int main ( void )
{
	BYTE Board_type;
	int return_value = 0; 
	
	return_value = DSCSAM_InitBoard(&Board_type);
	
	if(return_value != DE_NONE)
	{
		DSCGetLastError ( &errparams );
		printf ( "DSCSAM_InitBoard error: %s %s\n", DSCGetErrorString ( errparams.ErrCode ), errparams.errstring );
		return 0;
	}

	if(Board_type == 0)
		printf ( "Board Type : ZIGGY\n" );
	else if(Board_type == 3)
		printf ( "Board Type : STEVIE\n" );
	else if(Board_type == 5)
		printf ( "Board Type : ELTON\n" );
	else if(Board_type == 7)
		printf ( "Board Type : JETHRO\n" );
		
	/* Application code goes here */
	
	DSCSAM_FreeBoard();
	
	return 0;

} // end main()

Calls to any SAMD51 API function are always of the form, DSCSAM_[...], where [...] is a specific function (i.e., ADSample as in DSCSAM_ADSample).

Last updated