Permalink
Browse files

Merge branch 'master' of https://github.com/chipKIT32/chipKIT32-MAX

Conflicts:
	hardware/pic32/cores/pic32/HardwareSerial.cpp
Included in this change is the fix for issue #300 - adding ability to use high baud rates for hardware serial ports.
  • Loading branch information...
2 parents 2573386 + 3c56410 commit 3d0343518cb3d3cbd0199fc4b423777445264894 @EmbeddedMan EmbeddedMan committed Dec 29, 2012
@@ -58,7 +58,7 @@
//* Nov 1, 2011 <MLS> Also fixed some other compatibilty issues
//* Nov 12, 2012 <GeneApperson> Rewrite for board variant support
//* Sep 8, 2012 <BrianSchmalz> Fix dropping bytes on USB RX bug
-//* Jul 26, 2012 <GeneApperson> Added PPS support for PIC32MX1xx/MX2xx devices
+//* 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)
//************************************************************************
#ifndef __LANGUAGE_C__
@@ -43,6 +43,8 @@
#define bnSPI2TXIE 6
uint32_t spi_state;
+uint8_t fspi_state_saved = false;
+uint32_t interrupt_state = 0;
/** Soft SPI receive */
uint8_t spiRec(void) {
@@ -158,14 +160,24 @@ uint32_t Sd2Card::cardSize(void) {
void Sd2Card::chipSelectHigh(void) {
digitalWrite(chipSelectPin_, HIGH);
#if defined(_BOARD_MEGA_) || defined(_BOARD_UNO_) || defined(_BOARD_UC32_)
- SPI2CON = spi_state;
+ if(fspi_state_saved)
+ {
+ SPI2CON = spi_state;
+ fspi_state_saved = false;
+ INTRestoreInterrupts(interrupt_state);
+ }
#endif
}
//------------------------------------------------------------------------------
void Sd2Card::chipSelectLow(void) {
#if defined(_BOARD_MEGA_) || defined(_BOARD_UNO_) || defined(_BOARD_UC32_)
- spi_state = SPI2CON;
- SPI2CONbits.ON = 0;
+ if(!fspi_state_saved)
+ {
+ interrupt_state = INTDisableInterrupts();
+ spi_state = SPI2CON;
+ SPI2CONbits.ON = 0;
+ fspi_state_saved = true;
+ }
#endif
digitalWrite(chipSelectPin_, LOW);
}
@@ -313,6 +313,10 @@ extern const uint8_t analog_pin_to_channel_PGM[];
#define _SER0_IPL_ISR _UART1_IPL_ISR
#define _SER0_IPL _UART1_IPL_IPC
#define _SER0_SPL _UART1_SPL_IPC
+//#define>_SER0_RX_PIN 8$
+//#define>_SER0_TX_PIN 9$
+
+
/* Serial port 1 uses UART2
*/
@@ -322,6 +326,10 @@ extern const uint8_t analog_pin_to_channel_PGM[];
#define _SER1_IPL_ISR _UART2_IPL_ISR
#define _SER1_IPL _UART2_IPL_IPC
#define _SER1_SPL _UART2_SPL_IPC
+//#define>_SER0_RX_PIN 28$
+//#define>_SER0_TX_PIN 29$
+
+
/* ------------------------------------------------------------ */
/* SPI Port Declarations */

0 comments on commit 3d03435

Please sign in to comment.