Permalink
Browse files

Remove dependency on plib

Former-commit-id: 8920e48
  • Loading branch information...
1 parent cd2c4fc commit e5811e1a44b8bb45fef97115ef6946489deb0d53 @GeneApperson GeneApperson committed Feb 13, 2013
Showing with 1,465 additions and 337 deletions.
  1. +5 −15 hardware/pic32/cores/pic32/HardwareSerial.cpp
  2. +0 −2 hardware/pic32/cores/pic32/HardwareSerial_cdcacm.c
  3. +2 −1 hardware/pic32/cores/pic32/HardwareSerial_usb.c
  4. +2 −2 hardware/pic32/cores/pic32/System_Defs.h
  5. +15 −12 hardware/pic32/cores/pic32/Tone.cpp
  6. +3 −2 hardware/pic32/cores/pic32/WInterrupts.c
  7. +655 −0 hardware/pic32/cores/pic32/WSystem.c
  8. +148 −2 hardware/pic32/cores/pic32/p32_defs.h
  9. +30 −13 hardware/pic32/cores/pic32/task_manager.c
  10. +26 −43 hardware/pic32/cores/pic32/wiring.c
  11. +25 −14 hardware/pic32/cores/pic32/wiring.h
  12. +40 −44 hardware/pic32/cores/pic32/wiring_analog.c
  13. +1 −1 hardware/pic32/cores/pic32/wiring_digital.c
  14. +5 −0 hardware/pic32/cores/pic32/wiring_private.h
  15. +24 −7 hardware/pic32/libraries/EEPROM/utility/Deeprom.c
  16. +16 −0 hardware/pic32/libraries/EEPROM/utility/Deeprom.h
  17. +246 −0 hardware/pic32/libraries/EEPROM/utility/flash.c
  18. +78 −0 hardware/pic32/libraries/EEPROM/utility/flash.h
  19. +45 −17 hardware/pic32/libraries/SD/utility/Sd2Card.cpp
  20. +56 −72 hardware/pic32/libraries/SD/utility/Sd2PinMap.h
  21. +3 −3 hardware/pic32/libraries/Servo/Servo.cpp
  22. +2 −1 hardware/pic32/libraries/Servo/utility/int.c
  23. +1 −1 hardware/pic32/libraries/Servo/utility/int.h
  24. +11 −10 hardware/pic32/libraries/SoftPWMServo/SoftPWMServo.cpp
  25. +1 −1 hardware/pic32/libraries/Wire/utility/twi.c
  26. +4 −17 hardware/pic32/variants/Fubarino_Mini/Board_Data.c
  27. +9 −19 hardware/pic32/variants/Max32/Board_Data.c
  28. +4 −12 hardware/pic32/variants/fubarino_sd_v10/Board_Data.c
  29. +4 −10 hardware/pic32/variants/fubarino_sd_v11/Board_Data.c
  30. +4 −16 hardware/pic32/variants/quicK240/Board_Data.c
