first commit

This commit is contained in:
2024-10-10 00:45:09 +06:00
commit e56944bbcd
89 changed files with 31498 additions and 0 deletions

39
include/README Normal file
View File

@@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

17
include/uart.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef UART_H
#define UART_H
#include <stdint.h>
// Macro definitions
#define APB1_CLOCK (FUNCONF_SYSTEM_CORE_CLOCK / 2) // APB1 is divided by 2
#define UART_BRR_APB1 \
(((APB1_CLOCK) + (UART_BAUD_RATE / 2)) / (UART_BAUD_RATE)) // USART2
#define UART_BRR_APB2 \
(((FUNCONF_SYSTEM_CORE_CLOCK) + (UART_BAUD_RATE / 2)) / \
(UART_BAUD_RATE)) // USART1
// Function prototypes
void setup_uart(int uart_brr);
#endif // UART_H

24
include/w5500.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef W5500_H
#define W5500_H
#include <stdint.h>
// Sets the CS pin low
void W5500_Select(void);
// Sets the CS pin high
void W5500_Unselect(void);
// Reads a byte via SPI
uint8_t W5500_ReadByte(void);
// Writes a byte via SPI
void W5500_WriteByte(uint8_t byte);
// Reads multiple bytes via SPI
void W5500_ReadBuff(uint8_t* buff, uint16_t len);
// Writes multiple bytes via SPI
void W5500_WriteBuff(uint8_t* buff, uint16_t len);
#endif // W5500_H