forked from opetany93/KCC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuart.c
56 lines (45 loc) · 969 Bytes
/
uart.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* uart.c
*
* Created on: 13 sty 2018
* Author: opetany
*/
#include "../inc/uart.h"
#include "system.h"
#include "altera_up_avalon_rs232_regs.h"
static void sendByte(char byte)
{
IOWR_ALT_UP_RS232_DATA(UART_0_BASE, byte);
}
uint16_t ReceiveData(void){
IORD_ALT_UP_RS232_DATA(UART_0_BASE);
}
void sendStrig(char* s)
{
while(*s)
{
while( ALT_UP_RS232_CONTROL_WI_MSK & IORD_ALT_UP_RS232_CONTROL(UART_0_BASE) );
sendByte(*s++);
}
}
void sendData(uint8_t* data, uint16_t size)
{
uint16_t i;
for(i = 0; i < size; i++)
{
sendByte((char)*data++);
}
}
void sendOneByte(uint8_t data)
{
sendByte((char) data);
}
void sendLong(unsigned long long time){
time=time|0x0000010000000000;
sendOneByte((uint8_t)((time >> 40)&0xFF));
sendOneByte((uint8_t)((time >> 32)&0xFF));
sendOneByte((uint8_t)((time >> 24)&0xFF));
sendOneByte((uint8_t)((time >> 16)&0xFF));
sendOneByte((uint8_t)((time >> 8)&0xFF));
sendOneByte((uint8_t)(time&0xFF));
}