Skip to content

Commit 33ca061

Browse files
vmedcyArto Kinnunen
authored andcommitted
PSOC6: add psoc6csp asset with Cypress HAL implementation
PSoC 6 Chip Support Package provides hardware abstraction layer for Cypress PSoC 6 device peripherals.
1 parent 471f0ab commit 33ca061

File tree

106 files changed

+34612
-0
lines changed

Some content is hidden

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

106 files changed

+34612
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/***************************************************************************//**
2+
* \file cyabs_rtos_impl.h
3+
*
4+
* \brief
5+
* Internal definitions for RTOS abstraction layer
6+
*
7+
********************************************************************************
8+
* \copyright
9+
* Copyright 2019 Cypress Semiconductor Corporation
10+
* SPDX-License-Identifier: Apache-2.0
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License");
13+
* you may not use this file except in compliance with the License.
14+
* You may obtain a copy of the License at
15+
*
16+
* http://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* Unless required by applicable law or agreed to in writing, software
19+
* distributed under the License is distributed on an "AS IS" BASIS,
20+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21+
* See the License for the specific language governing permissions and
22+
* limitations under the License.
23+
*/
24+
25+
26+
#ifndef INCLUDED_CYABS_RTOS_IMPL_H_
27+
#define INCLUDED_CYABS_RTOS_IMPL_H_
28+
29+
#include "cmsis_os2.h"
30+
#include "rtx_os.h"
31+
32+
#ifdef __cplusplus
33+
extern "C"
34+
{
35+
#endif
36+
37+
/******************************************************
38+
* Constants
39+
******************************************************/
40+
#define CY_RTOS_MIN_STACK_SIZE 300 /** Minimum stack size */
41+
#define CY_RTOS_ALIGNMENT_MASK 0x00000007UL /** Checks for 8-bit alignement */
42+
43+
44+
/******************************************************
45+
* Type Definitions
46+
******************************************************/
47+
48+
/* RTOS thread priority */
49+
typedef enum
50+
{
51+
CY_RTOS_PRIORITY_MIN = osPriorityNone,
52+
CY_RTOS_PRIORITY_LOW = osPriorityLow,
53+
CY_RTOS_PRIORITY_BELOWNORMAL = osPriorityBelowNormal,
54+
CY_RTOS_PRIORITY_NORMAL = osPriorityNormal,
55+
CY_RTOS_PRIORITY_ABOVENORMAL = osPriorityAboveNormal,
56+
CY_RTOS_PRIORITY_HIGH = osPriorityHigh,
57+
CY_RTOS_PRIORITY_REALTIME = osPriorityRealtime,
58+
CY_RTOS_PRIORITY_MAX = osPriorityRealtime7
59+
} cy_thread_priority_t ;
60+
61+
typedef osThreadId_t cy_thread_t; /** CMSIS definition of a thread handle */
62+
typedef uint32_t cy_thread_arg_t; /** Argument passed to the entry function of a thread */
63+
typedef osMutexId_t cy_mutex_t; /** CMSIS definition of a mutex */
64+
typedef osSemaphoreId_t cy_semaphore_t; /** CMSIS definition of a semaphore */
65+
typedef osEventFlagsId_t cy_event_t; /** CMSIS definition of an event */
66+
typedef osMessageQueueId_t cy_queue_t; /** CMSIS definition of a message queue */
67+
typedef osTimerId_t cy_timer_t; /** CMSIS definition of a timer */
68+
typedef uint32_t cy_timer_callback_arg_t; /** Argument passed to the timer callback function */
69+
typedef uint32_t cy_time_t; /** Time in milliseconds */
70+
typedef osStatus_t cy_rtos_error_t; /** CMSIS definition of a error status */
71+
72+
#ifdef __cplusplus
73+
} /* extern "C" */
74+
#endif
75+
#endif /* ifndef INCLUDED_CYABS_RTOS_IMPL_H_ */
76+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/***************************************************************************//**
2+
* \file cyabs_chip.h
3+
*
4+
* \brief
5+
* Basic abstraction layer for dealing with chips containing a Cypress MCU. This
6+
* API provides convenience methods for initializing and manipulating different
7+
* hardware peripherals. Depending on the specific chip being used, not all
8+
* features may be supported.
9+
*
10+
********************************************************************************
11+
* \copyright
12+
* Copyright 2018-2019 Cypress Semiconductor Corporation
13+
* SPDX-License-Identifier: Apache-2.0
14+
*
15+
* Licensed under the Apache License, Version 2.0 (the "License");
16+
* you may not use this file except in compliance with the License.
17+
* You may obtain a copy of the License at
18+
*
19+
* http://www.apache.org/licenses/LICENSE-2.0
20+
*
21+
* Unless required by applicable law or agreed to in writing, software
22+
* distributed under the License is distributed on an "AS IS" BASIS,
23+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24+
* See the License for the specific language governing permissions and
25+
* limitations under the License.
26+
*******************************************************************************/
27+
28+
#pragma once
29+
30+
#include "cyhal.h"
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/***************************************************************************//**
2+
* \file cyabs_fs.h
3+
*
4+
* \brief
5+
* Basic file system abstraction layer. This API provides convenience methods
6+
* for reading and writing values.
7+
*
8+
********************************************************************************
9+
* \copyright
10+
* Copyright 2018-2019 Cypress Semiconductor Corporation
11+
* SPDX-License-Identifier: Apache-2.0
12+
*
13+
* Licensed under the Apache License, Version 2.0 (the "License");
14+
* you may not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* http://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*******************************************************************************/
25+
26+
/**
27+
* \addtogroup group_abstraction_fs File system abstraction
28+
* \ingroup group_abstraction
29+
* \{
30+
* Basic file system abstraction layer. This API provides convenience methods
31+
* for reading and writing values.
32+
*
33+
* \defgroup group_abstraction_fs_macros Macros
34+
* \defgroup group_abstraction_fs_data_structures Data Structures
35+
* \defgroup group_abstraction_fs_functions Functions
36+
*/
37+
38+
#pragma once
39+
40+
#include <stdint.h>
41+
#include <stdbool.h>
42+
#include "cy_result.h"
43+
44+
#if defined(__cplusplus)
45+
extern "C" {
46+
#endif
47+
48+
/**
49+
* \addtogroup group_abstraction_fs_macros
50+
* \{
51+
*/
52+
53+
#define CY_O_RDONLY (1 << 0) /**< TODO */
54+
#define CY_O_WRONLY (1 << 1) /**< TODO */
55+
#define CY_O_RDWR (1 << 2) /**< TODO */
56+
#define CY_O_APPEND (1 << 3) /**< TODO */
57+
#define CY_O_CREAT (1 << 4) /**< TODO */
58+
59+
/** \} group_abstraction_fs_macros */
60+
61+
/**
62+
* \addtogroup group_abstraction_fs_data_structures
63+
* \{
64+
*/
65+
66+
typedef uint32_t cy_handle_t; /**< Resource handle */
67+
68+
/** \} group_abstraction_fs_data_structures */
69+
70+
71+
/**
72+
* \addtogroup group_abstraction_fs_functions
73+
* \{
74+
*/
75+
76+
/**
77+
* \brief open or create a file and return a handle
78+
* \param path the path name of the file to open
79+
* \param oflag the mode to use when opening the file
80+
* \param handle pointer to location re receive handle
81+
* \returns CY_RSLT_SUCCESS if successful, otherwise error code
82+
*/
83+
cy_rslt_t cy_fs_open(const char *path, uint32_t oflag, cy_handle_t *handle) ;
84+
85+
/**
86+
* \brief close an open file
87+
* \param handle a file handle to an open file
88+
* \returns CY_RSLT_SUCCESS if successful, otherwise error code
89+
*/
90+
cy_rslt_t cy_fs_close(cy_handle_t handle) ;
91+
92+
/**
93+
* \brief read data from a file
94+
* \param handle a file handle open for reading or read/write
95+
* \param buf the buffer for the read data
96+
* \param nbyte the size of the buffer in bytes, the number of bytes read on return
97+
* \returns CY_RSLT_SUCCESS if successful, otherwise error code
98+
*/
99+
cy_rslt_t cy_fs_read(cy_handle_t handle, void *buf, size_t *nbyte) ;
100+
101+
/**
102+
* \brief write data to a file
103+
* \param handle a file handle open for writing or read/write
104+
* \param buf the buffer for the data to write
105+
* \param nbyte the size of the buffer in bytes, the number of bytes written on return
106+
* \returns CY_RSLT_SUCCESS if successful, otherwise error code
107+
*/
108+
cy_rslt_t cy_fs_write(cy_handle_t handle, const void *buf, size_t *nbyte) ;
109+
110+
/** \} group_abstraction_fs_functions */
111+
112+
#if defined(__cplusplus)
113+
}
114+
#endif
115+
116+
/** \} group_abstraction_fs */
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
/***************************************************************************//**
2+
* \file cyabs_resource.h
3+
*
4+
* \brief
5+
* Basic abstraction layer for dealing with resources.
6+
*
7+
********************************************************************************
8+
* \copyright
9+
* Copyright 2018-2019 Cypress Semiconductor Corporation
10+
* SPDX-License-Identifier: Apache-2.0
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License");
13+
* you may not use this file except in compliance with the License.
14+
* You may obtain a copy of the License at
15+
*
16+
* http://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* Unless required by applicable law or agreed to in writing, software
19+
* distributed under the License is distributed on an "AS IS" BASIS,
20+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21+
* See the License for the specific language governing permissions and
22+
* limitations under the License.
23+
*******************************************************************************/
24+
25+
/**
26+
* \addtogroup group_abstraction_resource Resource abstraction
27+
* \ingroup group_abstraction
28+
* \{
29+
* Basic abstraction layer for dealing with resources.
30+
*
31+
* \defgroup group_abstraction_resource_macros Macros
32+
* \defgroup group_abstraction_resource_enums Enums
33+
* \defgroup group_abstraction_resource_data_structures Data Structures
34+
* \defgroup group_abstraction_resource_functions Functions
35+
*/
36+
37+
#pragma once
38+
39+
#include <stdint.h>
40+
#include <stdbool.h>
41+
#include "cy_result.h"
42+
43+
#if defined(__cplusplus)
44+
extern "C" {
45+
#endif
46+
47+
/**
48+
* \addtogroup group_abstraction_resource_macros
49+
* \{
50+
*/
51+
52+
/** Error code for when the specified resource operation is not valid. */
53+
#define CY_RSLT_RSC_ERROR_UNSUPPORTED (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_RESOURCE, 0))
54+
/** Error indicating that memory for the specified resource could not be allocated. */
55+
#define CY_RSLT_RSC_ERROR_UNAVAILABLE (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_RESOURCE, 1))
56+
/** Error code for when the specified resource offset is not valid for the specified resource. */
57+
#define CY_RSLT_RSC_ERROR_OFFSET (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_RESOURCE, 2))
58+
/** Error code for when the specified resource can not be opened for reading. */
59+
#define CY_RSLT_RSC_ERROR_OPEN (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_RESOURCE, 3))
60+
/** Error code for when the specified location can not be accessed in the specified resource. */
61+
#define CY_RSLT_RSC_ERROR_SEEK (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_RESOURCE, 4))
62+
/** Error code for when the specified resource can not be read. */
63+
#define CY_RSLT_RSC_ERROR_READ (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_RESOURCE, 5))
64+
65+
/** \} group_abstraction_resource_macros */
66+
67+
68+
/**
69+
* \addtogroup group_abstraction_resource_enums
70+
* \{
71+
*/
72+
/** Different types of memory that the resources can be stored in. */
73+
typedef enum
74+
{
75+
CY_RESOURCE_IN_MEMORY, /**< resource location in memory */
76+
CY_RESOURCE_IN_FILESYSTEM, /**< resource location in filesystem */
77+
CY_RESOURCE_IN_EXTERNAL_STORAGE /**< resource location in external storage */
78+
} cy_resource_location_t;
79+
80+
/** \} group_abstraction_resource_enums */
81+
82+
83+
/**
84+
* \addtogroup group_abstraction_resource_data_structures
85+
* \{
86+
*/
87+
88+
/** Filesystem handle */
89+
typedef struct
90+
{
91+
unsigned long offset; /**< Offset to the start of the resource */
92+
const char* filename; /**< name of the resource */
93+
} cy_filesystem_resource_handle_t;
94+
95+
/** Resource handle structure */
96+
typedef struct
97+
{
98+
cy_resource_location_t location; /**< resource location */
99+
unsigned long size; /**< resource size */
100+
union
101+
{
102+
cy_filesystem_resource_handle_t fs; /** < filesystem resource handle */
103+
const uint8_t* mem_data; /** < memory resource handle */
104+
void* external_storage_context; /** < external storage context */
105+
} val;
106+
} cy_resource_handle_t;
107+
108+
/** \} group_abstraction_resource_data_structures */
109+
110+
/**
111+
* \addtogroup group_abstraction_resource_functions
112+
* \{
113+
*/
114+
115+
/**
116+
* \brief return the block size for the resource
117+
* \param handle handle to a resource
118+
* \param size pointer to a uint32_t to receive the size
119+
* \returns CY_RSLT_SUCCESS if the size was found, otherwise an error
120+
*/
121+
cy_rslt_t cy_resource_get_block_size(const cy_resource_handle_t *handle, uint32_t *size);
122+
123+
/**
124+
* \brief return the total size for the resource
125+
* \param handle handle to a resource
126+
* \param size pointer to a uint32_t to receive the size
127+
* \returns CY_RSLT_SUCCESS if the size was found, otherwise an error
128+
*/
129+
cy_rslt_t cy_resource_get_total_size(const cy_resource_handle_t *handle, uint32_t *size);
130+
131+
/**
132+
* \brief return the total number of blocks that exist for the resource
133+
* \param handle handle to a resource
134+
* \param blocks pointer to a uint32_t to receive the count
135+
* \returns CY_RSLT_SUCCESS if the count was found, otherwise an error
136+
*/
137+
cy_rslt_t cy_resource_get_block_count(const cy_resource_handle_t *handle, uint32_t *blocks);
138+
139+
/**
140+
* \brief read data from a resource
141+
* \param handle the handle to the resource
142+
* \param blockno the block number of the data from the resource
143+
* \param buffer pointer to receive buffer address from resource. The buffer must be freed when done. Eg: free(buffer)
144+
* \param size location to receive the size of the block read
145+
* \returns CY_RSLT_SUCCESS if data read, otherwise an error
146+
*/
147+
cy_rslt_t cy_resource_read(const cy_resource_handle_t *handle, uint32_t blockno, uint8_t **buffer, uint32_t *size);
148+
149+
/**
150+
* \brief optimized version of read for resources stored in memory (\see CY_RESOURCE_IN_MEMORY)
151+
* \param handle the handle to the resource
152+
* \param buffer pointer to receive buffer address from resource. This does NOT need to be freed.
153+
* \param size location to receive the size of the block read
154+
* \returns CY_RSLT_SUCCESS if data read, otherwise an error
155+
*/
156+
cy_rslt_t cy_resource_readonly_memory(const cy_resource_handle_t *handle, const uint8_t **buffer, uint32_t *size);
157+
158+
/** \} group_abstraction_resource_functions */
159+
160+
#if defined(__cplusplus)
161+
}
162+
#endif
163+
164+
/** \} group_abstraction_resource */

0 commit comments

Comments
 (0)