System Management code
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
Revision 1:e02eb179aed3, committed 2014-10-04
- Comitter:
- martydd3
- Date:
- Sat Oct 04 16:19:45 2014 +0000
- Parent:
- 0:e516fcccccda
- Child:
- 2:baeb80c778f7
- Commit message:
- System Management code;
Changed in this revision
--- a/CANBuffer.lib Wed Oct 01 12:52:26 2014 +0000 +++ b/CANBuffer.lib Sat Oct 04 16:19:45 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/Penn-Electric-Racing/code/CANBuffer/#0d8e82a5db8d +http://developer.mbed.org/teams/Penn-Electric-Racing/code/CANBuffer/#6fc28f58f16e
--- a/LPCDigitalOut.lib Wed Oct 01 12:52:26 2014 +0000 +++ b/LPCDigitalOut.lib Sat Oct 04 16:19:45 2014 +0000 @@ -1,1 +1,1 @@ -https://mbed.org/teams/Penn-Electric-Racing/code/LPCDigitalOut/#6e44ba5dde94 +http://developer.mbed.org/teams/Penn-Electric-Racing/code/LPCDigitalOut/#88059ca2c2d9
--- a/RTCStore/Store_RTC.h Wed Oct 01 12:52:26 2014 +0000 +++ b/RTCStore/Store_RTC.h Sat Oct 04 16:19:45 2014 +0000 @@ -22,6 +22,7 @@ #define _BATTERY_STATUS_ #include"mbed.h" +// General purpose register 0 #define _GPREG_BASE 0x40024044 // RTC = Real-Time Clock
--- a/SysMngmt.cpp Wed Oct 01 12:52:26 2014 +0000
+++ b/SysMngmt.cpp Sat Oct 04 16:19:45 2014 +0000
@@ -43,13 +43,28 @@
}
*/
+/*
+ http://developer.mbed.org/users/AjK/notebook/getting-closer-to-the-hardware/
+
+ extern "C" means this is linked assuming it's C code
+ C++ linker appearently adds extra crap with the function arguments keeping functions of this kind from linking properly
+
+ Interrupt handler, This is probably linked to the Timer 2 interrupt request somewhere by the libraries
+*/
extern "C" void TIMER2_IRQHandler(void)
{
if((LPC_TIM2->IR & 0x01) == 0x01) // if MR0 interrupt
{
- //printf("Every 1ms\n\r");
+ // This probably shouldn't be here, never have a printf() in an interrupt, locks up the main thread
+ // printf("Every 1ms\n\r");
+
LPC_TIM2->IR |= 1 << 0; // Clear MR0 interrupt flag
+ // gonna hope all these calculations are correct
+ // writes to RTC store, but there's no read code here
+ // 2 misleading things. First, RTC store writes to a general purpose register
+ // secondly, no code reads from this register in this .cpp, but maybe some other code does
+
Bat_I_Ratio=BatISense.read();
BATA_msec=(((Bat_I_Ratio*3.3) - BAT_ISENSE_OFFSET_V)/BAT_ISENSE_INCREMENT);
BATmA_Hr+=(BATA_msec*MSEC_HRS);
@@ -60,11 +75,14 @@
store.write(DCA_msec,1);
LPC_TIM2->TCR |= (1<<1); //Reset Timer1
- LPC_TIM2->TCR &= ~(1<<1); //Re Enable Timer1
+ LPC_TIM2->TCR &= ~(1<<1); //Re Enable Timer1
}
}
-
+/*
+ Appears to read a whole bunch of DigitalOut pins in void PollSwitch(), store the value in uint16_t Rxpoll,
+ and write the result to the CAN bus
+*/
void Poll()
{
uint16_t Rxpoll;
@@ -214,7 +232,8 @@
->MR0 0x4009 0018 (Match Register)
- ->MCR 0x4009 0014 (Match Control Register)
+ ->MCR 0x4009 0014 (Match Control Register) What to do when Match Register matches the Timer Counter
+ |= (1<<0); 0 Bit (Interrupt on MR0, interrupt generated when MR0 matches the value in TC)
*/
LPC_SC->PCONP |= (1<<22); //PoewerOn Timer/Counter2
@@ -223,6 +242,21 @@
LPC_TIM2->MR0 = 11999; // 1msec
LPC_TIM2->MCR |= (1<<0);
+ /*
+ Nested Vectored Interrupt Controller (NVIC)
+
+ NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
+ sets priority of an interrupt
+
+ IRQn_Type
+ Interrupt number definitions
+ Interrupt Request (IRQ)
+
+ NVIC_EnableIRQ(IRQn_Type IRQn)
+ Enable external interrupt (in this case, the TIMER2_IRQHandler(void) function above gets called every time
+ Timer2 generates an interrupt signal)
+
+ */
NVIC_SetPriority(TIMER0_IRQn,200); //IMD Capture Interrupt
NVIC_SetPriority(TIMER1_IRQn,200); //IMD 1msec sampling Interrupt
NVIC_SetPriority(TIMER2_IRQn,1); //Battery 1msec sampling Interrupt
