Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiancetai
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈家乐
jiancetai
Commits
9e4aee22
Commit
9e4aee22
authored
Mar 10, 2025
by
梁百峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat:增加与esp32通讯串口
parent
302a192b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
149 additions
and
17 deletions
+149
-17
Barcode_Scanner.c
YueJin_test_bench/source/Appliciation/Barcode_Scanner.c
+124
-3
Barcode_Scanner.h
YueJin_test_bench/source/Appliciation/Barcode_Scanner.h
+2
-0
RTE_GPIO.h
YueJin_test_bench/source/Appliciation/RTE_GPIO.h
+3
-3
GPIO.c
YueJin_test_bench/source/Driver/GPIO/GPIO.c
+7
-7
UART.h
YueJin_test_bench/source/Driver/UART/UART.h
+1
-1
init.c
YueJin_test_bench/source/System/init.c
+9
-0
interrupts.h
YueJin_test_bench/source/System/interrupts.h
+3
-3
No files found.
YueJin_test_bench/source/Appliciation/Barcode_Scanner.c
View file @
9e4aee22
...
...
@@ -24,8 +24,9 @@ uint8_t BarCode1[256] = {0};
uint32_t
readNum
=
0
;
uint32_t
readNum1
=
0
;
static
uint32_t
Protocol_UartRead
(
uint8_t
*
pData
,
uint32_t
len
);
static
uint32_t
Protocol_UartRead1
(
uint8_t
*
pData
,
uint32_t
len
);
static
uint32_t
Protocol_UartRead
(
uint8_t
*
pData
,
uint32_t
len
);
//485
static
uint32_t
Protocol_UartRead1
(
uint8_t
*
pData
,
uint32_t
len
);
//扫码枪
static
uint32_t
Protocol_UartRead2
(
uint8_t
*
pData
,
uint32_t
len
);
//esp32
uint8_t
nowdata
[
4
];
uint8_t
lastdata
[
4
];
uint8_t
checkresult
;
...
...
@@ -419,6 +420,27 @@ void UART_Put1(uint32_t Value)
}
return
;
}
void
UART_Put2
(
uint32_t
Value
)
{
uint32_t
nextPos
=
0u
;
nextPos
=
(
UARTRxBuf
.
write_pos
+
1
)
%
UART_RX_MAX_DEPTH
;
if
(
nextPos
==
UARTRxBuf
.
read_pos
)
{
//队列已满,无法插入队列
// UARTRxBuf.write_pos = 0;
// RS485_TX_finish = 0;
}
else
{
UARTRxBuf
.
Rx_Buffer
[
UARTRxBuf
.
write_pos
]
=
Value
;
UARTRxBuf
.
write_pos
=
(
UARTRxBuf
.
write_pos
+
1
)
%
UART_RX_MAX_DEPTH
;
}
RS485_send_time
=
0
;
return
;
}
void
Recv_Byte
(
void
)
{
int
i
=
0
;
...
...
@@ -608,4 +630,103 @@ static uint32_t Protocol_UartRead1(uint8_t *pData, uint32_t len)
}
return
i
;
}
\ No newline at end of file
}
void
Recv_Byte2
(
void
)
{
int
i
=
0
;
int
j
=
0
;
uint32_t
len
;
readNum1
=
Protocol_UartRead2
(
mDataBufPtr1
+
mDataBufLen1
,
1024
-
mDataBufLen1
);
// if (readNum1 > 0)
// {
// BarCodeDataGet();
// }
if
(
readNum1
>
0
)
{
mDataBufLen1
+=
readNum1
;
while
(
mDataBufLen1
)
{
memset
(
BarCode1
,
0
,
sizeof
(
BarCode1
));
for
(
i
=
0
;
i
<
mDataBufLen1
;
i
++
)
{
// if((mDataBufPtr1[i] == 0x0 ) && (mDataBufPtr1[i - 1] == 0x0))
// {
// if( i < 1)
// {
// break;
// }
// memset(BarCode1, 0, sizeof(BarCode1));
for
(
j
=
0
;
j
<
mDataBufLen1
;
j
++
)
{
BarCode1
[
j
]
=
mDataBufPtr1
[
j
];
}
// }
}
// 解析协议
len
=
mDataBufLen1
;
if
(
(
len
>
0
)
&&
(
len
<
mDataBufLen1
)
)
{
// 将未解析的数据移到头部
// Move unparsed data to the head
memcpy
(
mDataBufPtr1
,
mDataBufPtr1
+
len
,
mDataBufLen1
-
len
);
// memcpy(nowdata,mDataBufPtr + len,len);
// datacheck();
}
mDataBufLen1
-=
len
;
}
BarCodeDataGet
();
}
}
static
uint32_t
Protocol_UartRead2
(
uint8_t
*
pData
,
uint32_t
len
)
{
uint32_t
i
=
0
;
uint32_t
DataLen
=
0u
;
uint32_t
ReadLen
=
0u
;
if
(
UARTRxBuf1
.
write_pos
==
UARTRxBuf1
.
read_pos
)
{
return
0
;
//队列空
}
if
(
UARTRxBuf1
.
write_pos
>
UARTRxBuf1
.
read_pos
)
{
DataLen
=
UARTRxBuf1
.
write_pos
-
UARTRxBuf1
.
read_pos
;
}
else
{
DataLen
=
UART_RX_MAX_DEPTH
-
(
UARTRxBuf1
.
read_pos
-
UARTRxBuf1
.
write_pos
);
}
if
(
len
>
DataLen
)
{
ReadLen
=
DataLen
;
}
else
{
ReadLen
=
len
;
}
for
(
i
=
0u
;
i
<
ReadLen
;
i
++
)
{
pData
[
i
]
=
UARTRxBuf1
.
Rx_Buffer
[
UARTRxBuf1
.
read_pos
];
UARTRxBuf1
.
read_pos
=
(
UARTRxBuf1
.
read_pos
+
1
)
%
UART_RX_MAX_DEPTH
;
}
return
i
;
}
YueJin_test_bench/source/Appliciation/Barcode_Scanner.h
View file @
9e4aee22
...
...
@@ -6,8 +6,10 @@
#include "R485_Communication_Matrix.h"
void
UART_Put
(
uint32_t
Value
);
void
UART_Put1
(
uint32_t
Value
);
void
UART_Put2
(
uint32_t
Value
);
void
Recv_Byte
(
void
);
void
Recv_Byte1
(
void
);
void
Recv_Byte2
(
void
);
extern
uint8_t
GetDataCompare
(
void
);
extern
uint32_t
readNum
;
extern
uint8_t
BarCode
[
256
];
...
...
YueJin_test_bench/source/Appliciation/RTE_GPIO.h
View file @
9e4aee22
...
...
@@ -33,9 +33,9 @@
#define SW9 GPIO_IN_PORT09_PIN00
#define SW10 GPIO_IN_PORT10_PIN06
#define FUEL_RES_1 GPIO_OUT_PORT00_PIN13
//
#define FUEL_RES_1 GPIO_OUT_PORT00_PIN13
// #define FUEL_RES_2 GPIO_OUT_PORT08_PIN12
#define FUEL_RES_3 GPIO_OUT_PORT08_PIN10
//
#define FUEL_RES_3 GPIO_OUT_PORT08_PIN10
// #define FUEL_RES_4 GPIO_OUT_PORT08_PIN11
#define LINE_OUT_CHARGER GPIO_OUT_PORT10_PIN06//
...
...
@@ -100,7 +100,7 @@
#define LINE_OUT_NEG_09 GPIO_OUT_PORT10_PIN04
#define LINE_OUT_NEG_10 GPIO_OUT_PORT00_PIN08
#define LINE_FUEL_RES01 GPIO_OUT_PORT00_PIN13
//
#define LINE_FUEL_RES01 GPIO_OUT_PORT00_PIN13
#define LINE_FUEL_RES03 GPIO_OUT_PORT08_PIN10
...
...
YueJin_test_bench/source/Driver/GPIO/GPIO.c
View file @
9e4aee22
...
...
@@ -46,9 +46,9 @@ const uint16_t g_u16GPIOConfigArray[56U][2U] =
{
0x0620u
,
0x0600u
},
{
0x0000u
,
0x0000u
},
{
0x0000u
,
0x0000u
},
{
0x
063Cu
,
0x0
630u
},
{
0x
1
A6Bu
,
0x1A6Fu
},
{
0x
79C3u
,
0x7
9CFu
},
{
0x
663Cu
,
0x4
630u
},
{
0x
3
A6Bu
,
0x1A6Fu
},
{
0x
19C3u
,
0x3
9CFu
},
{
0x0000u
,
0x0000u
},
{
0x0000u
,
0x0000u
},
{
0x0000u
,
0x0000u
},
...
...
@@ -78,7 +78,7 @@ const uint16_t g_u16GPIOConfigArray[56U][2U] =
{
0x0000u
,
0x0000u
},
{
0x0002u
,
0x0200u
},
{
0x1800u
,
0x1800u
},
{
0x0
A60u
,
0x0A
60u
},
{
0x0
E60u
,
0x0E
60u
},
{
0xE7FFu
,
0xE7FFu
},
{
0x0000u
,
0x0000u
},
{
0x0000u
,
0x0000u
},
...
...
@@ -87,12 +87,12 @@ const uint16_t g_u16GPIOConfigArray[56U][2U] =
{
0x0000u
,
0x0000u
},
{
0x0000u
,
0x0000u
},
{
0x0000u
,
0x0000u
},
{
0x0010u
,
0x0000u
},
{
0x0000u
,
0x0000u
},
{
0x0000u
,
0x0000u
},
{
0x0000u
,
0x0000u
},
{
0x0010u
,
0x0000u
},
{
0x00FFu
,
0x00FFu
},
{
0x0200u
,
0x0000u
},
{
0x
C07
Fu
,
0xC07Fu
},
{
0x
03F
Fu
,
0xC07Fu
},
{
0xFFFFu
,
0xFFFFu
},
};
static
void
GPIO_PIN_Init
(
GPIO_Config_Mode_en_t
enGPIOConfigMode
)
...
...
YueJin_test_bench/source/Driver/UART/UART.h
View file @
9e4aee22
...
...
@@ -10,7 +10,7 @@
/**根据实际应用调整buf大小**/
#define UART_30_SEND_MAX 512UL
#define UART_31_SEND_MAX 512UL
#define UART_32_SEND_MAX
1
UL
#define UART_32_SEND_MAX
512
UL
#define UART_33_SEND_MAX 1UL
/***************************************************************/
...
...
YueJin_test_bench/source/System/init.c
View file @
9e4aee22
...
...
@@ -104,6 +104,15 @@ void Sys_Startup_Init(void)
loc_config
.
pfnUARTErrHandleCallBack
=
0
;
loc_config
.
pfnUARTReadMsgCallBack
=
UART_Put1
;
UART_Init
(
UART_RLIN31
,
&
loc_config
);
loc_config
.
enUARTLINMode
=
MODE_UART
;
loc_config
.
u32UARTbps
=
115200
;
loc_config
.
enUARTOrder
=
UART_LSB
;
loc_config
.
en2UARTParity
=
UART_PARITY_DISABLE
;
loc_config
.
en2UARTPolarity
=
UART_POLARITY_NORMAL
;
loc_config
.
pfnUARTConfirmCallBack
=
0
;
loc_config
.
pfnUARTErrHandleCallBack
=
0
;
loc_config
.
pfnUARTReadMsgCallBack
=
UART_Put2
;
UART_Init
(
UART_RLIN32
,
&
loc_config
);
LINE_OUT_NEG_01
=
1
;
LINE_OUT_NEG_02
=
1
;
LINE_OUT_NEG_03
=
1
;
...
...
YueJin_test_bench/source/System/interrupts.h
View file @
9e4aee22
...
...
@@ -939,17 +939,17 @@
#define INTRLIN32_ENABLE 0x00000000u
#endif
//
#define INTRLIN32UR0_ENABLE (IRQ_TABLE_START + 0x00000294u)
#define INTRLIN32UR0_ENABLE (IRQ_TABLE_START + 0x00000294u)
#ifndef INTRLIN32UR0_ENABLE
#define INTRLIN32UR0_ENABLE 0x00000000u
#endif
//
#define INTRLIN32UR1_ENABLE (IRQ_TABLE_START + 0x00000298u)
#define INTRLIN32UR1_ENABLE (IRQ_TABLE_START + 0x00000298u)
#ifndef INTRLIN32UR1_ENABLE
#define INTRLIN32UR1_ENABLE 0x00000000u
#endif
//
#define INTRLIN32UR2_ENABLE (IRQ_TABLE_START + 0x0000029Cu)
#define INTRLIN32UR2_ENABLE (IRQ_TABLE_START + 0x0000029Cu)
#ifndef INTRLIN32UR2_ENABLE
#define INTRLIN32UR2_ENABLE 0x00000000u
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment