Skip to content

Commit

Permalink
Cleanup with some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlohr committed Sep 27, 2024
1 parent 5bb63c7 commit 0a85294
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions examples/gpio_and_adc/gpio_and_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,46 +35,52 @@ int main()
funGpioInitAll();
funAnalogInit();

funPinMode( PA1, GPIO_CFGLR_IN_ANALOG ); // Also A0
funPinMode( PA2, GPIO_CFGLR_IN_PUPD ); // Also A1
funPinMode( PC4, GPIO_CFGLR_OUT_50Mhz_OD ); // Also A2
funPinMode( PD2, GPIO_CFGLR_OUT_50Mhz_PP ); // Also A3
funPinMode( PA1, GPIO_CFGLR_IN_ANALOG ); // Corresponds to analog in A0
funPinMode( PA2, GPIO_CFGLR_IN_PUPD ); // Corresponds to analog in A1
funPinMode( PC4, GPIO_CFGLR_OUT_50Mhz_OD ); // Corresponds to analog in A2
funPinMode( PD2, GPIO_CFGLR_OUT_50Mhz_PP ); // Corresponds to analog in A3
funPinMode( PC1, GPIO_CFGLR_OUT_50Mhz_OD ); // PC1 = 5V tolerant (so no ADC)

while(1)
{
// Drive digitals high
funDigitalWrite( PA1, 1 );
funDigitalWrite( PA2, 1 );
funDigitalWrite( PC4, 1 );
funDigitalWrite( PD2, 1 );
funDigitalWrite( PC1, 1 ); // 5v tolerant, no ADC

Delay_Ms(1000);

printf( "1: %d %d %d %d\n",
funAnalogRead( ANALOG_0 ),
funAnalogRead( ANALOG_1 ),
funAnalogRead( ANALOG_2 ),
funAnalogRead( ANALOG_3 ) );

printf( " %d %d %d %d %d\n",
printf( " %d %d %d %d %d\n\n",
funDigitalRead( PA1 ),
funDigitalRead( PA2 ),
funDigitalRead( PC4 ),
funDigitalRead( PD2 ),
funDigitalRead( PC1 ) );

// Drive digitals low
funDigitalWrite( PA1, 0 );
funDigitalWrite( PA2, 0 );
funDigitalWrite( PC4, 0 );
funDigitalWrite( PD2, 0 );
funDigitalWrite( PC1, 0 ); // 5v tolerant, no ADC

Delay_Ms(1000);

printf( "0: %d %d %d %d\n",
funAnalogRead( ANALOG_0 ),
funAnalogRead( ANALOG_1 ),
funAnalogRead( ANALOG_2 ),
funAnalogRead( ANALOG_3 ) );

printf( " %d %d %d %d %d\n",
printf( " %d %d %d %d %d\n\n",
funDigitalRead( PA1 ),
funDigitalRead( PA2 ),
funDigitalRead( PC4 ),
Expand Down

0 comments on commit 0a85294

Please sign in to comment.