Skip to content

Commit 9a8249b

Browse files
authored
【BSP】CY8CKIT-062S2-43012 (#6237)
英飞凌 CY8CKIT-062S2-43012 BSP
1 parent 38154c4 commit 9a8249b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+12860
-547
lines changed

.github/workflows/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
- {RTT_BSP: "at91/at91sam9g45", RTT_TOOL_CHAIN: "sourcery-arm"}
3838
- {RTT_BSP: "at91/at91sam9260", RTT_TOOL_CHAIN: "sourcery-arm"}
3939
- {RTT_BSP: "allwinner_tina", RTT_TOOL_CHAIN: "sourcery-arm"}
40+
- {RTT_BSP: "cypress/psoc6-cy8cproto-4343w", RTT_TOOL_CHAIN: "sourcery-arm"}
4041
- {RTT_BSP: "ft32/ft32f072xb-starter", RTT_TOOL_CHAIN: "sourcery-arm"}
4142
- {RTT_BSP: "gd32/arm/gd32103c-eval", RTT_TOOL_CHAIN: "sourcery-arm"}
4243
- {RTT_BSP: "gd32/arm/gd32105c-eval", RTT_TOOL_CHAIN: "sourcery-arm"}

bsp/cypress/libraries/HAL_Drivers/SConscript

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ if GetDepend(['BSP_USING_SPI']):
3838
if GetDepend(['BSP_USING_ADC']):
3939
src += ['drv_adc.c']
4040

41+
if GetDepend(['BSP_USING_USBD']):
42+
src += ['drv_usbd.c']
43+
4144
if GetDepend('BSP_USING_RTC'):
4245
src += ['drv_rtc.c']
4346

@@ -46,6 +49,9 @@ if GetDepend('BSP_USING_ON_CHIP_FLASH'):
4649

4750
if GetDepend(['RT_USING_WDT']):
4851
src += ['drv_wdt.c']
52+
53+
if GetDepend(['RT_USING_DAC']):
54+
src += ['drv_dac.c']
4955

5056
if GetDepend(['BSP_USING_TIM']):
5157
src += ['drv_hwtimer.c']
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
/*
2+
* Copyright (c) 2006-2022, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2022-07-28 rtthread qiu first version
9+
*/
10+
#include "drv_dac.h"
11+
#include "drv_common.h"
12+
#include <rtthread.h>
13+
14+
#if defined(BSP_USING_DAC1) || defined(BSP_USING_DAC2)
15+
16+
#define LOG_TAG "drv.dac"
17+
#include <drv_log.h>
18+
19+
struct cyp_dac
20+
{
21+
cy_stc_csdidac_config_t cyhal_dac_device;
22+
struct rt_dac_device cyp_dac_device;
23+
char *name;
24+
};
25+
26+
static struct cyp_dac dac_config[] =
27+
{
28+
#ifdef BSP_USING_DAC1
29+
DAC1_CONFIG,
30+
#endif
31+
#ifdef BSP_USING_DAC2
32+
DAC2_CONFIG,
33+
#endif
34+
35+
};
36+
37+
/*get dac channel*/
38+
static rt_uint32_t cyp_dac_get_channel(rt_uint32_t channel)
39+
{
40+
rt_uint32_t cyp_dac_channel = 0;
41+
42+
switch (channel)
43+
{
44+
case 1:
45+
cyp_dac_channel = CY_CSDIDAC_A;
46+
break;
47+
case 2:
48+
cyp_dac_channel = CY_CSDIDAC_B;
49+
break;
50+
default:
51+
RT_ASSERT(0);
52+
break;
53+
}
54+
55+
return cyp_dac_channel;
56+
}
57+
58+
struct cyp_dac cyp_adc_obj[sizeof(dac_config) / sizeof(dac_config[0])];
59+
60+
cy_stc_csdidac_context_t csdidac_context;
61+
62+
/*dac device enable*/
63+
static rt_err_t cyp_dac_enabled(struct rt_dac_device *device, rt_uint32_t channel)
64+
{
65+
cy_rslt_t result;
66+
67+
rt_uint32_t cyp_channel;
68+
69+
RT_ASSERT(device != RT_NULL);
70+
71+
cyhal_dac_t *dac_device;
72+
73+
dac_device = device->parent.user_data;
74+
75+
/* get current dac channel*/
76+
cyp_channel = cyp_dac_get_channel(channel);
77+
78+
/*DAC device init*/
79+
result = Cy_CSDIDAC_Init(&CSDIDAC_csdidac_config, &csdidac_context);
80+
81+
if (result != RT_EOK)
82+
{
83+
LOG_E("Cy_CSDIDAC_Init fail = %d\n", result);
84+
return -RT_ENOSYS;
85+
}
86+
87+
return RT_EOK;
88+
}
89+
90+
/*dac device disable*/
91+
static rt_err_t cyp_dac_disable(struct rt_dac_device *device, rt_uint32_t channel)
92+
{
93+
rt_uint32_t cyp_channel;
94+
95+
cy_rslt_t result;
96+
97+
RT_ASSERT(device != RT_NULL);
98+
99+
cyhal_dac_t *dac_device;
100+
101+
dac_device = device->parent.user_data;
102+
103+
cyp_channel = cyp_dac_get_channel(channel);
104+
105+
/*DAC free device*/
106+
result = Cy_CSDIDAC_OutputDisable(cyp_channel, &csdidac_context);
107+
if (result != RT_EOK)
108+
{
109+
LOG_E("DAC Outputdisable failed. Error: %d\n", result);
110+
return -RT_ENOSYS;
111+
}
112+
return RT_EOK;
113+
}
114+
115+
/*set dac output value*/
116+
static rt_err_t cyp_adc_convert(struct rt_dac_device *device, rt_uint32_t channel, rt_uint32_t *value)
117+
{
118+
RT_ASSERT(device != RT_NULL);
119+
120+
cy_rslt_t result;
121+
122+
rt_uint32_t cyp_channel;
123+
124+
cyp_channel = cyp_dac_get_channel(channel);
125+
126+
result = Cy_CSDIDAC_OutputEnable(cyp_channel, *value, &csdidac_context);
127+
if (result != RT_EOK)
128+
{
129+
LOG_E("DAC channel initialization failed. Error: %d\n", result);
130+
return -RT_ENOSYS;
131+
}
132+
133+
return RT_EOK;
134+
}
135+
136+
static const struct rt_dac_ops cyp_dac_ops =
137+
{
138+
.disabled = cyp_dac_disable,
139+
.enabled = cyp_dac_enabled,
140+
.convert = cyp_adc_convert,
141+
};
142+
143+
/*dac device init*/
144+
static int rt_hw_dac_init(void)
145+
{
146+
int result = RT_EOK;
147+
148+
/* save dac name */
149+
char name_buf[5] = {'d', 'a', 'c', '0', 0};
150+
151+
int i = 0;
152+
153+
i = sizeof(dac_config) / sizeof(dac_config[0]);
154+
155+
for (i = 0; i < sizeof(dac_config) / sizeof(dac_config[0]); i++)
156+
{
157+
158+
#ifdef BSP_USING_DAC1
159+
name_buf[3] = '1';
160+
#endif
161+
162+
#ifdef BSP_USING_DAC2
163+
name_buf[3] = '2';
164+
#endif
165+
/* register DAC device */
166+
if (rt_hw_dac_register(&cyp_adc_obj[i].cyp_dac_device, name_buf, &cyp_dac_ops, RT_NULL) == RT_EOK)
167+
{
168+
LOG_E("dac device register success\n");
169+
}
170+
else
171+
{
172+
LOG_E("dac device register fail\n");
173+
result = -RT_ERROR;
174+
}
175+
}
176+
return result;
177+
}
178+
179+
INIT_BOARD_EXPORT(rt_hw_dac_init);
180+
181+
#endif /* BSP_USING_DAC1 /BSP_USING_DAC2 */
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (c) 2006-2022, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2022-07-28 rtthread qiu first version
9+
*/
10+
#ifndef __DRV__DAC_H__
11+
#define __DRV__DAC_H__
12+
#include "rtconfig.h"
13+
#include "cycfg.h"
14+
#include <rtthread.h>
15+
#include "cy_csdidac.h"
16+
#include "cycfg_peripherals.h"
17+
18+
static const cy_stc_csdidac_pin_t CSDIDAC_csdidac_a_pin =
19+
{
20+
.ioPcPtr = GPIO_PRT10,
21+
.pin = 0u,
22+
};
23+
static const cy_stc_csdidac_pin_t CSDIDAC_csdidac_b_pin =
24+
{
25+
.ioPcPtr = GPIO_PRT10,
26+
.pin = 0u,
27+
};
28+
29+
const cy_stc_csdidac_config_t CSDIDAC_csdidac_config =
30+
{
31+
.base = CSD0,
32+
.csdCxtPtr = &cy_csd_0_context,
33+
.configA = CY_CSDIDAC_GPIO,
34+
.configB = CY_CSDIDAC_GPIO,
35+
.ptrPinA = (const cy_stc_csdidac_pin_t *)&CSDIDAC_csdidac_a_pin,
36+
.ptrPinB = (const cy_stc_csdidac_pin_t *)&CSDIDAC_csdidac_b_pin,
37+
.cpuClk = 100000000u,
38+
.csdInitTime = 25u,
39+
};
40+
41+
#ifdef BSP_USING_DAC1
42+
#ifndef DAC1_CONFIG
43+
#define DAC1_CONFIG \
44+
{ \
45+
.name = "dac1", \
46+
}
47+
#endif /* DAC1_CONFIG */
48+
#endif /*BSP_USING_DAC2*/
49+
50+
#ifdef BSP_USING_DAC2
51+
#ifndef DAC2_CONFIG
52+
#define DAC2_CONFIG \
53+
{ \
54+
.name = "dac2", \
55+
}
56+
#endif /* DAC2_CONFIG */
57+
#endif /*BSP_USING_DAC2*/
58+
59+
#endif /*__DRV__DAC_H__*/

bsp/cypress/libraries/HAL_Drivers/drv_gpio.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#include <rtdevice.h>
1616
#include "drv_common.h"
1717

18-
#include "cy_retarget_io.h"
19-
#include "cyhal_gpio.h"
2018
#include "cyhal_irq_psoc.h"
2119

2220
#define GPIO_INTERRUPT_PRIORITY (7u)

bsp/cypress/libraries/HAL_Drivers/drv_uart.c

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,51 +12,50 @@
1212
#include "drv_uart.h"
1313

1414
#include "uart_config.h"
15-
#include "cy_retarget_io.h"
1615
#include "cyhal_scb_common.h"
1716

1817
enum
1918
{
20-
#ifdef BSP_USING_UART0
19+
#ifdef BSP_USING_UART0
2120
UART0_INDEX,
22-
#endif
23-
#ifdef BSP_USING_UART1
21+
#endif
22+
#ifdef BSP_USING_UART1
2423
UART1_INDEX,
25-
#endif
26-
#ifdef BSP_USING_UART2
24+
#endif
25+
#ifdef BSP_USING_UART2
2726
UART2_INDEX,
28-
#endif
29-
#ifdef BSP_USING_UART3
27+
#endif
28+
#ifdef BSP_USING_UART3
3029
UART3_INDEX,
31-
#endif
32-
#ifdef BSP_USING_UART4
30+
#endif
31+
#ifdef BSP_USING_UART4
3332
UART4_INDEX,
34-
#endif
35-
#ifdef BSP_USING_UART5
33+
#endif
34+
#ifdef BSP_USING_UART5
3635
UART5_INDEX,
37-
#endif
36+
#endif
3837
};
3938

4039
static struct ifx_uart_config uart_config[] =
4140
{
42-
#ifdef BSP_USING_UART0
41+
#ifdef BSP_USING_UART0
4342
UART0_CONFIG,
44-
#endif
45-
#ifdef BSP_USING_UART1
43+
#endif
44+
#ifdef BSP_USING_UART1
4645
UART1_CONFIG,
47-
#endif
48-
#ifdef BSP_USING_UART2
46+
#endif
47+
#ifdef BSP_USING_UART2
4948
UART2_CONFIG,
50-
#endif
51-
#ifdef BSP_USING_UART3
49+
#endif
50+
#ifdef BSP_USING_UART3
5251
UART3_CONFIG,
53-
#endif
54-
#ifdef BSP_USING_UART4
52+
#endif
53+
#ifdef BSP_USING_UART4
5554
UART4_CONFIG,
56-
#endif
57-
#ifdef BSP_USING_UART5
55+
#endif
56+
#ifdef BSP_USING_UART5
5857
UART5_CONFIG,
59-
#endif
58+
#endif
6059
};
6160

6261
static struct ifx_uart uart_obj[sizeof(uart_config) / sizeof(uart_config[0])] = {0};
@@ -196,20 +195,20 @@ static rt_err_t ifx_control(struct rt_serial_device *serial, int cmd, void *arg)
196195

197196
switch (cmd)
198197
{
199-
case RT_DEVICE_CTRL_CLR_INT:
198+
case RT_DEVICE_CTRL_CLR_INT:
200199

201-
break;
200+
break;
202201

203-
case RT_DEVICE_CTRL_SET_INT:
204-
/* Unmasking only the RX fifo not empty interrupt bit */
205-
uart->config->usart_x->INTR_RX_MASK = SCB_INTR_RX_MASK_NOT_EMPTY_Msk;
202+
case RT_DEVICE_CTRL_SET_INT:
203+
/* Unmasking only the RX fifo not empty interrupt bit */
204+
uart->config->usart_x->INTR_RX_MASK = SCB_INTR_RX_MASK_NOT_EMPTY_Msk;
206205

207-
/* Interrupt Settings for UART */
208-
Cy_SysInt_Init(uart->config->UART_SCB_IRQ_cfg, uart->config->userIsr);
206+
/* Interrupt Settings for UART */
207+
Cy_SysInt_Init(uart->config->UART_SCB_IRQ_cfg, uart->config->userIsr);
209208

210-
/* Enable the interrupt */
211-
NVIC_EnableIRQ(uart->config->intrSrc);
212-
break;
209+
/* Enable the interrupt */
210+
NVIC_EnableIRQ(uart->config->intrSrc);
211+
break;
213212
}
214213

215214
return (RT_EOK);

bsp/cypress/libraries/HAL_Drivers/drv_uart.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <rtdevice.h>
1616

1717
#include "board.h"
18-
#include "cycfg_peripherals.h"
1918

2019
#define uart_isr_callback(name) name##_isr_callback
2120

0 commit comments

Comments
 (0)