68 lines
2.2 KiB
Plaintext
68 lines
2.2 KiB
Plaintext
|
|
% let Common = system.getScript("/driverlib/Common.js");
|
||
|
|
% var module = system.modules['/driverlib/gpio.js'];
|
||
|
|
//*****************************************************************************
|
||
|
|
//
|
||
|
|
// GPIO Configurations
|
||
|
|
//
|
||
|
|
//*****************************************************************************
|
||
|
|
void `module.peripheralName`_init(){
|
||
|
|
% for(var i = 0; i < module.$instances.length; i++)
|
||
|
|
% {
|
||
|
|
% var instance = module.$instances[i];
|
||
|
|
`instance.$name`_init();
|
||
|
|
% }
|
||
|
|
}
|
||
|
|
|
||
|
|
%if (module != null)
|
||
|
|
%{
|
||
|
|
% for(var i = 0; i < module.$instances.length; i++) {
|
||
|
|
% var instance = module.$instances[i];
|
||
|
|
void `instance.$name`_init(){
|
||
|
|
% if (instance.analogMode == "GPIO_ANALOG_ENABLED"){
|
||
|
|
GPIO_setAnalogMode(`instance.$name`, `instance.analogMode`);
|
||
|
|
%} else {
|
||
|
|
% if (instance.writeInitialValue){
|
||
|
|
GPIO_writePin(`instance.$name`, `instance.initialValue`);
|
||
|
|
% }
|
||
|
|
%if(instance.padConfig == "STD")
|
||
|
|
%{
|
||
|
|
GPIO_setPadConfig(`instance.$name`, GPIO_PIN_TYPE_`instance.padConfig`);
|
||
|
|
%}
|
||
|
|
%else if(instance.padConfig == "PULLUP")
|
||
|
|
%{
|
||
|
|
GPIO_setPadConfig(`instance.$name`, GPIO_PIN_TYPE_STD | GPIO_PIN_TYPE_PULLUP);
|
||
|
|
%}
|
||
|
|
%else if(instance.padConfig == "INVERT")
|
||
|
|
%{
|
||
|
|
GPIO_setPadConfig(`instance.$name`, GPIO_PIN_TYPE_STD | GPIO_PIN_TYPE_INVERT);
|
||
|
|
%}
|
||
|
|
%else if(instance.padConfig == "PULLUP_INVERT")
|
||
|
|
%{
|
||
|
|
GPIO_setPadConfig(`instance.$name`, GPIO_PIN_TYPE_STD | GPIO_PIN_TYPE_PULLUP | GPIO_PIN_TYPE_INVERT);
|
||
|
|
%}
|
||
|
|
%else if(instance.padConfig == "OD")
|
||
|
|
%{
|
||
|
|
GPIO_setPadConfig(`instance.$name`, GPIO_PIN_TYPE_`instance.padConfig`);
|
||
|
|
%}
|
||
|
|
%else if(instance.padConfig == "OD_PULLUP")
|
||
|
|
%{
|
||
|
|
GPIO_setPadConfig(`instance.$name`, GPIO_PIN_TYPE_OD | GPIO_PIN_TYPE_PULLUP);
|
||
|
|
%}
|
||
|
|
%else if(instance.padConfig == "OD_INVERT")
|
||
|
|
%{
|
||
|
|
GPIO_setPadConfig(`instance.$name`, GPIO_PIN_TYPE_OD | GPIO_PIN_TYPE_INVERT);
|
||
|
|
%}
|
||
|
|
%else if(instance.padConfig == "OD_PULLUP_INVERT")
|
||
|
|
%{
|
||
|
|
GPIO_setPadConfig(`instance.$name`, GPIO_PIN_TYPE_OD | GPIO_PIN_TYPE_PULLUP | GPIO_PIN_TYPE_INVERT);
|
||
|
|
%}
|
||
|
|
GPIO_setQualificationMode(`instance.$name`, `instance.qualMode`);
|
||
|
|
GPIO_setDirectionMode(`instance.$name`, `instance.direction`);
|
||
|
|
% if (!["F28002x", "F280013x", "F280015x"].includes(Common.getDeviceName())) {
|
||
|
|
GPIO_setControllerCore(`instance.$name`, `instance.controllerCore`);
|
||
|
|
% }
|
||
|
|
%}
|
||
|
|
}
|
||
|
|
%}
|
||
|
|
%}
|