TMS320F28335 Library  1.0
Documentation
general_output.h File Reference

Header file for General Output module. More...

Go to the source code of this file.

Functions

int16 init_generalOutputPin (Uint16)
 Configuration of GPIO as general output pin. More...
 
int16 generalOutputPin_setPinHigh (Uint16)
 Set output pin high. More...
 
int16 generalOutputPin_setPinLow (Uint16)
 Set output pin low. More...
 

Detailed Description

Header file for General Output module.

Definition in file general_output.h.

Function Documentation

◆ generalOutputPin_setPinHigh()

int16 generalOutputPin_setPinHigh ( Uint16  pin)

Set output pin high.

Parameters
[in]1) GPIO pin as Uint16 --> valid value: 0-87 (see global_defines.h)
Returns
Result of operations as int16
--> 0 = operation successful
--> -1 = invalid value of GPIO pin

Definition at line 63 of file general_output.c.

63  {
64  EALLOW; // Allow register-access
65  switch(pin){
66  case 0 ... 31: TMC_BASE_PIO->DATA[0].SET |= ((Uint32)0x1 << pin); // Set Output to 1
67  break;
68  case 32 ... 63: pin -= 32;
69  TMC_BASE_PIO->DATA[1].SET |= ((Uint32)0x1 << pin); // Set Output to 1
70  break;
71  case 64 ... 87: pin -= 64;
72  TMC_BASE_PIO->DATA[2].SET |= ((Uint32)0x1 << pin); // Set Output to 1
73  break;
74  default: EDIS;
75  return -1; // Invalid input value
76  }
77  EDIS; // Protect register
78  return 0;
79 }

◆ generalOutputPin_setPinLow()

int16 generalOutputPin_setPinLow ( Uint16  pin)

Set output pin low.

Parameters
[in]1) GPIO pin as Uint16 --> valid value: 0-87 (see global_defines.h)
Returns
Result of operations as int16
--> 0 = operation successful
--> -1 = invalid value of GPIO pin

Definition at line 88 of file general_output.c.

88  {
89  EALLOW; // Allow register-access
90  switch(pin){
91  case 0 ... 31: TMC_BASE_PIO->DATA[0].CLEAR |= ((Uint32)0x1 << pin); // Set Output to 0
92  break;
93  case 32 ... 63: pin -= 32;
94  TMC_BASE_PIO->DATA[1].CLEAR |= ((Uint32)0x1 << pin); // Set Output to 0
95  break;
96  case 64 ... 87: pin -= 64;
97  TMC_BASE_PIO->DATA[2].CLEAR |= ((Uint32)0x1 << pin); // Set Output to 0
98  break;
99  default: EDIS;
100  return -1; // Invalid input value
101  }
102  EDIS; // Protect register
103  return 0;
104 }

◆ init_generalOutputPin()

int16 init_generalOutputPin ( Uint16  pin)

Configuration of GPIO as general output pin.

Parameters
[in]1) GPIO pin as Uint16 --> valid value: 0-87 (see global_defines.h)
Returns
Result of operations as int16
--> 0 = operation successful
--> -1 = invalid value of GPIO pin

Definition at line 15 of file general_output.c.

15  {
16  EALLOW; // Allow register-access
17  switch(pin){
18  case 0 ... 31: TMC_BASE_PIO->CTL[0].PUD |= ((Uint32)0x1 << pin); // Disable the internal pullup on the specified pin.
19  if(pin <=15){
20  TMC_BASE_PIO->CTL[0].MUX1 &= ~((Uint32)0x3 << (pin*2)); // General purpose input/output
21  }
22  else{
23  TMC_BASE_PIO->CTL[0].MUX2 &= ~((Uint32)0x3 << ((pin-16)*2)); // General purpose input/output
24  }
25  TMC_BASE_PIO->CTL[0].DIR |= ((Uint32)0x1 << pin); // Configures the GPIO pin as an output
26  break;
27  case 32 ... 63: pin -= 32;
28  TMC_BASE_PIO->CTL[1].PUD |= ((Uint32)0x1 << pin); // Disable the internal pullup on the specified pin.
29  if(pin <=15){
30  TMC_BASE_PIO->CTL[1].MUX1 &= ~((Uint32)0x3 << (pin*2)); // General purpose input/output
31  }
32  else{
33  TMC_BASE_PIO->CTL[1].MUX2 &= ~((Uint32)0x3 << ((pin-16)*2)); // General purpose input/output
34  }
35  TMC_BASE_PIO->CTL[1].DIR |= ((Uint32)0x1 << pin); // Configures the GPIO pin as an output
36  break;
37  case 64 ... 87: pin -= 64;
38  TMC_BASE_PIO->CTL[2].PUD |= ((Uint32)0x1 << pin); // Disable the internal pullup on the specified pin.
39  if(pin <=15){
40  TMC_BASE_PIO->CTL[2].MUX1 &= ~((Uint32)0x3 << (pin*2)); // General purpose input/output
41  }
42  else{
43  TMC_BASE_PIO->CTL[2].MUX2 &= ~((Uint32)0x3 << ((pin-16)*2)); // General purpose input/output
44  }
45  TMC_BASE_PIO->CTL[2].DIR |= ((Uint32)0x1 << pin); // Configures the GPIO pin as an output
46  break;
47  default: EDIS;
48  return -1; // Invalid input value
49  }
50  EDIS; // Protect register
51  return 0;
52 
53 
54 }
Uint32
unsigned long Uint32
32 Bit Variable: 0 .. 4.294.967.295
Definition: global_defines.h:22