@@ -60,8 +60,9 @@
//* Sep 8, 2012 <BrianSchmalz> Fix dropping bytes on USB RX bug
//* Jul 26, 2012 <GeneApperson> Added PPS support for PIC32MX1xx/MX2xx devices
//* Nov 23, 2012 <BrianSchmalz> Auto-detect when to use BRGH = 1 (high baud rates)
+//* Feb 6, 2013 <GeneApperson> Removed dependencies on the Microchip plib library
//************************************************************************
-#ifndef __LANGUAGE_C__
+#if !defined(__LANGUAGE_C__)
#define __LANGUAGE_C__
#endif
@@ -70,7 +71,7 @@
#include <inttypes.h>
#include <p32xxxx.h>
-#include <plib.h>
+#include <sys/attribs.h>
#include "wiring.h"
#include "wiring_private.h"
@@ -193,20 +194,9 @@ void HardwareSerial::begin(unsigned long baudRate)
mapPps(pinRx, ppsRx);
#endif
- /* Compute the address of the interrupt priority control
- ** registers used by this UART
- */
- ipc = ((p32_regset *)&IPC0) + (vec / 4); //interrupt priority control reg set
-
- /* Compute the number of bit positions to shift to get to the
- ** correct position for the priority bits for this IRQ.
- */
- irq_shift = 8 * (vec % 4);
-
/* Set the interrupt privilege level and sub-privilege level
*/
- ipc->clr = (0x1F << irq_shift);
- ipc->set = ((ipl << 2) + spl) << irq_shift;
+ setIntPriority(vec, ipl, spl);
/* Clear the interrupt flags, and set the interrupt enables for the
** interrupts used by this UART.
@@ -573,7 +563,7 @@ void USBSerial::begin(unsigned long baudRate)
DebugViaSerial0("returned from cdcacm_register");
// Must enable glocal interrupts - in this case, we are using multi-vector mode
- INTEnableSystemMultiVectoredInt();
+ //INTEnableSystemMultiVectoredInt();
DebugViaSerial0("INTEnableSystemMultiVectoredInt");
}
@@ -19,8 +19,6 @@
//************************************************************************
-#include <plib.h>
-
//#include "main.h"
#include "HardwareSerial.h"
//* make sure the cpu selected has a usb port
@@ -18,7 +18,8 @@
//************************************************************************
-#include <plib.h>
+#include <p32xxxx.h>
+#include <sys/attribs.h>
#include "HardwareSerial.h"
@@ -118,11 +118,11 @@
*/
#if defined(__PIC32MX1XX__) || defined(__PIC32MX2XX__)
#define _CT_IPL_ISR IPL7SOFT
-#define _CT_IPL_IPC CT_INT_PRIOR_7
+#define _CT_IPL_IPC 7
#define _CT_SPL_IPC 0
#else
#define _CT_IPL_ISR IPL7SRS
-#define _CT_IPL_IPC CT_INT_PRIOR_7
+#define _CT_IPL_IPC 7
#define _CT_SPL_IPC 0
#endif
@@ -37,13 +37,12 @@
//* Oct 15, 2010 Started on Tone.cpp for PIC32
//* Aug 7, 2011 <GeneApperson> Completed implementation for single tone.
//* Oct 5, 2011 <MLS> Issue #132 Tone fails when the frequency is 0 fixed
+// Feb 6, 2013 <GeneApperson> Removed dependencies on the Microchip plib library
//************************************************************************
#define LANGUAGE_C
#define __LANGUAGE_C__
-//* the Microchip .h files do not know about C++
-#include <plib.h>
//#define DEBUG_TONE
@@ -56,12 +55,15 @@
#include "HardwareSerial.h"
#endif
+#include <p32xxxx.h>
+#include <sys/attribs.h>
+
#include "wiring.h"
#define OPT_SYSTEM_INTERNAL
#define OPT_BOARD_INTERNAL //pull in internal symbol definitons
-#include "pins_arduino.h"
#include "p32_defs.h"
+#include "pins_arduino.h"
// timerx_toggle_count:
// > 0 - duration specified
@@ -100,9 +102,10 @@ uint8_t port;
if (tone_pin == 255)
{
// No tone currently playing. Init the timer.
- T1CON = T1_PS_1_256;
- mT1ClearIntFlag();
- ConfigIntTimer1(T1_INT_ON | _T1_IPL_IPC | (_T1_SPL_IPC << 4));
+ T1CON = TACON_PS_256;
+ clearIntFlag(_TIMER_1_IRQ);
+ setIntPriority(_TIMER_1_VECTOR, _T1_IPL_IPC, _T1_SPL_IPC);
+ setIntEnable(_TIMER_1_IRQ);
}
else if (_pin != tone_pin)
{
@@ -130,17 +133,17 @@ uint8_t port;
timer1_toggle_count = -1;
}
- TMR1 = 0;
- PR1 = ((F_CPU / 256) / 2 / frequency);
- T1CONSET = T1_ON;
+ TMR1 = 0;
+ PR1 = ((__PIC32_pbClk / 256) / 2 / frequency);
+ T1CONSET = TACON_ON;
}
}
//************************************************************************
void disableTimer(uint8_t _timer)
{
- mT1IntEnable(0);
- T1CON = 0;;
+ clearIntEnable(_TIMER_1_IRQ);
+ T1CON = 0;
tone_pin = 255;
}
@@ -187,7 +190,7 @@ void __ISR(_TIMER_1_VECTOR, _T1_IPL_ISR) Timer1Handler(void)
}
// clear the interrupt flag
- mT1ClearIntFlag();
+ clearIntFlag(_TIMER_1_IRQ);
}
}; //* extern "C"
@@ -32,18 +32,19 @@
//* Aug 30, 2011 <GeneApperson> clear interrupt flag after return from
//* user interrupt function (issue #109)
//* Jul 26, 2012 <GeneApperson> Added PPS support for PIC32MX1xx/MX2xx devices
+// Feb 6, 2012 <GeneApperson> Removed dependencies on the Microchip plib library
//************************************************************************
-#include <plib.h>
#include <p32xxxx.h>
+#include <sys/attribs.h>
#include <inttypes.h>
#include <stdio.h>
#define OPT_SYSTEM_INTERNAL
#define OPT_BOARD_INTERNAL //pull in internal symbol definitons
-#include "pins_arduino.h"
#include "p32_defs.h"
+#include "pins_arduino.h"
#include "WConstants.h"
#include "wiring_private.h"
Oops, something went wrong.

0 comments on commit e5811e1

Please sign in to comment.