UP
This commit is contained in:
@@ -97,7 +97,7 @@ void SW_SPI_RWL(SW_Dev_Spi Dev, uint8_t *Read_Date, uint8_t *Write_Date, uint32_
|
||||
}
|
||||
|
||||
uint16_t SW_SPI_RW16(SW_Dev_Spi Dev, uint16_t Write_Date) {
|
||||
Data16 wdate16, rdate16;
|
||||
Data16_t wdate16, rdate16;
|
||||
wdate16.u16 = Write_Date;
|
||||
CS_ENABLE();
|
||||
if (Dev.ENDIAN) {
|
||||
@@ -112,7 +112,7 @@ uint16_t SW_SPI_RW16(SW_Dev_Spi Dev, uint16_t Write_Date) {
|
||||
}
|
||||
|
||||
void SW_SPI_RL16(SW_Dev_Spi Dev, uint16_t *Read_Date, uint32_t Len) {
|
||||
Data16 rdate16;
|
||||
Data16_t rdate16;
|
||||
CS_ENABLE();
|
||||
switch (Dev.ENDIAN) {
|
||||
case LTL:
|
||||
@@ -148,7 +148,7 @@ void SW_SPI_RL16(SW_Dev_Spi Dev, uint16_t *Read_Date, uint32_t Len) {
|
||||
}
|
||||
|
||||
void SW_SPI_WL16(SW_Dev_Spi Dev, uint16_t *Write_Date, uint32_t Len) {
|
||||
Data16 wdate16;
|
||||
Data16_t wdate16;
|
||||
CS_ENABLE();
|
||||
switch (Dev.ENDIAN) {
|
||||
case LTL:
|
||||
@@ -184,7 +184,7 @@ void SW_SPI_WL16(SW_Dev_Spi Dev, uint16_t *Write_Date, uint32_t Len) {
|
||||
}
|
||||
|
||||
void SW_SPI_RWL16(SW_Dev_Spi Dev, uint16_t *Read_Date, uint16_t *Write_Date, uint32_t Len) {
|
||||
Data16 wdate16, rdate16;
|
||||
Data16_t wdate16, rdate16;
|
||||
CS_ENABLE();
|
||||
switch (Dev.ENDIAN) {
|
||||
case LTL:
|
@@ -8,7 +8,7 @@
|
||||
#define STDIN_FILENO 0
|
||||
#define STDOUT_FILENO 1
|
||||
#define STDERR_FILENO 2
|
||||
|
||||
#ifdef HAL
|
||||
UART_HandleTypeDef *gHuart;
|
||||
|
||||
void RetargetInit(UART_HandleTypeDef *huart) {
|
||||
@@ -45,5 +45,5 @@ int _read(int fd, char *ptr, int len) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif //#if !defined(OS_USE_SEMIHOSTING)
|
@@ -1,31 +0,0 @@
|
||||
//
|
||||
// Created by lydxh on 2024/5/9.
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include "tool.h"
|
||||
|
||||
float Mapping(float val, float I_Min, float I_Max, float O_Min, float O_Max)
|
||||
{
|
||||
return(((val-I_Min)*((O_Max-O_Min)/(I_Max-I_Min)))+O_Min);
|
||||
}
|
||||
|
||||
void BufPrint(char *name,void *buf,unsigned char size,unsigned int len,unsigned char frame){
|
||||
printf("\n%s:\n",name);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if(i%frame==0&&i!=0) printf("\n");
|
||||
switch (size) {
|
||||
case 8:
|
||||
printf("%02x ",*((unsigned char*)buf + i));
|
||||
break;
|
||||
case 16:
|
||||
printf("%04x ",*((unsigned short *)buf + i));
|
||||
break;
|
||||
case 32:
|
||||
printf("%08x ",*((unsigned int *)buf + i));
|
||||
break;
|
||||
default:
|
||||
printf("未指定类型大小");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
45
lib/src/tool.cpp
Normal file
45
lib/src/tool.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Created by lydxh on 2024/5/9.
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include "tool.h"
|
||||
|
||||
float Mapping(float val, float I_Min, float I_Max, float O_Min, float O_Max) {
|
||||
return (((val - I_Min) * ((O_Max - O_Min) / (I_Max - I_Min))) + O_Min);
|
||||
}
|
||||
|
||||
void BufPrint(char *name, void *buf, Type_t type, unsigned int len, unsigned char frame) {
|
||||
printf("\n%s:\n", name);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (i % frame == 0 && i != 0) printf("\n");
|
||||
switch (type) {
|
||||
case U8:
|
||||
printf("%02X ", *((unsigned char *) buf + i));
|
||||
break;
|
||||
case U16:
|
||||
printf("%04X ", *((unsigned short *) buf + i));
|
||||
break;
|
||||
case U32:
|
||||
printf("%08X ", *((unsigned int *) buf + i));
|
||||
break;
|
||||
case CHAR:
|
||||
printf("%c ", *((char *) buf + i));
|
||||
break;
|
||||
case SHORT:
|
||||
printf("%d ", *((short *) buf + i));
|
||||
break;
|
||||
case INT:
|
||||
printf("%d ", *((int *) buf + i));
|
||||
break;
|
||||
case FLOAT:
|
||||
printf("%0.2f ", *((float *) buf + i));
|
||||
break;
|
||||
case DOUBLE:
|
||||
printf("%0.2f ", *((double *) buf + i));
|
||||
break;
|
||||
default:
|
||||
printf("未指定类型大小:%p", buf);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
Reference in New Issue
Block a user