mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-02 13:24:12 +01:00
Fix syntax error on wiring_analog
This commit is contained in:
parent
f77fcec4e9
commit
1c9738e3db
@ -18,27 +18,28 @@
|
|||||||
|
|
||||||
//#include "wiring_private.h"
|
//#include "wiring_private.h"
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
#include "variant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
eAnalogReference analog_reference = AR_DEFAULT;
|
eAnalogReference analog_reference = AR_DEFAULT;
|
||||||
|
|
||||||
void analogReference( eAnalogReference ulMode )
|
void analogReference(eAnalogReference ulMode) {
|
||||||
{
|
|
||||||
analog_reference = ulMode;
|
analog_reference = ulMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t analogRead( uint32_t ulPin )
|
uint32_t analogRead(uint32_t ulPin) {
|
||||||
{
|
|
||||||
uint32_t ulValue = 0;
|
uint32_t ulValue = 0;
|
||||||
uint32_t ulChannel;
|
uint32_t ulChannel;
|
||||||
|
|
||||||
|
if (ulPin < A0)
|
||||||
|
ulPin += A0;
|
||||||
|
|
||||||
ulChannel = g_APinDescription[ulPin].ulAnalogChannel;
|
ulChannel = g_APinDescription[ulPin].ulAnalogChannel;
|
||||||
|
|
||||||
#if defined SAM3U4E
|
#if defined __SAM3U4E__
|
||||||
switch ( ulChannel )
|
switch ( ulChannel )
|
||||||
{
|
{
|
||||||
// Handling ADC 10 bits channels
|
// Handling ADC 10 bits channels
|
||||||
@ -57,7 +58,7 @@ uint32_t analogRead( uint32_t ulPin )
|
|||||||
adc_start( ADC );
|
adc_start( ADC );
|
||||||
|
|
||||||
// Wait for end of conversion
|
// Wait for end of conversion
|
||||||
while ( adc_get_status( ADC ) & (1<<ulChannel) ) == 0 ) ;
|
while ((adc_get_status(ADC) & (1<<ulChannel)) == 0);
|
||||||
|
|
||||||
// Read the value
|
// Read the value
|
||||||
ulValue=adc_get_value( ADC, ulChannel );
|
ulValue=adc_get_value( ADC, ulChannel );
|
||||||
@ -85,7 +86,7 @@ uint32_t analogRead( uint32_t ulPin )
|
|||||||
adc12_start( ADC12B );
|
adc12_start( ADC12B );
|
||||||
|
|
||||||
// Wait for end of conversion
|
// Wait for end of conversion
|
||||||
while ( adc12_get_status( ADC12B ) & (1<<(ulChannel-ADC8)) ) == 0 ) ;
|
while ((adc12_get_status(ADC12B) & (1<<(ulChannel-ADC8))) == 0);
|
||||||
|
|
||||||
// Read the value
|
// Read the value
|
||||||
ulValue=adc12_get_value( ADC12B, ulChannel-ADC8 );
|
ulValue=adc12_get_value( ADC12B, ulChannel-ADC8 );
|
||||||
@ -111,47 +112,25 @@ uint32_t analogRead( uint32_t ulPin )
|
|||||||
// hardware support. These are defined in the appropriate
|
// hardware support. These are defined in the appropriate
|
||||||
// pins_*.c file. For the rest of the pins, we default
|
// pins_*.c file. For the rest of the pins, we default
|
||||||
// to digital output.
|
// to digital output.
|
||||||
void analogWrite( uint32_t ulPin, uint32_t ulValue )
|
void analogWrite(uint32_t ulPin, uint32_t ulValue) {
|
||||||
{
|
|
||||||
pinMode(ulPin, OUTPUT);
|
pinMode(ulPin, OUTPUT);
|
||||||
|
|
||||||
if ( ulValue == 0 )
|
if (ulValue == 0) {
|
||||||
{
|
|
||||||
digitalWrite(ulPin, LOW);
|
digitalWrite(ulPin, LOW);
|
||||||
}
|
} else if (ulValue == 255) {
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( ulValue == 255 )
|
|
||||||
{
|
|
||||||
digitalWrite(ulPin, HIGH);
|
digitalWrite(ulPin, HIGH);
|
||||||
}
|
} else if ((g_APinDescription[ulPin].ulPinAttribute && PIN_ATTR_PWM)
|
||||||
else
|
== PIN_ATTR_PWM) {
|
||||||
{
|
|
||||||
if ( (g_APinDescription[ulPin].ulPinAttribute && PIN_ATTR_PWM) == PIN_ATTR_PWM )
|
|
||||||
{
|
|
||||||
// Setup PWM for this pin
|
// Setup PWM for this pin
|
||||||
}
|
} else if ((g_APinDescription[ulPin].ulPinAttribute && PIN_ATTR_TIMER)
|
||||||
else
|
== PIN_ATTR_TIMER) {
|
||||||
{
|
|
||||||
if ( (g_APinDescription[ulPin].ulPinAttribute && PIN_ATTR_TIMER) == PIN_ATTR_TIMER )
|
|
||||||
{
|
|
||||||
// Setup Timer for this pin
|
// Setup Timer for this pin
|
||||||
}
|
} else if (ulValue < 128) {
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( ulValue < 128 )
|
|
||||||
{
|
|
||||||
digitalWrite(ulPin, LOW);
|
digitalWrite(ulPin, LOW);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
digitalWrite(ulPin, HIGH);
|
digitalWrite(ulPin, HIGH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user