Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 216 → Rev 231

/PIC Stuff/Cerebot_32MX7_LED_Cube/UART1.c
1,5 → 1,3
#include <xc.h>
#include <plib.h>
#include "defines.h"
#include "UART1.h"
 
16,7 → 14,7
* BRG = PerfBusFreq / (4 * Baud Rate) - 1
*/
 
void UART1_Init(UART1_DATA *data, void (*rx_callback)(char)) {
void UART1_Init(UART1_DATA *data, void (*rx_callback)(uint8_t)) {
uart_data_ptr = data;
uart_data_ptr->rx_callback = rx_callback;
uart_data_ptr->buffer_out_len = 0;
45,7 → 43,7
PORTDbits.RD14 = 0;
}
 
int UART1_Write(char *string, int length) {
uint8_t UART1_Write(uint8_t *string, uint32_t length) {
if (length > UART1_BUFFER_SIZE)
return 0;
if (uart_data_ptr->buffer_out_len != 0)
54,7 → 52,7
// Put the data to send into the outbound buffer
uart_data_ptr->buffer_out_len = length;
uart_data_ptr->buffer_out_ind = 0;
int i;
uint8_t i;
for (i = 0; i < length; i++) {
uart_data_ptr->buffer_out[i] = string[i];
}
82,7 → 80,7
if (IFS0bits.U1RXIF) {
// Read the data received from the last transfer
while (U1STAbits.URXDA) {
char c = U1RXREG;
uint8_t c = U1RXREG;
// Call the RX callback function on each received data
if (uart_data_ptr->rx_callback != NULL) {
(*uart_data_ptr->rx_callback)(c);