-
Notifications
You must be signed in to change notification settings - Fork 0
/
interrupt.c
106 lines (89 loc) · 2.38 KB
/
interrupt.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* interrupt.c
*
* Created on: 06/mar/2015
* Author: robotics
*/
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdarg.h>
#include "inc/hw_ints.h"
#include "inc/hw_i2c.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/uart.h"
#include "driverlib/rom.h"
#include "uartp/uartstdio.h"
#include "uartp/uart.h"
#include "init.h"
///
/// routine di servizio della uart1 (usata per comunicare con la tiva)
volatile uint8_t uart1buffer[16], RX_PTR1 = 0, READ_PTR1 = 0;
void UART1IntHandler(void)
{
uint32_t ui32Status;
//
// Get the interrrupt status.
//
ui32Status = ROM_UARTIntStatus(UART1_BASE, true);
//
// Clear the asserted interrupts.
//
ROM_UARTIntClear(UART1_BASE, ui32Status);
PRINTF("INT:\n");
//
// Loop while there are characters in the receive FIFO.
//
while(ROM_UARTCharsAvail(UART1_BASE)){
//
// Read the next character from the UART and write it back to the UART.
//
uart1buffer[RX_PTR1]=ROM_UARTCharGetNonBlocking(UART1_BASE);
/// echo
ROM_UARTCharPutNonBlocking(UART0_BASE, uart1buffer[RX_PTR1]);
RX_PTR1++;
RX_PTR1 &= DIM_READ_BUFF - 1;
//UARTCharPutNonBlocking(UART1_BASE,
// dato);
}
}
///
// utilizzata per la lettura del sensore di colore
volatile int contLightPwm = 0;
void IntGPIOd(void){
GPIOIntClear(GPIO_PORTD_BASE, GPIO_INT_PIN_1);
contLightPwm++;
// //
// // Set PB3 high to indicate entry to this interrupt handler.
// //
// GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);
//
//
// //
// // Wait two seconds.
// //
// Delay(1);
//
// GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
}
extern volatile int procCom4;
///
/// routine di servizio del timer4
/// questa routine scatta e chiude la finestra di campionamento del sensore di colore.
void Timer4ISR(void){
/// pulisce le interruzione del timer4
ROM_TimerIntClear(TIMER4_BASE, TIMER_TIMA_TIMEOUT);
/// disabilita la porta D a generare interruzioni
GPIOIntDisable(GPIO_PORTD_BASE, GPIO_INT_PIN_1);
/// disabilita il timer 4
TimerDisable(TIMER4_BASE, TIMER_A);
/// segnala lo scadere del timer
procCom4 = 1;
/// spento il dispositivo
HWREG(GPIO_PORTD_BASE + (GPIO_O_DATA + (GPIO_PIN_0 << 2))) = 0;
}