-
This commit is contained in:
		| @@ -70,6 +70,8 @@ volatile eusart1_status_t eusart1RxLastError; | ||||
| /** | ||||
|   Section: EUSART1 APIs | ||||
| */ | ||||
| void (*EUSART1_RxDefaultInterruptHandler)(void); | ||||
|  | ||||
| void (*EUSART1_FramingErrorHandler)(void); | ||||
| void (*EUSART1_OverrunErrorHandler)(void); | ||||
| void (*EUSART1_ErrorHandler)(void); | ||||
| @@ -91,8 +93,8 @@ void EUSART1_Initialize(void) | ||||
|     // SPEN enabled; RX9 9-bit; CREN enabled; ADDEN disabled; SREN disabled;  | ||||
|     RCSTA1 = 0xD0; | ||||
|  | ||||
|     // TX9 9-bit; TX9D 0; SENDB sync_break_complete; TXEN enabled; SYNC synchronous; BRGH hi_speed; CSRC master_mode;  | ||||
|     TXSTA1 = 0xF4; | ||||
|     // TX9 9-bit; TX9D 0; SENDB sync_break_complete; TXEN enabled; SYNC asynchronous; BRGH hi_speed; CSRC master_mode;  | ||||
|     TXSTA1 = 0xE4; | ||||
|  | ||||
|     //  | ||||
|     SPBRG1 = 0x8A; | ||||
| @@ -138,12 +140,11 @@ eusart1_status_t EUSART1_get_last_status(void){ | ||||
| uint8_t EUSART1_Read(void) | ||||
| { | ||||
|     uint8_t readValue  = 0; | ||||
|     RCSTA1bits.SREN = 1; | ||||
|      | ||||
|     while(0 == eusart1RxCount) | ||||
|     { | ||||
|     } | ||||
|      | ||||
|  | ||||
|     eusart1RxLastError = eusart1RxStatusBuffer[eusart1RxTail]; | ||||
|  | ||||
|     readValue = eusart1RxBuffer[eusart1RxTail++]; | ||||
| @@ -160,8 +161,6 @@ uint8_t EUSART1_Read(void) | ||||
|  | ||||
| void EUSART1_Write(uint8_t txData) | ||||
| { | ||||
|     RCSTA1bits.SREN = 0; | ||||
|     RCSTA1bits.CREN = 0;	 | ||||
|     while(0 == PIR1bits.TX1IF) | ||||
|     { | ||||
|     } | ||||
| @@ -169,6 +168,8 @@ void EUSART1_Write(uint8_t txData) | ||||
|     TXREG1 = txData;    // Write the data byte to the USART. | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| void EUSART1_Receive_ISR(void) | ||||
| { | ||||
|      | ||||
| @@ -178,7 +179,7 @@ void EUSART1_Receive_ISR(void) | ||||
|         eusart1RxStatusBuffer[eusart1RxHead].ferr = 1; | ||||
|         EUSART1_FramingErrorHandler(); | ||||
|     } | ||||
|      | ||||
|  | ||||
|     if(RCSTA1bits.OERR){ | ||||
|         eusart1RxStatusBuffer[eusart1RxHead].oerr = 1; | ||||
|         EUSART1_OverrunErrorHandler(); | ||||
| @@ -190,7 +191,7 @@ void EUSART1_Receive_ISR(void) | ||||
|         EUSART1_RxDataHandler(); | ||||
|     } | ||||
|      | ||||
|     // or set custom function using eusart1_SetRxInterruptHandler() | ||||
|     // or set custom function using EUSART1_SetRxInterruptHandler() | ||||
| } | ||||
|  | ||||
| void EUSART1_RxDataHandler(void){ | ||||
| @@ -201,7 +202,6 @@ void EUSART1_RxDataHandler(void){ | ||||
|         eusart1RxHead = 0; | ||||
|     } | ||||
|     eusart1RxCount++; | ||||
|      | ||||
| } | ||||
|  | ||||
| void EUSART1_DefaultFramingErrorHandler(void){} | ||||
|   | ||||
| @@ -91,8 +91,7 @@ extern volatile uint8_t eusart1RxCount; | ||||
| /** | ||||
|   Section: EUSART1 APIs | ||||
| */ | ||||
|  | ||||
| void (*EUSART1_RxDefaultInterruptHandler)(void); | ||||
| extern void (*EUSART1_RxDefaultInterruptHandler)(void); | ||||
|  | ||||
| /** | ||||
|   @Summary | ||||
|   | ||||
| @@ -71,7 +71,7 @@ void PIN_MANAGER_Initialize(void) | ||||
|     TRISG = 0xFF; | ||||
|     TRISB = 0xFF; | ||||
|     TRISH = 0xFF; | ||||
|     TRISC = 0xFB; | ||||
|     TRISC = 0xBB; | ||||
|     TRISD = 0xFF; | ||||
|     TRISJ = 0xFF; | ||||
|      | ||||
|   | ||||
| @@ -75,6 +75,14 @@ | ||||
| #define RC2_SetDigitalInput()       do { TRISCbits.TRISC2 = 1; } while(0) | ||||
| #define RC2_SetDigitalOutput()      do { TRISCbits.TRISC2 = 0; } while(0) | ||||
|  | ||||
| // get/set RC6 procedures | ||||
| #define RC6_SetHigh()               do { LATCbits.LATC6 = 1; } while(0) | ||||
| #define RC6_SetLow()                do { LATCbits.LATC6 = 0; } while(0) | ||||
| #define RC6_Toggle()                do { LATCbits.LATC6 = ~LATCbits.LATC6; } while(0) | ||||
| #define RC6_GetValue()              PORTCbits.RC6 | ||||
| #define RC6_SetDigitalInput()       do { TRISCbits.TRISC6 = 1; } while(0) | ||||
| #define RC6_SetDigitalOutput()      do { TRISCbits.TRISC6 = 0; } while(0) | ||||
|  | ||||
| // get/set voltage aliases | ||||
| #define voltage_TRIS                 TRISFbits.TRISF0 | ||||
| #define voltage_LAT                  LATFbits.LATF0 | ||||
|   | ||||
| @@ -71,11 +71,11 @@ void TMR0_Initialize(void) | ||||
|     //Enable 16bit timer mode before assigning value to TMR0H | ||||
|     T0CONbits.T08BIT = 0; | ||||
|  | ||||
|     // TMR0H 255;  | ||||
|     TMR0H = 0xFF; | ||||
|     // TMR0H 158;  | ||||
|     TMR0H = 0x9E; | ||||
|  | ||||
|     // TMR0L 252;  | ||||
|     TMR0L = 0xFC; | ||||
|     // TMR0L 87;  | ||||
|     TMR0L = 0x57; | ||||
|  | ||||
| 	 | ||||
|     // Load TMR0 value to the 16-bit reload variable | ||||
| @@ -90,8 +90,8 @@ void TMR0_Initialize(void) | ||||
|     // Set Default Interrupt Handler | ||||
|     TMR0_SetInterruptHandler(TMR0_DefaultInterruptHandler); | ||||
|  | ||||
|     // T0PS 1:2; T08BIT 16-bit; T0SE Increment_hi_lo; T0CS T0CKI; TMR0ON enabled; PSA not_assigned;  | ||||
|     T0CON = 0xB8; | ||||
|     // T0PS 1:2; T08BIT 16-bit; T0SE Increment_hi_lo; T0CS FOSC/4; TMR0ON enabled; PSA not_assigned;  | ||||
|     T0CON = 0x98; | ||||
| } | ||||
|  | ||||
| void TMR0_StartTimer(void) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user