@@ -0,0 +1,17 | |||
|
1 | /* | |
|
No newline at end of file | ||
|
2 | * Mensajes.h | |
|
No newline at end of file | ||
|
3 | * | |
|
No newline at end of file | ||
|
4 | * Created on: Nov 12, 2009 | |
|
No newline at end of file | ||
|
5 | * Author: redes | |
|
No newline at end of file | ||
|
6 | */ | |
|
No newline at end of file | ||
|
7 | ||
|
No newline at end of file | ||
|
8 | #ifndef MENSAJES_H_ | |
|
No newline at end of file | ||
|
9 | #define MENSAJES_H_ | |
|
No newline at end of file | ||
|
10 | ||
|
No newline at end of file | ||
|
11 | void LOG_SERVIDOR(char *mensaje); | |
|
No newline at end of file | ||
|
12 | void LOG_CLIENTE(char *mensaje); | |
|
No newline at end of file | ||
|
13 | void ERROR_FATAL(char *mensaje); | |
|
No newline at end of file | ||
|
14 | void ERROR(char *mensaje); | |
|
No newline at end of file | ||
|
15 | ||
|
No newline at end of file | ||
|
16 | ||
|
No newline at end of file | ||
|
17 | #endif /* MENSAJES_H_ */ No newline at end of file |
@@ -0,0 +1,124 | |||
|
1 | // ***************************************************************************** | |
|
No newline at end of file | ||
|
2 | // SOFTWARE API DEFINITION FOR Analog to Digital Convertor | |
|
No newline at end of file | ||
|
3 | // ***************************************************************************** | |
|
No newline at end of file | ||
|
4 | ||
|
No newline at end of file | ||
|
5 | #ifndef ADC_AT91_H | |
|
No newline at end of file | ||
|
6 | #define ADC_AT91_H | |
|
No newline at end of file | ||
|
7 | ||
|
No newline at end of file | ||
|
8 | #define MAP_SIZE 4096Ul | |
|
No newline at end of file | ||
|
9 | #define MAP_MASK (MAP_SIZE - 1) | |
|
No newline at end of file | ||
|
10 | ||
|
No newline at end of file | ||
|
11 | #define ADC_BASE 0xFFFE0000 | |
|
No newline at end of file | ||
|
12 | ||
|
No newline at end of file | ||
|
13 | // -------- ADC_CR : (ADC Offset: 0x0) ADC Control Register -------- | |
|
No newline at end of file | ||
|
14 | #define ADC_SWRST ((unsigned int) 0x1 << 0) // (ADC) Software Reset | |
|
No newline at end of file | ||
|
15 | #define ADC_START ((unsigned int) 0x1 << 1) // (ADC) Start Conversion | |
|
No newline at end of file | ||
|
16 | // -------- ADC_MR : (ADC Offset: 0x4) ADC Mode Register -------- | |
|
No newline at end of file | ||
|
17 | #define ADC_TRGEN_DIS ((unsigned int) 0x0) // (ADC) Hradware triggers are disabled. Starting a conversion is only possible by software | |
|
No newline at end of file | ||
|
18 | #define ADC_TRGEN_EN ((unsigned int) 0x1) // (ADC) Hardware trigger selected by TRGSEL field is enabled. | |
|
No newline at end of file | ||
|
19 | ||
|
No newline at end of file | ||
|
20 | #define ADC_TRGSEL_TIOA0 ((unsigned int) 0x0 << 1) // (ADC) Selected TRGSEL = TIAO0 | |
|
No newline at end of file | ||
|
21 | #define ADC_TRGSEL_TIOA1 ((unsigned int) 0x1 << 1) // (ADC) Selected TRGSEL = TIAO1 | |
|
No newline at end of file | ||
|
22 | #define ADC_TRGSEL_TIOA2 ((unsigned int) 0x2 << 1) // (ADC) Selected TRGSEL = TIAO2 | |
|
No newline at end of file | ||
|
23 | #define ADC_TRGSEL_TIOA3 ((unsigned int) 0x3 << 1) // (ADC) Selected TRGSEL = TIAO3 | |
|
No newline at end of file | ||
|
24 | #define ADC_TRGSEL_TIOA4 ((unsigned int) 0x4 << 1) // (ADC) Selected TRGSEL = TIAO4 | |
|
No newline at end of file | ||
|
25 | #define ADC_TRGSEL_TIOA5 ((unsigned int) 0x5 << 1) // (ADC) Selected TRGSEL = TIAO5 | |
|
No newline at end of file | ||
|
26 | #define ADC_TRGSEL_EXT ((unsigned int) 0x6 << 1) // (ADC) Selected TRGSEL = External Trigger | |
|
No newline at end of file | ||
|
27 | ||
|
No newline at end of file | ||
|
28 | #define ADC_RES_10BIT ((unsigned int) 0x0 << 4) // (ADC) 10-bit resolution | |
|
No newline at end of file | ||
|
29 | #define ADC_RES_8BIT ((unsigned int) 0x1 << 4) // (ADC) 8-bit resolution | |
|
No newline at end of file | ||
|
30 | ||
|
No newline at end of file | ||
|
31 | #define ADC_SLEEP_NORMAL_MODE ((unsigned int) 0x0 << 5) // (ADC) Normal Mode | |
|
No newline at end of file | ||
|
32 | #define ADC_SLEEP_MODE ((unsigned int) 0x1 << 5) // (ADC) Sleep Mode | |
|
No newline at end of file | ||
|
33 | ||
|
No newline at end of file | ||
|
34 | #define ADC_PRESCAL ((unsigned int) 0x31 << 2) // (ADC) Prescaler rate selection | |
|
No newline at end of file | ||
|
35 | #define ADC_STARTUP ((unsigned int) 0x00 << 2) // (ADC) Startup Time | |
|
No newline at end of file | ||
|
36 | #define ADC_SHTIM ((unsigned int) 0x01 << 9) // (ADC) Sample & Hold Time | |
|
No newline at end of file | ||
|
37 | ||
|
No newline at end of file | ||
|
38 | // -------- ADC_CHER : (ADC Offset: 0x10) ADC Channel Enable Register -------- | |
|
No newline at end of file | ||
|
39 | #define ADC_CH0 ((unsigned int) 0x1 << 0) // (ADC) Channel 0 | |
|
No newline at end of file | ||
|
40 | #define ADC_CH1 ((unsigned int) 0x1 << 1) // (ADC) Channel 1 | |
|
No newline at end of file | ||
|
41 | #define ADC_CH2 ((unsigned int) 0x1 << 2) // (ADC) Channel 2 | |
|
No newline at end of file | ||
|
42 | #define ADC_CH3 ((unsigned int) 0x1 << 3) // (ADC) Channel 3 | |
|
No newline at end of file | ||
|
43 | ||
|
No newline at end of file | ||
|
44 | /*Anadido por DCordova*/ | |
|
No newline at end of file | ||
|
45 | // -------- ADC_CHSR : (ADC Offset: 0x10) ADC Channel Status Register -------- | |
|
No newline at end of file | ||
|
46 | #define ADC_CHSR0 ((unsigned int) 0x1 << 0) // (ADC) Channel 0 | |
|
No newline at end of file | ||
|
47 | #define ADC_CHSR1 ((unsigned int) 0x1 << 1) // (ADC) Channel 1 | |
|
No newline at end of file | ||
|
48 | #define ADC_CHSR2 ((unsigned int) 0x1 << 2) // (ADC) Channel 2 | |
|
No newline at end of file | ||
|
49 | #define ADC_CHSR3 ((unsigned int) 0x1 << 3) // (ADC) Channel 3 | |
|
No newline at end of file | ||
|
50 | /*Anadido por DCordova*/ | |
|
No newline at end of file | ||
|
51 | ||
|
No newline at end of file | ||
|
52 | ||
|
No newline at end of file | ||
|
53 | // -------- ADC_CHDR : (ADC Offset: 0x14) ADC Channel Disable Register -------- | |
|
No newline at end of file | ||
|
54 | // -------- ADC_CHSR : (ADC Offset: 0x18) ADC Channel Status Register -------- | |
|
No newline at end of file | ||
|
55 | // -------- ADC_SR : (ADC Offset: 0x1c) ADC Status Register -------- | |
|
No newline at end of file | ||
|
56 | ||
|
No newline at end of file | ||
|
57 | #define MASK_EOC0 ((unsigned int) 0x1 << 0) // (ADC) End of Conversion | |
|
No newline at end of file | ||
|
58 | #define MASK_EOC1 ((unsigned int) 0x1 << 1) // (ADC) End of Conversion | |
|
No newline at end of file | ||
|
59 | #define MASK_EOC2 ((unsigned int) 0x1 << 2) // (ADC) End of Conversion | |
|
No newline at end of file | ||
|
60 | #define MASK_EOC3 ((unsigned int) 0x1 << 3) // (ADC) End of Conversion | |
|
No newline at end of file | ||
|
61 | #define MASK_OVRE0 ((unsigned int) 0x1 << 8) // (ADC) Overrun Error | |
|
No newline at end of file | ||
|
62 | #define MASK_OVRE1 ((unsigned int) 0x1 << 9) // (ADC) Overrun Error | |
|
No newline at end of file | ||
|
63 | #define MASK_OVRE2 ((unsigned int) 0x1 << 10) // (ADC) Overrun Error | |
|
No newline at end of file | ||
|
64 | #define MASK_OVRE3 ((unsigned int) 0x1 << 11) // (ADC) Overrun Error | |
|
No newline at end of file | ||
|
65 | #define MASK_DRDY ((unsigned int) 0x1 << 16) // (ADC) Data Ready | |
|
No newline at end of file | ||
|
66 | #define MASK_GOVRE ((unsigned int) 0x1 << 17) // (ADC) General Overrun | |
|
No newline at end of file | ||
|
67 | ||
|
No newline at end of file | ||
|
68 | // -------- ADC_LCDR : (ADC Offset: 0x20) ADC Last Converted Data Register -------- | |
|
No newline at end of file | ||
|
69 | #define ADC_LDATA ((unsigned int) 0x3FF << 0) // (ADC) Last Data Converted | |
|
No newline at end of file | ||
|
70 | #define ADC_DATA ((unsigned int) 0x3FF << 0) // (ADC) Converted Data | |
|
No newline at end of file | ||
|
71 | #define ADC_DISABLE_INTERRUP ((unsigned int) 0x0F0F0F << 0) //(ADC) Disable all interrup | |
|
No newline at end of file | ||
|
72 | ||
|
No newline at end of file | ||
|
73 | typedef volatile unsigned int AT91_REG2;// Hardware register definition | |
|
No newline at end of file | ||
|
74 | ||
|
No newline at end of file | ||
|
75 | typedef struct _AT91S_ADC { | |
|
No newline at end of file | ||
|
76 | AT91_REG2 ADC_CR; // ADC Control Register | |
|
No newline at end of file | ||
|
77 | AT91_REG2 ADC_MR; // ADC Mode Register | |
|
No newline at end of file | ||
|
78 | AT91_REG2 Reserved0[2]; // | |
|
No newline at end of file | ||
|
79 | AT91_REG2 ADC_CHER; // ADC Channel Enable Register | |
|
No newline at end of file | ||
|
80 | AT91_REG2 ADC_CHDR; // ADC Channel Disable Register | |
|
No newline at end of file | ||
|
81 | AT91_REG2 ADC_CHSR; // ADC Channel Status Register | |
|
No newline at end of file | ||
|
82 | AT91_REG2 ADC_SR; // ADC Status Register | |
|
No newline at end of file | ||
|
83 | AT91_REG2 ADC_LCDR; // ADC Last Converted Data Register | |
|
No newline at end of file | ||
|
84 | AT91_REG2 ADC_IER; // ADC Interrupt Enable Register | |
|
No newline at end of file | ||
|
85 | AT91_REG2 ADC_IDR; // ADC Interrupt Disable Register | |
|
No newline at end of file | ||
|
86 | AT91_REG2 ADC_IMR; // ADC Interrupt Mask Register | |
|
No newline at end of file | ||
|
87 | AT91_REG2 ADC_CDR0; // ADC Channel Data Register 0 | |
|
No newline at end of file | ||
|
88 | AT91_REG2 ADC_CDR1; // ADC Channel Data Register 1 | |
|
No newline at end of file | ||
|
89 | AT91_REG2 ADC_CDR2; // ADC Channel Data Register 2 | |
|
No newline at end of file | ||
|
90 | AT91_REG2 ADC_CDR3; // ADC Channel Data Register 3 | |
|
No newline at end of file | ||
|
91 | AT91_REG2 ADC_CDR4; // ADC Channel Data Register 4 | |
|
No newline at end of file | ||
|
92 | AT91_REG2 ADC_CDR5; // ADC Channel Data Register 5 | |
|
No newline at end of file | ||
|
93 | AT91_REG2 ADC_CDR6; // ADC Channel Data Register 6 | |
|
No newline at end of file | ||
|
94 | AT91_REG2 ADC_CDR7; // ADC Channel Data Register 7 | |
|
No newline at end of file | ||
|
95 | AT91_REG2 Reserved1[44]; // | |
|
No newline at end of file | ||
|
96 | AT91_REG2 ADC_RPR; // Receive Pointer Register | |
|
No newline at end of file | ||
|
97 | AT91_REG2 ADC_RCR; // Receive Counter Register | |
|
No newline at end of file | ||
|
98 | AT91_REG2 ADC_TPR; // Transmit Pointer Register | |
|
No newline at end of file | ||
|
99 | AT91_REG2 ADC_TCR; // Transmit Counter Register | |
|
No newline at end of file | ||
|
100 | AT91_REG2 ADC_RNPR; // Receive Next Pointer Register | |
|
No newline at end of file | ||
|
101 | AT91_REG2 ADC_RNCR; // Receive Next Counter Register | |
|
No newline at end of file | ||
|
102 | AT91_REG2 ADC_TNPR; // Transmit Next Pointer Register | |
|
No newline at end of file | ||
|
103 | AT91_REG2 ADC_TNCR; // Transmit Next Counter Register | |
|
No newline at end of file | ||
|
104 | AT91_REG2 ADC_PTCR; // PDC Transfer Control Register | |
|
No newline at end of file | ||
|
105 | AT91_REG2 ADC_PTSR; // PDC Transfer Status Register | |
|
No newline at end of file | ||
|
106 | } AT91S_ADC, *AT91PS_ADC; | |
|
No newline at end of file | ||
|
107 | ||
|
No newline at end of file | ||
|
108 | AT91S_ADC *adc_map(unsigned int adcbase); | |
|
No newline at end of file | ||
|
109 | /**********************Aniadido por DCV*********/ | |
|
No newline at end of file | ||
|
110 | AT91S_ADC *adc_map1(unsigned int adcbase); | |
|
No newline at end of file | ||
|
111 | /**********************Aniadido por DCV*********/ | |
|
No newline at end of file | ||
|
112 | ||
|
No newline at end of file | ||
|
113 | void ADC_INIT(AT91S_ADC * adc); | |
|
No newline at end of file | ||
|
114 | void ADC_RESET(AT91S_ADC * adc); | |
|
No newline at end of file | ||
|
115 | void CONFIG_ADC(AT91S_ADC * adc,unsigned int REG_CONFIG); | |
|
No newline at end of file | ||
|
116 | void ENABLE_CHANNEL(AT91S_ADC * adc,unsigned int CHANNEL); | |
|
No newline at end of file | ||
|
117 | unsigned int STATUS_CHANNEL(AT91S_ADC * adc); | |
|
No newline at end of file | ||
|
118 | unsigned int GET_ADC(AT91S_ADC * adc); | |
|
No newline at end of file | ||
|
119 | unsigned int GET_ADC0(AT91S_ADC * adc); | |
|
No newline at end of file | ||
|
120 | unsigned int GET_ADC1(AT91S_ADC * adc); | |
|
No newline at end of file | ||
|
121 | unsigned int GET_ADC3(AT91S_ADC * adc); | |
|
No newline at end of file | ||
|
122 | unsigned int ver_reg_mode(AT91S_ADC * adc); | |
|
No newline at end of file | ||
|
123 | unsigned int GET_STATUS(AT91S_ADC * adc); | |
|
No newline at end of file | ||
|
124 | #endif No newline at end of file |
@@ -0,0 +1,137 | |||
|
1 | /* | |
|
No newline at end of file | ||
|
2 | * This programmer uses AT91' GPIO lines | |
|
No newline at end of file | ||
|
3 | * | |
|
No newline at end of file | ||
|
4 | * 2006 by Carlos Camargo | |
|
No newline at end of file | ||
|
5 | * 2007.May.10 Andres Calderon | |
|
No newline at end of file | ||
|
6 | * 2009.Aug.26 Jose Francisco Quenta | |
|
No newline at end of file | ||
|
7 | */ | |
|
No newline at end of file | ||
|
8 | ||
|
No newline at end of file | ||
|
9 | #ifndef ECB_AT91_H | |
|
No newline at end of file | ||
|
10 | #define ECB_AT91_H | |
|
No newline at end of file | ||
|
11 | ||
|
No newline at end of file | ||
|
12 | ||
|
No newline at end of file | ||
|
13 | #define MAP_SIZE 4096Ul | |
|
No newline at end of file | ||
|
14 | #define MAP_MASK (MAP_SIZE - 1) | |
|
No newline at end of file | ||
|
15 | ||
|
No newline at end of file | ||
|
16 | #define PIOA_BASE 0xFFFFF400 | |
|
No newline at end of file | ||
|
17 | #define PIOB_BASE 0xFFFFF600 | |
|
No newline at end of file | ||
|
18 | #define PIOC_BASE 0xFFFFF800 | |
|
No newline at end of file | ||
|
19 | #define PIOD_BASE 0xFFFFFA00 | |
|
No newline at end of file | ||
|
20 | ||
|
No newline at end of file | ||
|
21 | #define PB0 (1 << 0) | |
|
No newline at end of file | ||
|
22 | #define PB1 (1 << 1) | |
|
No newline at end of file | ||
|
23 | #define PB2 (1 << 2) | |
|
No newline at end of file | ||
|
24 | #define PB3 (1 << 3) | |
|
No newline at end of file | ||
|
25 | #define PB8 (1 << 8) | |
|
No newline at end of file | ||
|
26 | #define PB9 (1 << 9) | |
|
No newline at end of file | ||
|
27 | #define PB10 (1 << 10) | |
|
No newline at end of file | ||
|
28 | #define PB11 (1 << 11) | |
|
No newline at end of file | ||
|
29 | #define PB16 (1 << 16) | |
|
No newline at end of file | ||
|
30 | #define PB17 (1 << 17) | |
|
No newline at end of file | ||
|
31 | #define PB18 (1 << 18) | |
|
No newline at end of file | ||
|
32 | #define PB19 (1 << 19) | |
|
No newline at end of file | ||
|
33 | #define PB20 (1 << 20) | |
|
No newline at end of file | ||
|
34 | #define PB21 (1 << 21) | |
|
No newline at end of file | ||
|
35 | #define PB22 (1 << 22) | |
|
No newline at end of file | ||
|
36 | #define PB23 (1 << 23) | |
|
No newline at end of file | ||
|
37 | #define PB24 (1 << 24) | |
|
No newline at end of file | ||
|
38 | #define PB25 (1 << 25) | |
|
No newline at end of file | ||
|
39 | #define PB30 (1 << 30) | |
|
No newline at end of file | ||
|
40 | #define PB31 (1 << 31) | |
|
No newline at end of file | ||
|
41 | ||
|
No newline at end of file | ||
|
42 | #define PC0 (1 << 0) | |
|
No newline at end of file | ||
|
43 | #define PC1 (1 << 1) | |
|
No newline at end of file | ||
|
44 | #define PC4 (1 << 4) | |
|
No newline at end of file | ||
|
45 | #define PC5 (1 << 5) | |
|
No newline at end of file | ||
|
46 | #define PC6 (1 << 6) | |
|
No newline at end of file | ||
|
47 | #define PC7 (1 << 7) | |
|
No newline at end of file | ||
|
48 | #define PC8 (1 << 8) | |
|
No newline at end of file | ||
|
49 | #define PC9 (1 << 9) | |
|
No newline at end of file | ||
|
50 | #define PC10 (1 << 10) | |
|
No newline at end of file | ||
|
51 | #define PC11 (1 << 11) | |
|
No newline at end of file | ||
|
52 | #define PC16 (1 << 16) | |
|
No newline at end of file | ||
|
53 | #define PC17 (1 << 17) | |
|
No newline at end of file | ||
|
54 | #define PC18 (1 << 18) | |
|
No newline at end of file | ||
|
55 | #define PC19 (1 << 19) | |
|
No newline at end of file | ||
|
56 | #define PC20 (1 << 20) | |
|
No newline at end of file | ||
|
57 | #define PC21 (1 << 21) | |
|
No newline at end of file | ||
|
58 | #define PC22 (1 << 22) | |
|
No newline at end of file | ||
|
59 | #define PC23 (1 << 23) | |
|
No newline at end of file | ||
|
60 | #define PC24 (1 << 24) | |
|
No newline at end of file | ||
|
61 | #define PC25 (1 << 25) | |
|
No newline at end of file | ||
|
62 | #define PC26 (1 << 26) | |
|
No newline at end of file | ||
|
63 | #define PC27 (1 << 27) | |
|
No newline at end of file | ||
|
64 | #define PC28 (1 << 28) | |
|
No newline at end of file | ||
|
65 | #define PC29 (1 << 29) | |
|
No newline at end of file | ||
|
66 | #define PC30 (1 << 30) | |
|
No newline at end of file | ||
|
67 | #define PC31 (1 << 31) | |
|
No newline at end of file | ||
|
68 | ||
|
No newline at end of file | ||
|
69 | ||
|
No newline at end of file | ||
|
70 | typedef volatile unsigned int AT91_REG; | |
|
No newline at end of file | ||
|
71 | /* Hardware register definition */ | |
|
No newline at end of file | ||
|
72 | ||
|
No newline at end of file | ||
|
73 | typedef struct _AT91S_PIO { | |
|
No newline at end of file | ||
|
74 | AT91_REG PIO_PER; /* PIO Enable Register */ | |
|
No newline at end of file | ||
|
75 | AT91_REG PIO_PDR; /* PIO Disable Register */ | |
|
No newline at end of file | ||
|
76 | AT91_REG PIO_PSR; /* PIO Status Register */ | |
|
No newline at end of file | ||
|
77 | AT91_REG Reserved0[1]; | |
|
No newline at end of file | ||
|
78 | AT91_REG PIO_OER; /* Output Enable Register */ | |
|
No newline at end of file | ||
|
79 | AT91_REG PIO_ODR; /* Output Disable Registerr */ | |
|
No newline at end of file | ||
|
80 | AT91_REG PIO_OSR; /* Output Status Register */ | |
|
No newline at end of file | ||
|
81 | AT91_REG Reserved1[1]; | |
|
No newline at end of file | ||
|
82 | AT91_REG PIO_IFER; /* Input Filter Enable Register */ | |
|
No newline at end of file | ||
|
83 | AT91_REG PIO_IFDR; /* Input Filter Disable Register */ | |
|
No newline at end of file | ||
|
84 | AT91_REG PIO_IFSR; /* Input Filter Status Register */ | |
|
No newline at end of file | ||
|
85 | AT91_REG Reserved2[1]; | |
|
No newline at end of file | ||
|
86 | AT91_REG PIO_SODR; /* Set Output Data Register */ | |
|
No newline at end of file | ||
|
87 | AT91_REG PIO_CODR; /* Clear Output Data Register */ | |
|
No newline at end of file | ||
|
88 | AT91_REG PIO_ODSR; /* Output Data Status Register */ | |
|
No newline at end of file | ||
|
89 | AT91_REG PIO_PDSR; /* Pin Data Status Register */ | |
|
No newline at end of file | ||
|
90 | AT91_REG PIO_IER; /* Interrupt Enable Register */ | |
|
No newline at end of file | ||
|
91 | AT91_REG PIO_IDR; /* Interrupt Disable Register */ | |
|
No newline at end of file | ||
|
92 | AT91_REG PIO_IMR; /* Interrupt Mask Register */ | |
|
No newline at end of file | ||
|
93 | AT91_REG PIO_ISR; /* Interrupt Status Register */ | |
|
No newline at end of file | ||
|
94 | AT91_REG PIO_MDER; /* Multi-driver Enable Register */ | |
|
No newline at end of file | ||
|
95 | AT91_REG PIO_MDDR; /* Multi-driver Disable Register */ | |
|
No newline at end of file | ||
|
96 | AT91_REG PIO_MDSR; /* Multi-driver Status Register */ | |
|
No newline at end of file | ||
|
97 | AT91_REG Reserved3[1]; | |
|
No newline at end of file | ||
|
98 | AT91_REG PIO_PUDR; /* Pull-up Disable Register */ | |
|
No newline at end of file | ||
|
99 | AT91_REG PIO_PUER; /* Pull-up Enable Register */ | |
|
No newline at end of file | ||
|
100 | AT91_REG PIO_PUSR; /* Pad Pull-up Status Register */ | |
|
No newline at end of file | ||
|
101 | AT91_REG Reserved4[1]; | |
|
No newline at end of file | ||
|
102 | AT91_REG PIO_ASR; /* Select A Register */ | |
|
No newline at end of file | ||
|
103 | AT91_REG PIO_BSR; /* Select B Register */ | |
|
No newline at end of file | ||
|
104 | AT91_REG PIO_ABSR; /* AB Select Status Register */ | |
|
No newline at end of file | ||
|
105 | AT91_REG Reserved5[9]; | |
|
No newline at end of file | ||
|
106 | AT91_REG PIO_OWER; /* Output Write Enable Register */ | |
|
No newline at end of file | ||
|
107 | AT91_REG PIO_OWDR; /* Output Write Disable Register */ | |
|
No newline at end of file | ||
|
108 | AT91_REG PIO_OWSR; /* Output Write Status Register */ | |
|
No newline at end of file | ||
|
109 | } AT91S_PIO, *AT91PS_PIO; | |
|
No newline at end of file | ||
|
110 | ||
|
No newline at end of file | ||
|
111 | void pio_out(AT91S_PIO * pio, int mask, unsigned long val, int opcion); | |
|
No newline at end of file | ||
|
112 | ||
|
No newline at end of file | ||
|
113 | int pio_in(AT91S_PIO * pio, int mask); | |
|
No newline at end of file | ||
|
114 | ||
|
No newline at end of file | ||
|
115 | AT91S_PIO *pio_map(unsigned int piobase); | |
|
No newline at end of file | ||
|
116 | ||
|
No newline at end of file | ||
|
117 | void pio_enable(AT91S_PIO * pio, int mask); | |
|
No newline at end of file | ||
|
118 | ||
|
No newline at end of file | ||
|
119 | void pio_output_enable(AT91S_PIO * pio, int mask); | |
|
No newline at end of file | ||
|
120 | ||
|
No newline at end of file | ||
|
121 | void pio_input_enable(AT91S_PIO * pio, int mask); | |
|
No newline at end of file | ||
|
122 | ||
|
No newline at end of file | ||
|
123 | void pio_disable_irq(AT91S_PIO * pio, int mask); | |
|
No newline at end of file | ||
|
124 | ||
|
No newline at end of file | ||
|
125 | void pio_disable_multiple_driver(AT91S_PIO * pio, int mask); | |
|
No newline at end of file | ||
|
126 | ||
|
No newline at end of file | ||
|
127 | void pio_disable_pull_ups(AT91S_PIO * pio, int mask); | |
|
No newline at end of file | ||
|
128 | ||
|
No newline at end of file | ||
|
129 | void pio_synchronous_data_output(AT91S_PIO * pio, int mask); | |
|
No newline at end of file | ||
|
130 | ||
|
No newline at end of file | ||
|
131 | //funciones agregadas para la realizar el estado de algunos registros: | |
|
No newline at end of file | ||
|
132 | int ver_registro(AT91S_PIO * pio); | |
|
No newline at end of file | ||
|
133 | void pin_adc_enable(AT91S_PIO * pio, int mask); | |
|
No newline at end of file | ||
|
134 | void periferico_a(AT91S_PIO * pio, int mask); | |
|
No newline at end of file | ||
|
135 | int ver_periferico(AT91S_PIO * pio); | |
|
No newline at end of file | ||
|
136 | ||
|
No newline at end of file | ||
|
137 | #endif No newline at end of file |
@@ -0,0 +1,83 | |||
|
1 | // ***************************************************************************** | |
|
No newline at end of file | ||
|
2 | // SOFTWARE API DEFINITION FOR Power Management Controler | |
|
No newline at end of file | ||
|
3 | // ***************************************************************************** | |
|
No newline at end of file | ||
|
4 | #ifndef SYSCLOCK_AT91_H | |
|
No newline at end of file | ||
|
5 | #define SYSCLOCK_AT91_H | |
|
No newline at end of file | ||
|
6 | ||
|
No newline at end of file | ||
|
7 | #define MAP_SIZE 4096Ul | |
|
No newline at end of file | ||
|
8 | #define MAP_MASK (MAP_SIZE - 1) | |
|
No newline at end of file | ||
|
9 | ||
|
No newline at end of file | ||
|
10 | #define CLOCK_BASE 0xFFFFFC00 | |
|
No newline at end of file | ||
|
11 | // -------- PMC_SCER : (PMC Offset: 0x0) System Clock Enable Register -------- | |
|
No newline at end of file | ||
|
12 | #define AT91C_PMC_PCK ((unsigned int) 0x1 << 0) // (PMC) Processor Clock | |
|
No newline at end of file | ||
|
13 | #define AT91C_PMC_UHP ((unsigned int) 0x1 << 6) // (PMC) USB Host Port Clock | |
|
No newline at end of file | ||
|
14 | #define AT91C_PMC_UDP ((unsigned int) 0x1 << 7) // (PMC) USB Device Port Clock | |
|
No newline at end of file | ||
|
15 | #define AT91C_PMC_PCK0 ((unsigned int) 0x1 << 8) // (PMC) Programmable Clock Output | |
|
No newline at end of file | ||
|
16 | #define AT91C_PMC_PCK1 ((unsigned int) 0x1 << 9) // (PMC) Programmable Clock Output | |
|
No newline at end of file | ||
|
17 | #define AT91C_PMC_HCK0 ((unsigned int) 0x1 << 16) // (PMC) AHB UHP Clock Output | |
|
No newline at end of file | ||
|
18 | #define AT91C_PMC_HCK1 ((unsigned int) 0x1 << 17) // (PMC) AHB LCDC Clock Output | |
|
No newline at end of file | ||
|
19 | // -------- PMC_SCDR : (PMC Offset: 0x4) System Clock Disable Register -------- | |
|
No newline at end of file | ||
|
20 | // -------- PMC_SCSR : (PMC Offset: 0x8) System Clock Status Register -------- | |
|
No newline at end of file | ||
|
21 | // -------- CKGR_MOR : (PMC Offset: 0x20) Main Oscillator Register -------- | |
|
No newline at end of file | ||
|
22 | // -------- CKGR_MCFR : (PMC Offset: 0x24) Main Clock Frequency Register -------- | |
|
No newline at end of file | ||
|
23 | // -------- CKGR_PLLAR : (PMC Offset: 0x28) PLL A Register -------- | |
|
No newline at end of file | ||
|
24 | // -------- CKGR_PLLBR : (PMC Offset: 0x2c) PLL B Register -------- | |
|
No newline at end of file | ||
|
25 | // -------- PMC_MCKR : (PMC Offset: 0x30) Master Clock Register -------- | |
|
No newline at end of file | ||
|
26 | #define AT91C_PMC_CSS ((unsigned int) 0x3 << 0) // (PMC) Programmable Clock Selection | |
|
No newline at end of file | ||
|
27 | #define AT91C_PMC_CSS_SLOW_CLK ((unsigned int) 0x0) // (PMC) Slow Clock is selected | |
|
No newline at end of file | ||
|
28 | #define AT91C_PMC_CSS_MAIN_CLK ((unsigned int) 0x1) // (PMC) Main Clock is selected | |
|
No newline at end of file | ||
|
29 | #define AT91C_PMC_CSS_PLLA_CLK ((unsigned int) 0x2) // (PMC) Clock from PLL A is selected | |
|
No newline at end of file | ||
|
30 | #define AT91C_PMC_CSS_PLLB_CLK ((unsigned int) 0x3) // (PMC) Clock from PLL B is selected | |
|
No newline at end of file | ||
|
31 | #define AT91C_PMC_PRES ((unsigned int) 0x7 << 2) // (PMC) Programmable Clock Prescaler | |
|
No newline at end of file | ||
|
32 | #define AT91C_PMC_PRES_CLK ((unsigned int) 0x0 << 2) // (PMC) Selected clock | |
|
No newline at end of file | ||
|
33 | #define AT91C_PMC_PRES_CLK_2 ((unsigned int) 0x1 << 2) // (PMC) Selected clock divided by 2 | |
|
No newline at end of file | ||
|
34 | #define AT91C_PMC_PRES_CLK_4 ((unsigned int) 0x2 << 2) // (PMC) Selected clock divided by 4 | |
|
No newline at end of file | ||
|
35 | #define AT91C_PMC_PRES_CLK_8 ((unsigned int) 0x3 << 2) // (PMC) Selected clock divided by 8 | |
|
No newline at end of file | ||
|
36 | #define AT91C_PMC_PRES_CLK_16 ((unsigned int) 0x4 << 2) // (PMC) Selected clock divided by 16 | |
|
No newline at end of file | ||
|
37 | #define AT91C_PMC_PRES_CLK_32 ((unsigned int) 0x5 << 2) // (PMC) Selected clock divided by 32 | |
|
No newline at end of file | ||
|
38 | #define AT91C_PMC_PRES_CLK_64 ((unsigned int) 0x6 << 2) // (PMC) Selected clock divided by 64 | |
|
No newline at end of file | ||
|
39 | #define AT91C_PMC_MDIV ((unsigned int) 0x3 << 8) // (PMC) Master Clock Division | |
|
No newline at end of file | ||
|
40 | #define AT91C_PMC_MDIV_1 ((unsigned int) 0x0 << 8) // (PMC) The master clock and the processor clock are the same | |
|
No newline at end of file | ||
|
41 | #define AT91C_PMC_MDIV_2 ((unsigned int) 0x1 << 8) // (PMC) The processor clock is twice as fast as the master clock | |
|
No newline at end of file | ||
|
42 | #define AT91C_PMC_MDIV_3 ((unsigned int) 0x2 << 8) // (PMC) The processor clock is four times faster than the master clock | |
|
No newline at end of file | ||
|
43 | // -------- PMC_PCKR : (PMC Offset: 0x40) Programmable Clock Register -------- | |
|
No newline at end of file | ||
|
44 | // -------- PMC_IER : (PMC Offset: 0x60) PMC Interrupt Enable Register -------- | |
|
No newline at end of file | ||
|
45 | #define AT91C_PMC_MOSCS ((unsigned int) 0x1 << 0) // (PMC) MOSC Status/Enable/Disable/Mask | |
|
No newline at end of file | ||
|
46 | #define AT91C_PMC_LOCKA ((unsigned int) 0x1 << 1) // (PMC) PLL A Status/Enable/Disable/Mask | |
|
No newline at end of file | ||
|
47 | #define AT91C_PMC_LOCKB ((unsigned int) 0x1 << 2) // (PMC) PLL B Status/Enable/Disable/Mask | |
|
No newline at end of file | ||
|
48 | #define AT91C_PMC_MCKRDY ((unsigned int) 0x1 << 3) // (PMC) Master Clock Status/Enable/Disable/Mask | |
|
No newline at end of file | ||
|
49 | #define AT91C_PMC_PCK0RDY ((unsigned int) 0x1 << 8) // (PMC) PCK0_RDY Status/Enable/Disable/Mask | |
|
No newline at end of file | ||
|
50 | #define AT91C_PMC_PCK1RDY ((unsigned int) 0x1 << 9) // (PMC) PCK1_RDY Status/Enable/Disable/Mask | |
|
No newline at end of file | ||
|
51 | // -------- PMC_IDR : (PMC Offset: 0x64) PMC Interrupt Disable Register -------- | |
|
No newline at end of file | ||
|
52 | // -------- PMC_SR : (PMC Offset: 0x68) PMC Status Register -------- | |
|
No newline at end of file | ||
|
53 | // -------- PMC_IMR : (PMC Offset: 0x6c) PMC Interrupt Mask Register -------- | |
|
No newline at end of file | ||
|
54 | ||
|
No newline at end of file | ||
|
55 | typedef volatile unsigned int AT91_REG3;// Hardware register definition | |
|
No newline at end of file | ||
|
56 | typedef struct _AT91S_PMC { | |
|
No newline at end of file | ||
|
57 | AT91_REG3 PMC_SCER; // System Clock Enable Register | |
|
No newline at end of file | ||
|
58 | AT91_REG3 PMC_SCDR; // System Clock Disable Register | |
|
No newline at end of file | ||
|
59 | AT91_REG3 PMC_SCSR; // System Clock Status Register | |
|
No newline at end of file | ||
|
60 | AT91_REG3 Reserved0[1]; // | |
|
No newline at end of file | ||
|
61 | AT91_REG3 PMC_PCER; // Peripheral Clock Enable Register | |
|
No newline at end of file | ||
|
62 | AT91_REG3 PMC_PCDR; // Peripheral Clock Disable Register | |
|
No newline at end of file | ||
|
63 | AT91_REG3 PMC_PCSR; // Peripheral Clock Status Register | |
|
No newline at end of file | ||
|
64 | AT91_REG3 Reserved1[1]; // | |
|
No newline at end of file | ||
|
65 | AT91_REG3 PMC_MOR; // Main Oscillator Register | |
|
No newline at end of file | ||
|
66 | AT91_REG3 PMC_MCFR; // Main Clock Frequency Register | |
|
No newline at end of file | ||
|
67 | AT91_REG3 PMC_PLLAR; // PLL A Register | |
|
No newline at end of file | ||
|
68 | AT91_REG3 PMC_PLLBR; // PLL B Register | |
|
No newline at end of file | ||
|
69 | AT91_REG3 PMC_MCKR; // Master Clock Register | |
|
No newline at end of file | ||
|
70 | AT91_REG3 Reserved2[3]; // | |
|
No newline at end of file | ||
|
71 | AT91_REG3 PMC_PCKR[8]; // Programmable Clock Register | |
|
No newline at end of file | ||
|
72 | AT91_REG3 PMC_IER; // Interrupt Enable Register | |
|
No newline at end of file | ||
|
73 | AT91_REG3 PMC_IDR; // Interrupt Disable Register | |
|
No newline at end of file | ||
|
74 | AT91_REG3 PMC_SR; // Status Register | |
|
No newline at end of file | ||
|
75 | AT91_REG3 PMC_IMR; // Interrupt Mask Register | |
|
No newline at end of file | ||
|
76 | } AT91S_PMC, *AT91PS_PMC; | |
|
No newline at end of file | ||
|
77 | ||
|
No newline at end of file | ||
|
78 | //Funciones: | |
|
No newline at end of file | ||
|
79 | AT91S_PMC *clock_map(unsigned int clockbase); | |
|
No newline at end of file | ||
|
80 | void enable_clock_adc(AT91S_PMC * clock); | |
|
No newline at end of file | ||
|
81 | unsigned int status_clock_adc(AT91S_PMC * clock); | |
|
No newline at end of file | ||
|
82 | #endif | |
|
No newline at end of file | ||
|
83 | No newline at end of file |
@@ -0,0 +1,39 | |||
|
1 | /* | |
|
No newline at end of file | ||
|
2 | * Mensajes.c | |
|
No newline at end of file | ||
|
3 | * | |
|
No newline at end of file | ||
|
4 | * Created on: Nov 12, 2009 | |
|
No newline at end of file | ||
|
5 | * Author: Jose Francisco Quenta | |
|
No newline at end of file | ||
|
6 | */ | |
|
No newline at end of file | ||
|
7 | ||
|
No newline at end of file | ||
|
8 | #include <stdio.h> | |
|
No newline at end of file | ||
|
9 | #include <stdlib.h> | |
|
No newline at end of file | ||
|
10 | ||
|
No newline at end of file | ||
|
11 | /* | |
|
No newline at end of file | ||
|
12 | * Imprime mensajes del servidor | |
|
No newline at end of file | ||
|
13 | */ | |
|
No newline at end of file | ||
|
14 | void LOG_SERVIDOR(char *mensaje){ | |
|
No newline at end of file | ||
|
15 | printf("SERVIDOR: %s\n",mensaje); | |
|
No newline at end of file | ||
|
16 | } | |
|
No newline at end of file | ||
|
17 | ||
|
No newline at end of file | ||
|
18 | /* | |
|
No newline at end of file | ||
|
19 | * Imprime mensajes del cliente | |
|
No newline at end of file | ||
|
20 | */ | |
|
No newline at end of file | ||
|
21 | void LOG_CLIENTE(char *mensaje){ | |
|
No newline at end of file | ||
|
22 | printf("CLIENTE: %s\n",mensaje); | |
|
No newline at end of file | ||
|
23 | } | |
|
No newline at end of file | ||
|
24 | ||
|
No newline at end of file | ||
|
25 | /* | |
|
No newline at end of file | ||
|
26 | * Error no fatal, permite la continuación del programa | |
|
No newline at end of file | ||
|
27 | */ | |
|
No newline at end of file | ||
|
28 | void ERROR(char *mensaje){ | |
|
No newline at end of file | ||
|
29 | fprintf(stderr, "ERROR. %s\n", mensaje); | |
|
No newline at end of file | ||
|
30 | } | |
|
No newline at end of file | ||
|
31 | ||
|
No newline at end of file | ||
|
32 | /* | |
|
No newline at end of file | ||
|
33 | * Error fatal, aborta la ejecución del programa con código de salida de error | |
|
No newline at end of file | ||
|
34 | */ | |
|
No newline at end of file | ||
|
35 | void ERROR_FATAL(char *mensaje){ | |
|
No newline at end of file | ||
|
36 | fprintf(stderr, "ERROR FATAL. %s\n", mensaje); | |
|
No newline at end of file | ||
|
37 | exit(EXIT_FAILURE); | |
|
No newline at end of file | ||
|
38 | } | |
|
No newline at end of file | ||
|
39 | No newline at end of file |
@@ -0,0 +1,138 | |||
|
1 | /* | |
|
No newline at end of file | ||
|
2 | * This programmer uses AT91' ADC Module | |
|
No newline at end of file | ||
|
3 | * | |
|
No newline at end of file | ||
|
4 | * 2010 by Ricardo V. Rojas Quispe | |
|
No newline at end of file | ||
|
5 | */ | |
|
No newline at end of file | ||
|
6 | ||
|
No newline at end of file | ||
|
7 | #include <stdint.h> | |
|
No newline at end of file | ||
|
8 | #include <stdlib.h> | |
|
No newline at end of file | ||
|
9 | #include <stdio.h> | |
|
No newline at end of file | ||
|
10 | #include <unistd.h> | |
|
No newline at end of file | ||
|
11 | ||
|
No newline at end of file | ||
|
12 | #include <sys/types.h> | |
|
No newline at end of file | ||
|
13 | #include <sys/stat.h> | |
|
No newline at end of file | ||
|
14 | #include <sys/mman.h> | |
|
No newline at end of file | ||
|
15 | #include <fcntl.h> | |
|
No newline at end of file | ||
|
16 | ||
|
No newline at end of file | ||
|
17 | #include "./Librerias/at91adc.h" | |
|
No newline at end of file | ||
|
18 | ||
|
No newline at end of file | ||
|
19 | AT91S_ADC *adc_map(unsigned int adcbase){ | |
|
No newline at end of file | ||
|
20 | int fd; | |
|
No newline at end of file | ||
|
21 | void *base; | |
|
No newline at end of file | ||
|
22 | ||
|
No newline at end of file | ||
|
23 | AT91S_ADC *adc; | |
|
No newline at end of file | ||
|
24 | ||
|
No newline at end of file | ||
|
25 | off_t addr = adcbase; | |
|
No newline at end of file | ||
|
26 | ||
|
No newline at end of file | ||
|
27 | if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) { | |
|
No newline at end of file | ||
|
28 | fprintf(stderr, "Cannot open /dev/mem.\n"); | |
|
No newline at end of file | ||
|
29 | exit(EXIT_FAILURE); | |
|
No newline at end of file | ||
|
30 | } | |
|
No newline at end of file | ||
|
31 | ||
|
No newline at end of file | ||
|
32 | ||
|
No newline at end of file | ||
|
33 | base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, addr & ~MAP_MASK); | |
|
No newline at end of file | ||
|
34 | ||
|
No newline at end of file | ||
|
35 | if (base == (void *) -1) { | |
|
No newline at end of file | ||
|
36 | fprintf(stderr, "Cannot open /dev/mem.\n"); | |
|
No newline at end of file | ||
|
37 | exit(EXIT_FAILURE); | |
|
No newline at end of file | ||
|
38 | } | |
|
No newline at end of file | ||
|
39 | ||
|
No newline at end of file | ||
|
40 | ||
|
No newline at end of file | ||
|
41 | adc = base + (addr & MAP_MASK); | |
|
No newline at end of file | ||
|
42 | ||
|
No newline at end of file | ||
|
43 | return adc; | |
|
No newline at end of file | ||
|
44 | } | |
|
No newline at end of file | ||
|
45 | /**********************Anadido por DCV*ini********/ | |
|
No newline at end of file | ||
|
46 | AT91S_ADC *adc_map1(unsigned int adcbase){ | |
|
No newline at end of file | ||
|
47 | int fd; | |
|
No newline at end of file | ||
|
48 | void *base; | |
|
No newline at end of file | ||
|
49 | ||
|
No newline at end of file | ||
|
50 | AT91S_ADC *adc; | |
|
No newline at end of file | ||
|
51 | ||
|
No newline at end of file | ||
|
52 | off_t addr = adcbase; | |
|
No newline at end of file | ||
|
53 | ||
|
No newline at end of file | ||
|
54 | if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) { | |
|
No newline at end of file | ||
|
55 | //fprintf(stderr, "Cannot open /dev/mem.\n"); | |
|
No newline at end of file | ||
|
56 | exit(EXIT_FAILURE); | |
|
No newline at end of file | ||
|
57 | } | |
|
No newline at end of file | ||
|
58 | ||
|
No newline at end of file | ||
|
59 | base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, addr & ~MAP_MASK); | |
|
No newline at end of file | ||
|
60 | ||
|
No newline at end of file | ||
|
61 | if (base == (void *) -1) { | |
|
No newline at end of file | ||
|
62 | //fprintf(stderr, "Cannot open /dev/mem.\n"); | |
|
No newline at end of file | ||
|
63 | exit(EXIT_FAILURE); | |
|
No newline at end of file | ||
|
64 | } | |
|
No newline at end of file | ||
|
65 | ||
|
No newline at end of file | ||
|
66 | adc = base + (addr & MAP_MASK); | |
|
No newline at end of file | ||
|
67 | ||
|
No newline at end of file | ||
|
68 | return adc; | |
|
No newline at end of file | ||
|
69 | } | |
|
No newline at end of file | ||
|
70 | ||
|
No newline at end of file | ||
|
71 | /*********************Anadido por DCV*fin**********/ | |
|
No newline at end of file | ||
|
72 | void ADC_INIT(AT91S_ADC * adc){ | |
|
No newline at end of file | ||
|
73 | //Incia conversion ADC | |
|
No newline at end of file | ||
|
74 | adc->ADC_CR = ADC_START; | |
|
No newline at end of file | ||
|
75 | } | |
|
No newline at end of file | ||
|
76 | ||
|
No newline at end of file | ||
|
77 | void ADC_RESET(AT91S_ADC * adc){ | |
|
No newline at end of file | ||
|
78 | //Reset de ADC | |
|
No newline at end of file | ||
|
79 | adc->ADC_CR = ADC_SWRST; | |
|
No newline at end of file | ||
|
80 | } | |
|
No newline at end of file | ||
|
81 | void CONFIG_ADC(AT91S_ADC * adc,unsigned int REG_CONFIG){ | |
|
No newline at end of file | ||
|
82 | //configura ADC | |
|
No newline at end of file | ||
|
83 | adc->ADC_MR = REG_CONFIG; | |
|
No newline at end of file | ||
|
84 | adc->ADC_IDR = ADC_DISABLE_INTERRUP; | |
|
No newline at end of file | ||
|
85 | } | |
|
No newline at end of file | ||
|
86 | void ENABLE_CHANNEL(AT91S_ADC * adc,unsigned int CHANNEL){ | |
|
No newline at end of file | ||
|
87 | //Habilita canal selecconado y deshabilita el resto | |
|
No newline at end of file | ||
|
88 | adc->ADC_CHER = CHANNEL & 0x0F; | |
|
No newline at end of file | ||
|
89 | adc->ADC_CHDR = ~CHANNEL & 0x0F; | |
|
No newline at end of file | ||
|
90 | } | |
|
No newline at end of file | ||
|
91 | unsigned int STATUS_CHANNEL(AT91S_ADC * adc){ | |
|
No newline at end of file | ||
|
92 | //Retorna el estado del canal habilitado | |
|
No newline at end of file | ||
|
93 | return (adc->ADC_CHSR); | |
|
No newline at end of file | ||
|
94 | } | |
|
No newline at end of file | ||
|
95 | unsigned int GET_ADC(AT91S_ADC * adc){ | |
|
No newline at end of file | ||
|
96 | //unsigned int valor=1; | |
|
No newline at end of file | ||
|
97 | //Retorna el valor de ADC (resolucion de 10BIT) | |
|
No newline at end of file | ||
|
98 | while(1){ | |
|
No newline at end of file | ||
|
99 | if ((adc-> ADC_SR & MASK_DRDY) == MASK_DRDY) | |
|
No newline at end of file | ||
|
100 | break; | |
|
No newline at end of file | ||
|
101 | } | |
|
No newline at end of file | ||
|
102 | return (adc->ADC_LCDR & ADC_LDATA); | |
|
No newline at end of file | ||
|
103 | } | |
|
No newline at end of file | ||
|
104 | unsigned int GET_STATUS(AT91S_ADC * adc){ | |
|
No newline at end of file | ||
|
105 | //Retorna el estado del ADC (registro) | |
|
No newline at end of file | ||
|
106 | return (adc->ADC_SR); | |
|
No newline at end of file | ||
|
107 | } | |
|
No newline at end of file | ||
|
108 | unsigned int GET_ADC0(AT91S_ADC * adc){ | |
|
No newline at end of file | ||
|
109 | //Retorna el valor de la conversion del canal 0 | |
|
No newline at end of file | ||
|
110 | while(1){ | |
|
No newline at end of file | ||
|
111 | if ((adc->ADC_SR & MASK_EOC0) == MASK_EOC0) | |
|
No newline at end of file | ||
|
112 | break; | |
|
No newline at end of file | ||
|
113 | } | |
|
No newline at end of file | ||
|
114 | return (adc->ADC_CDR0 & ADC_LDATA); | |
|
No newline at end of file | ||
|
115 | } | |
|
No newline at end of file | ||
|
116 | unsigned int GET_ADC1(AT91S_ADC * adc){ | |
|
No newline at end of file | ||
|
117 | //Retorna el valor de la conversion del canal 1 | |
|
No newline at end of file | ||
|
118 | while(1){ | |
|
No newline at end of file | ||
|
119 | if ((adc->ADC_SR & MASK_EOC1) == MASK_EOC1) | |
|
No newline at end of file | ||
|
120 | break; | |
|
No newline at end of file | ||
|
121 | } | |
|
No newline at end of file | ||
|
122 | return (adc->ADC_CDR1 & ADC_LDATA); | |
|
No newline at end of file | ||
|
123 | } | |
|
No newline at end of file | ||
|
124 | unsigned int GET_ADC3(AT91S_ADC * adc){ | |
|
No newline at end of file | ||
|
125 | unsigned int valor=1; | |
|
No newline at end of file | ||
|
126 | //Retorna el valor de ADC (resolucion de 10BIT) | |
|
No newline at end of file | ||
|
127 | while(valor){ | |
|
No newline at end of file | ||
|
128 | if ((adc-> ADC_SR) & 0x10000) | |
|
No newline at end of file | ||
|
129 | valor = 0; | |
|
No newline at end of file | ||
|
130 | else | |
|
No newline at end of file | ||
|
131 | valor = 1; | |
|
No newline at end of file | ||
|
132 | } | |
|
No newline at end of file | ||
|
133 | return (adc->ADC_CDR1 & ADC_DATA); | |
|
No newline at end of file | ||
|
134 | } | |
|
No newline at end of file | ||
|
135 | unsigned int ver_reg_mode(AT91S_ADC * adc){ | |
|
No newline at end of file | ||
|
136 | //retorna el valor del ADC_MR | |
|
No newline at end of file | ||
|
137 | return (adc->ADC_MR); | |
|
No newline at end of file | ||
|
138 | } No newline at end of file |
@@ -0,0 +1,119 | |||
|
1 | /* | |
|
No newline at end of file | ||
|
2 | * This programmer uses AT91' GPIO lines | |
|
No newline at end of file | ||
|
3 | * | |
|
No newline at end of file | ||
|
4 | * 2006 by Carlos Camargo | |
|
No newline at end of file | ||
|
5 | * 2007.May.10 Andres Calderon | |
|
No newline at end of file | ||
|
6 | * 2009.Aug.26 Jose Francisco Quenta | |
|
No newline at end of file | ||
|
7 | */ | |
|
No newline at end of file | ||
|
8 | ||
|
No newline at end of file | ||
|
9 | #include <stdint.h> | |
|
No newline at end of file | ||
|
10 | #include <stdlib.h> | |
|
No newline at end of file | ||
|
11 | #include <stdio.h> | |
|
No newline at end of file | ||
|
12 | #include <unistd.h> | |
|
No newline at end of file | ||
|
13 | ||
|
No newline at end of file | ||
|
14 | ||
|
No newline at end of file | ||
|
15 | #include <sys/types.h> | |
|
No newline at end of file | ||
|
16 | #include <sys/stat.h> | |
|
No newline at end of file | ||
|
17 | #include <sys/mman.h> | |
|
No newline at end of file | ||
|
18 | #include <fcntl.h> | |
|
No newline at end of file | ||
|
19 | ||
|
No newline at end of file | ||
|
20 | #include "./Librerias/at91gpio.h" | |
|
No newline at end of file | ||
|
21 | ||
|
No newline at end of file | ||
|
22 | void pio_out(AT91S_PIO * pio, int mask, unsigned long val, int opcion) | |
|
No newline at end of file | ||
|
23 | { | |
|
No newline at end of file | ||
|
24 | if (opcion == 1) | |
|
No newline at end of file | ||
|
25 | pio->PIO_SODR = mask & val; | |
|
No newline at end of file | ||
|
26 | else | |
|
No newline at end of file | ||
|
27 | pio->PIO_CODR = mask & val; | |
|
No newline at end of file | ||
|
28 | } | |
|
No newline at end of file | ||
|
29 | ||
|
No newline at end of file | ||
|
30 | ||
|
No newline at end of file | ||
|
31 | int pio_in(AT91S_PIO * pio, int mask) | |
|
No newline at end of file | ||
|
32 | { | |
|
No newline at end of file | ||
|
33 | return (pio->PIO_PDSR & mask); | |
|
No newline at end of file | ||
|
34 | } | |
|
No newline at end of file | ||
|
35 | ||
|
No newline at end of file | ||
|
36 | ||
|
No newline at end of file | ||
|
37 | AT91S_PIO *pio_map(unsigned int piobase) | |
|
No newline at end of file | ||
|
38 | { | |
|
No newline at end of file | ||
|
39 | int fd; | |
|
No newline at end of file | ||
|
40 | void *base; | |
|
No newline at end of file | ||
|
41 | ||
|
No newline at end of file | ||
|
42 | AT91S_PIO *pio; | |
|
No newline at end of file | ||
|
43 | ||
|
No newline at end of file | ||
|
44 | off_t addr = piobase; | |
|
No newline at end of file | ||
|
45 | ||
|
No newline at end of file | ||
|
46 | if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) { | |
|
No newline at end of file | ||
|
47 | fprintf(stderr, "Cannot open /dev/mem.\n"); | |
|
No newline at end of file | ||
|
48 | exit(EXIT_FAILURE); | |
|
No newline at end of file | ||
|
49 | } | |
|
No newline at end of file | ||
|
50 | ||
|
No newline at end of file | ||
|
51 | fprintf(stderr, "/dev/mem opened.\n"); | |
|
No newline at end of file | ||
|
52 | ||
|
No newline at end of file | ||
|
53 | base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, addr & ~MAP_MASK); | |
|
No newline at end of file | ||
|
54 | ||
|
No newline at end of file | ||
|
55 | if (base == (void *) -1) { | |
|
No newline at end of file | ||
|
56 | fprintf(stderr, "Cannot open /dev/mem.\n"); | |
|
No newline at end of file | ||
|
57 | exit(EXIT_FAILURE); | |
|
No newline at end of file | ||
|
58 | } | |
|
No newline at end of file | ||
|
59 | ||
|
No newline at end of file | ||
|
60 | fprintf(stderr, "Memory mapped at address %p.\n", base); | |
|
No newline at end of file | ||
|
61 | ||
|
No newline at end of file | ||
|
62 | pio = base + (addr & MAP_MASK); | |
|
No newline at end of file | ||
|
63 | ||
|
No newline at end of file | ||
|
64 | return pio; | |
|
No newline at end of file | ||
|
65 | } | |
|
No newline at end of file | ||
|
66 | ||
|
No newline at end of file | ||
|
67 | ||
|
No newline at end of file | ||
|
68 | void pio_enable(AT91S_PIO * pio, int mask) | |
|
No newline at end of file | ||
|
69 | { | |
|
No newline at end of file | ||
|
70 | pio->PIO_PER = mask; /* Enable PIO */ | |
|
No newline at end of file | ||
|
71 | } | |
|
No newline at end of file | ||
|
72 | ||
|
No newline at end of file | ||
|
73 | void pio_output_enable(AT91S_PIO * pio, int mask) | |
|
No newline at end of file | ||
|
74 | { | |
|
No newline at end of file | ||
|
75 | pio->PIO_OER = mask; /* Set TDI, TMS and TCK as outputs */ | |
|
No newline at end of file | ||
|
76 | } | |
|
No newline at end of file | ||
|
77 | ||
|
No newline at end of file | ||
|
78 | void pio_input_enable(AT91S_PIO * pio, int mask) | |
|
No newline at end of file | ||
|
79 | { | |
|
No newline at end of file | ||
|
80 | pio->PIO_ODR = mask; /* Set TDO as input */ | |
|
No newline at end of file | ||
|
81 | pio->PIO_IFER = mask; /* Enable Input Filter */ | |
|
No newline at end of file | ||
|
82 | } | |
|
No newline at end of file | ||
|
83 | ||
|
No newline at end of file | ||
|
84 | void pio_disable_irq(AT91S_PIO * pio, int mask) | |
|
No newline at end of file | ||
|
85 | { | |
|
No newline at end of file | ||
|
86 | pio->PIO_IDR = mask; /* Disable pin interrupts */ | |
|
No newline at end of file | ||
|
87 | } | |
|
No newline at end of file | ||
|
88 | ||
|
No newline at end of file | ||
|
89 | void pio_disable_multiple_driver(AT91S_PIO * pio, int mask) | |
|
No newline at end of file | ||
|
90 | { | |
|
No newline at end of file | ||
|
91 | pio->PIO_MDDR = mask; /* Disable Multiple Diver */ | |
|
No newline at end of file | ||
|
92 | } | |
|
No newline at end of file | ||
|
93 | ||
|
No newline at end of file | ||
|
94 | void pio_disable_pull_ups(AT91S_PIO * pio, int mask) | |
|
No newline at end of file | ||
|
95 | { | |
|
No newline at end of file | ||
|
96 | pio->PIO_PUDR = mask; /* Disable Pull-Ups */ | |
|
No newline at end of file | ||
|
97 | } | |
|
No newline at end of file | ||
|
98 | ||
|
No newline at end of file | ||
|
99 | void pio_synchronous_data_output(AT91S_PIO * pio, int mask) | |
|
No newline at end of file | ||
|
100 | { | |
|
No newline at end of file | ||
|
101 | pio->PIO_OWDR = mask; /* Synchronous Data Output Write in PIO_ */ | |
|
No newline at end of file | ||
|
102 | } | |
|
No newline at end of file | ||
|
103 | ||
|
No newline at end of file | ||
|
104 | //Nuevas funciones: | |
|
No newline at end of file | ||
|
105 | int ver_registro(AT91S_PIO * pio){ | |
|
No newline at end of file | ||
|
106 | return (pio->PIO_PSR); | |
|
No newline at end of file | ||
|
107 | } | |
|
No newline at end of file | ||
|
108 | //Habilitar pines para usar con ADC | |
|
No newline at end of file | ||
|
109 | void pin_adc_enable(AT91S_PIO * pio, int mask){ | |
|
No newline at end of file | ||
|
110 | pio->PIO_PDR = mask; | |
|
No newline at end of file | ||
|
111 | } | |
|
No newline at end of file | ||
|
112 | //selecciona para el periferico A | |
|
No newline at end of file | ||
|
113 | void periferico_a(AT91S_PIO * pio, int mask){ | |
|
No newline at end of file | ||
|
114 | pio->PIO_ASR = mask; | |
|
No newline at end of file | ||
|
115 | } | |
|
No newline at end of file | ||
|
116 | //Retorna cero si esta en el perifierico A y 1 si est aen el periferico B | |
|
No newline at end of file | ||
|
117 | int ver_periferico(AT91S_PIO * pio){ | |
|
No newline at end of file | ||
|
118 | return (pio->PIO_ABSR & 0x01); | |
|
No newline at end of file | ||
|
119 | } No newline at end of file |
@@ -0,0 +1,55 | |||
|
1 | /* | |
|
No newline at end of file | ||
|
2 | * This programmer uses AT91' System clock | |
|
No newline at end of file | ||
|
3 | * | |
|
No newline at end of file | ||
|
4 | * 2010 by Ricardo V. Rojas Quispe | |
|
No newline at end of file | ||
|
5 | */ | |
|
No newline at end of file | ||
|
6 | ||
|
No newline at end of file | ||
|
7 | #include <stdint.h> | |
|
No newline at end of file | ||
|
8 | #include <stdlib.h> | |
|
No newline at end of file | ||
|
9 | #include <stdio.h> | |
|
No newline at end of file | ||
|
10 | #include <unistd.h> | |
|
No newline at end of file | ||
|
11 | ||
|
No newline at end of file | ||
|
12 | #include <sys/types.h> | |
|
No newline at end of file | ||
|
13 | #include <sys/stat.h> | |
|
No newline at end of file | ||
|
14 | #include <sys/mman.h> | |
|
No newline at end of file | ||
|
15 | #include <fcntl.h> | |
|
No newline at end of file | ||
|
16 | ||
|
No newline at end of file | ||
|
17 | #include "./Librerias/at91sysclock.h" | |
|
No newline at end of file | ||
|
18 | ||
|
No newline at end of file | ||
|
19 | //Mapeando los registro en memoria: | |
|
No newline at end of file | ||
|
20 | AT91S_PMC *clock_map(unsigned int clockbase){ | |
|
No newline at end of file | ||
|
21 | int fd; | |
|
No newline at end of file | ||
|
22 | void *base; | |
|
No newline at end of file | ||
|
23 | ||
|
No newline at end of file | ||
|
24 | AT91S_PMC *clock; | |
|
No newline at end of file | ||
|
25 | ||
|
No newline at end of file | ||
|
26 | off_t addr = clockbase; | |
|
No newline at end of file | ||
|
27 | ||
|
No newline at end of file | ||
|
28 | if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) { | |
|
No newline at end of file | ||
|
29 | fprintf(stderr, "Cannot open /dev/mem.\n"); | |
|
No newline at end of file | ||
|
30 | exit(EXIT_FAILURE); | |
|
No newline at end of file | ||
|
31 | } | |
|
No newline at end of file | ||
|
32 | ||
|
No newline at end of file | ||
|
33 | //fprintf(stderr, "/dev/mem opened.\n"); | |
|
No newline at end of file | ||
|
34 | ||
|
No newline at end of file | ||
|
35 | base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, addr & ~MAP_MASK); | |
|
No newline at end of file | ||
|
36 | ||
|
No newline at end of file | ||
|
37 | if (base == (void *) -1) { | |
|
No newline at end of file | ||
|
38 | fprintf(stderr, "Cannot open /dev/mem.\n"); | |
|
No newline at end of file | ||
|
39 | exit(EXIT_FAILURE); | |
|
No newline at end of file | ||
|
40 | } | |
|
No newline at end of file | ||
|
41 | ||
|
No newline at end of file | ||
|
42 | //fprintf(stderr, "Memory mapped at address %p.\n", base); | |
|
No newline at end of file | ||
|
43 | ||
|
No newline at end of file | ||
|
44 | clock = base + (addr & MAP_MASK); | |
|
No newline at end of file | ||
|
45 | ||
|
No newline at end of file | ||
|
46 | return clock; | |
|
No newline at end of file | ||
|
47 | } | |
|
No newline at end of file | ||
|
48 | //Habilitamos el clock de ADC | |
|
No newline at end of file | ||
|
49 | void enable_clock_adc(AT91S_PMC * clock){ | |
|
No newline at end of file | ||
|
50 | clock->PMC_PCER=0x20; | |
|
No newline at end of file | ||
|
51 | } | |
|
No newline at end of file | ||
|
52 | //Leemos el registro de estado de clock para perifericos | |
|
No newline at end of file | ||
|
53 | unsigned int status_clock_adc(AT91S_PMC * clock){ | |
|
No newline at end of file | ||
|
54 | return (clock->PMC_PCSR); | |
|
No newline at end of file | ||
|
55 | } No newline at end of file |
@@ -25,9 +25,14 | |||
|
25 | 25 | #include <netinet/in.h> No newline at end of file |
|
26 | 26 | #include <arpa/inet.h> No newline at end of file |
|
27 | 27 | #include <netdb.h> |
|
28 | No newline at end of file | |
|
28 | ||
|
No newline at end of file | ||
|
29 | No newline at end of file | |
|
29 | #include "./Librerias/AT91gpio_Funciones.h" | |
|
No newline at end of file | ||
|
30 | No newline at end of file | |
|
30 | #include "./Librerias/Mensajes.h" No newline at end of file | |
|
No newline at end of file | ||
|
31 | #include "./Librerias/at91gpio.h" | |
|
No newline at end of file | ||
|
32 | //#include "./Librerias/Mensajes.h" | |
|
No newline at end of file | ||
|
33 | #include "./Librerias/at91adc.h" | |
|
No newline at end of file | ||
|
34 | //clock | |
|
No newline at end of file | ||
|
35 | #include "./Librerias/at91sysclock.h" No newline at end of file | |
|
31 | 36 | No newline at end of file |
|
32 | 37 | #define PUERTO_SERVIDOR 5500 No newline at end of file |
|
33 | 38 | #define TAM_BUFFER 1024 No newline at end of file |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now