Copyright (c) LibDriver
14 | * All rights reserved.
15 | *
16 | * The MIT License (MIT)
17 | *
18 | * Permission is hereby granted, free of charge, to any person obtaining a copy
19 | * of this software and associated documentation files (the "Software"), to deal
20 | * in the Software without restriction, including without limitation the rights
21 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22 | * copies of the Software, and to permit persons to whom the Software is
23 | * furnished to do so, subject to the following conditions:
24 | *
25 | * The above copyright notice and this permission notice shall be included in all
26 | * copies or substantial portions of the Software.
27 | *
28 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 | * SOFTWARE.
35 | */
36 |
--------------------------------------------------------------------------------
/example/driver_ads1118_basic.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 - present LibDriver All rights reserved
3 | *
4 | * The MIT License (MIT)
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | * @file driver_ads1118_basic.h
25 | * @brief driver ads1118 basic header file
26 | * @version 1.0.0
27 | * @author Shifeng Li
28 | * @date 2024-02-28
29 | *
30 | *
history
31 | *
32 | *
Date
Version
Author
Description
33 | *
2024/02/28
1.0
Shifeng Li
first upload
34 | *
35 | */
36 |
37 | #ifndef DRIVER_ADS1118_BASIC_H
38 | #define DRIVER_ADS1118_BASIC_H
39 |
40 | #include "driver_ads1118_interface.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C"{
44 | #endif
45 |
46 | /**
47 | * @defgroup ads1118_example_driver ads1118 example driver function
48 | * @brief ads1118 example driver modules
49 | * @ingroup ads1118_driver
50 | * @{
51 | */
52 |
53 | /**
54 | * @brief ads1118 basic example default definition
55 | */
56 | #define ADS1118_BASIC_DEFAULT_RANGE ADS1118_RANGE_6P144V /**< set range 6.144V */
57 | #define ADS1118_BASIC_DEFAULT_RATE ADS1118_RATE_128SPS /**< set 128 SPS */
58 | #define ADS1118_BASIC_DEFAULT_DOUT_PULL_UP ADS1118_BOOL_FALSE /**< disable dout pull up */
59 |
60 | /**
61 | * @brief basic example init
62 | * @param[in] mode adc mode
63 | * @param[in] channel adc channel
64 | * @return status code
65 | * - 0 success
66 | * - 1 init failed
67 | * @note none
68 | */
69 | uint8_t ads1118_basic_init(ads1118_mode_t mode, ads1118_channel_t channel);
70 |
71 | /**
72 | * @brief basic example deinit
73 | * @return status code
74 | * - 0 success
75 | * - 1 deinit failed
76 | * @note none
77 | */
78 | uint8_t ads1118_basic_deinit(void);
79 |
80 | /**
81 | * @brief basic example read
82 | * @param[out] *s pointer to a converted adc buffer
83 | * @return status code
84 | * - 0 success
85 | * - 1 read failed
86 | * @note none
87 | */
88 | uint8_t ads1118_basic_read(float *s);
89 |
90 | /**
91 | * @brief basic example read
92 | * @param[out] *deg pointer to a converted adc buffer
93 | * @return status code
94 | * - 0 success
95 | * - 1 read failed
96 | * @note none
97 | */
98 | uint8_t ads1118_basic_read_temperature(float *deg);
99 |
100 | /**
101 | * @}
102 | */
103 |
104 | #ifdef __cplusplus
105 | }
106 | #endif
107 |
108 | #endif
109 |
--------------------------------------------------------------------------------
/example/driver_ads1118_shot.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 - present LibDriver All rights reserved
3 | *
4 | * The MIT License (MIT)
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | * @file driver_ads1118_shot.h
25 | * @brief driver ads1118 shot header file
26 | * @version 1.0.0
27 | * @author Shifeng Li
28 | * @date 2024-02-28
29 | *
30 | *
history
31 | *
32 | *
Date
Version
Author
Description
33 | *
2024/02/28
1.0
Shifeng Li
first upload
34 | *
35 | */
36 |
37 | #ifndef DRIVER_ADS1118_SHOT_H
38 | #define DRIVER_ADS1118_SHOT_H
39 |
40 | #include "driver_ads1118_interface.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C"{
44 | #endif
45 |
46 | /**
47 | * @addtogroup ads1118_example_driver
48 | * @{
49 | */
50 |
51 | /**
52 | * @brief ads1118 shot example default definition
53 | */
54 | #define ADS1118_SHOT_DEFAULT_RANGE ADS1118_RANGE_6P144V /**< set range 6.144V */
55 | #define ADS1118_SHOT_DEFAULT_RATE ADS1118_RATE_128SPS /**< set 128 SPS */
56 | #define ADS1118_SHOT_DEFAULT_DOUT_PULL_UP ADS1118_BOOL_FALSE /**< disable dout pull up */
57 |
58 | /**
59 | * @brief shot example init
60 | * @param[in] mode adc mode
61 | * @param[in] channel adc channel
62 | * @return status code
63 | * - 0 success
64 | * - 1 init failed
65 | * @note none
66 | */
67 | uint8_t ads1118_shot_init(ads1118_mode_t mode, ads1118_channel_t channel);
68 |
69 | /**
70 | * @brief shot example read
71 | * @param[out] *s pointer to a converted adc buffer
72 | * @return status code
73 | * - 0 success
74 | * - 1 read failed
75 | * @note none
76 | */
77 | uint8_t ads1118_shot_read(float *s);
78 |
79 | /**
80 | * @brief shot example read
81 | * @param[out] *deg pointer to a converted adc buffer
82 | * @return status code
83 | * - 0 success
84 | * - 1 read failed
85 | * @note none
86 | */
87 | uint8_t ads1118_shot_read_temperature(float *deg);
88 |
89 | /**
90 | * @brief shot example deinit
91 | * @return status code
92 | * - 0 success
93 | * - 1 deinit failed
94 | * @note none
95 | */
96 | uint8_t ads1118_shot_deinit(void);
97 |
98 | /**
99 | * @}
100 | */
101 |
102 | #ifdef __cplusplus
103 | }
104 | #endif
105 |
106 | #endif
107 |
--------------------------------------------------------------------------------
/interface/driver_ads1118_interface.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 - present LibDriver All rights reserved
3 | *
4 | * The MIT License (MIT)
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | * @file driver_ads1118_interface.h
25 | * @brief driver ads1118 interface header file
26 | * @version 1.0.0
27 | * @author Shifeng Li
28 | * @date 2024-02-28
29 | *
30 | *
history
31 | *
32 | *
Date
Version
Author
Description
33 | *
2024/02/28
1.0
Shifeng Li
first upload
34 | *
35 | */
36 |
37 | #ifndef DRIVER_ADS1118_INTERFACE_H
38 | #define DRIVER_ADS1118_INTERFACE_H
39 |
40 | #include "driver_ads1118.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C"{
44 | #endif
45 |
46 | /**
47 | * @defgroup ads1118_interface_driver ads1118 interface driver function
48 | * @brief ads1118 interface driver modules
49 | * @ingroup ads1118_driver
50 | * @{
51 | */
52 |
53 | /**
54 | * @brief interface spi bus init
55 | * @return status code
56 | * - 0 success
57 | * - 1 spi init failed
58 | * @note none
59 | */
60 | uint8_t ads1118_interface_spi_init(void);
61 |
62 | /**
63 | * @brief interface spi bus deinit
64 | * @return status code
65 | * - 0 success
66 | * - 1 spi deinit failed
67 | * @note none
68 | */
69 | uint8_t ads1118_interface_spi_deinit(void);
70 |
71 | /**
72 | * @brief interface spi bus transmit
73 | * @param[in] *tx pointer to a tx buffer
74 | * @param[out] *rx pointer to a rx buffer
75 | * @param[in] len length of the data buffer
76 | * @return status code
77 | * - 0 success
78 | * - 1 transmit failed
79 | * @note none
80 | */
81 | uint8_t ads1118_interface_spi_transmit(uint8_t *tx, uint8_t *rx, uint16_t len);
82 |
83 | /**
84 | * @brief interface delay ms
85 | * @param[in] ms time
86 | * @note none
87 | */
88 | void ads1118_interface_delay_ms(uint32_t ms);
89 |
90 | /**
91 | * @brief interface print format data
92 | * @param[in] fmt format data
93 | * @note none
94 | */
95 | void ads1118_interface_debug_print(const char *const fmt, ...);
96 |
97 | /**
98 | * @}
99 | */
100 |
101 | #ifdef __cplusplus
102 | }
103 | #endif
104 |
105 | #endif
106 |
--------------------------------------------------------------------------------
/interface/driver_ads1118_interface_template.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 - present LibDriver All rights reserved
3 | *
4 | * The MIT License (MIT)
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | * @file driver_ads1118_interface_template.c
25 | * @brief driver ads1118 interface template source file
26 | * @version 1.0.0
27 | * @author Shifeng Li
28 | * @date 2024-02-28
29 | *
30 | *
4 |
5 | ### Table of Contents
6 |
7 | - [Introduce](#Introduce)
8 | - [Classification](#Classification)
9 | - [Compliance](#Compliance)
10 | - [Code](#Code)
11 | - [Report](#Report)
12 |
13 | ### Introduce
14 |
15 | MISRA C is a set of software development guidelines for the C programming language developed by The MISRA Consortium. Its aims are to facilitate code safety, security, portability and reliability in the context of embedded systems, specifically those systems programmed in ISO C / C90 / C99.
16 |
17 | Although originally specifically targeted at the automotive industry, MISRA C has evolved as a widely accepted model for best practices by leading developers in sectors including automotive, aerospace, telecom, medical devices, defense, railway, and others.
18 |
19 | ### Classification
20 |
21 | Each Guideline is classified as Mandatory(new for MISRA C:2012), Required or Advisory.
22 |
23 | - Mandatory guidelines shall always be complied with
24 | - Required guidelines shall be complied with, unless subject to a Deviation
25 | - Advisory guidelines are considered good practice, but compliance is less formal.
26 |
27 | ### Compliance
28 |
29 | In order for a piece of software to claim to be compliant to the MISRA C Guidelines, all mandatory rules shall be met and all required rules and directives shall either be met or subject to a formal deviation.
30 |
31 | Many MISRA C rules can be characterized as guidelines because under certain condition software engineers may deviate from rules and still be considered compliant with the standard. Deviations must be documented either in the code or in a file. In addition; proof must be provided that the software engineer has considered the safety of the system and that deviating from the rule will not have a negative impact, requirements for deviations also include:
32 |
33 | - The rule deviated from.
34 | - Rationale for deviation.
35 |
36 | ### Code
37 |
38 | LibDriver complies with deviated MISRA standards. LibDriver complies with all mandatory guidelines and most required guidelines, the deviations are shown in Table 1.
39 |
40 |
Table 1. Guideline Deviations
41 |
42 | | Guideline | Description | Status | Explanation | Severity |
43 | | --------- | ------------------------------------------------------------ | ------------ | ------------------------------------------------------------ | -------- |
44 | | 10.1 | Operands shall not be of an inappropriate essential type. (\|, &, ~, <<, >>) | incompatible | Embedded drivers need this method to set or clear some bits and drivers guarantee the safety of the operation. | very low |
45 | | 10.3 | The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category. (<<, >>) | incompatible | Embedded drivers need this method to set or clear some bits and drivers guarantee the safety of the operation. | very low |
46 | | 10.4 | Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category. (\|, &, <<, >>) | incompatible | Embedded drivers need this method to set or clear some bits and drivers guarantee the safety of the operation. | very low |
47 | | 10.8 | The value of a composite expression shall not be cast to a different essential type category or a wider essential type. | incompatible | We use enumeration to define driver configuration, which is a friendly programming method and should be accepted and drivers guarantee the safety of the operation. | very low |
48 | | 12.1 | The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand. | incompatible | Embedded drivers need this method to set or clear some bits and drivers guarantee the safety of the operation. | very low |
49 |
50 | ### Report
51 |
52 | Detailed reports can be found in /misra/ads1118_polyspace_report.pdf.
53 |
--------------------------------------------------------------------------------
/misra/ads1118_polyspace_report.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/libdriver/ads1118/ce0dd14eab798081f13bc6302ddd3710c438580b/misra/ads1118_polyspace_report.pdf
--------------------------------------------------------------------------------
/project/raspberrypi4b/J8Header.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/libdriver/ads1118/ce0dd14eab798081f13bc6302ddd3710c438580b/project/raspberrypi4b/J8Header.jpg
--------------------------------------------------------------------------------
/project/raspberrypi4b/cmake/VERSION:
--------------------------------------------------------------------------------
1 | 1.0.0
--------------------------------------------------------------------------------
/project/raspberrypi4b/cmake/config.cmake.in:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2015 - present LibDriver All rights reserved
3 | #
4 | # The MIT License (MIT)
5 | #
6 | # Permission is hereby granted, free of charge, to any person obtaining a copy
7 | # of this software and associated documentation files (the "Software"), to deal
8 | # in the Software without restriction, including without limitation the rights
9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | # copies of the Software, and to permit persons to whom the Software is
11 | # furnished to do so, subject to the following conditions:
12 | #
13 | # The above copyright notice and this permission notice shall be included in all
14 | # copies or substantial portions of the Software.
15 | #
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | # SOFTWARE.
23 | #
24 |
25 | # set the package init
26 | @PACKAGE_INIT@
27 |
28 | # include dependency macro
29 | include(CMakeFindDependencyMacro)
30 |
31 | # find the pkgconfig and use this tool to find the third party packages
32 | find_package(PkgConfig REQUIRED)
33 |
34 | # find the third party packages with pkgconfig
35 | pkg_search_module(GPIOD REQUIRED libgpiod)
36 |
37 | # include the cmake targets
38 | include(${CMAKE_CURRENT_LIST_DIR}/@CMAKE_PROJECT_NAME@-targets.cmake)
39 |
40 | # get the include header directories
41 | get_target_property(@CMAKE_PROJECT_NAME@_INCLUDE_DIRS @CMAKE_PROJECT_NAME@ INTERFACE_INCLUDE_DIRECTORIES)
42 |
43 | # get the library directories
44 | get_target_property(@CMAKE_PROJECT_NAME@_LIBRARIES @CMAKE_PROJECT_NAME@ IMPORTED_LOCATION_RELEASE)
45 |
--------------------------------------------------------------------------------
/project/raspberrypi4b/cmake/uninstall.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2015 - present LibDriver All rights reserved
3 | #
4 | # The MIT License (MIT)
5 | #
6 | # Permission is hereby granted, free of charge, to any person obtaining a copy
7 | # of this software and associated documentation files (the "Software"), to deal
8 | # in the Software without restriction, including without limitation the rights
9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | # copies of the Software, and to permit persons to whom the Software is
11 | # furnished to do so, subject to the following conditions:
12 | #
13 | # The above copyright notice and this permission notice shall be included in all
14 | # copies or substantial portions of the Software.
15 | #
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | # SOFTWARE.
23 | #
24 |
25 | # check the install_manifest.txt
26 | if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt")
27 | # output the error
28 | message(FATAL_ERROR "cannot find install manifest: ${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt")
29 | endif()
30 |
31 | # read install_manifest.txt to uninstall_list
32 | file(READ "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt" ${CMAKE_PROJECT_NAME}_uninstall_list)
33 |
34 | # replace '\n' to ';'
35 | string(REGEX REPLACE "\n" ";" ${CMAKE_PROJECT_NAME}_uninstall_list "${${CMAKE_PROJECT_NAME}_uninstall_list}")
36 |
37 | # uninstall the list files
38 | foreach(${CMAKE_PROJECT_NAME}_uninstall_list ${${CMAKE_PROJECT_NAME}_uninstall_list})
39 | # if a link or a file
40 | if(IS_SYMLINK "$ENV{DESTDIR}${${CMAKE_PROJECT_NAME}_uninstall_list}" OR EXISTS "$ENV{DESTDIR}${${CMAKE_PROJECT_NAME}_uninstall_list}")
41 | # delete the file
42 | execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${${CMAKE_PROJECT_NAME}_uninstall_list}
43 | RESULT_VARIABLE rm_retval
44 | )
45 |
46 | # check the retval
47 | if(NOT "${rm_retval}" STREQUAL 0)
48 | # output the error
49 | message(FATAL_ERROR "failed to remove file: '${${CMAKE_PROJECT_NAME}_uninstall_list}'.")
50 | else()
51 | # uninstalling files
52 | message(STATUS "uninstalling: $ENV{DESTDIR}${${CMAKE_PROJECT_NAME}_uninstall_list}")
53 | endif()
54 | else()
55 | # output the error
56 | message(STATUS "file: $ENV{DESTDIR}${${CMAKE_PROJECT_NAME}_uninstall_list} does not exist.")
57 | endif()
58 | endforeach()
59 |
--------------------------------------------------------------------------------
/project/raspberrypi4b/driver/src/raspberrypi4b_driver_ads1118_interface.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 - present LibDriver All rights reserved
3 | *
4 | * The MIT License (MIT)
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | * @file raspberrypi4b_driver_ads1118_interface.c
25 | * @brief raspberrypi4b driver ads1118 interface source file
26 | * @version 1.0.0
27 | * @author Shifeng Li
28 | * @date 2024-02-28
29 | *
30 | *
history
31 | *
32 | *
Date
Version
Author
Description
33 | *
2024/02/28
1.0
Shifeng Li
first upload
34 | *
35 | */
36 |
37 | #include "driver_ads1118_interface.h"
38 | #include "spi.h"
39 | #include
40 |
41 | /**
42 | * @brief spi device name definition
43 | */
44 | #define SPI_DEVICE_NAME "/dev/spidev0.0" /**< spi device name */
45 |
46 | /**
47 | * @brief spi device handle definition
48 | */
49 | static int gs_fd; /**< spi handle */
50 |
51 | /**
52 | * @brief interface spi bus init
53 | * @return status code
54 | * - 0 success
55 | * - 1 spi init failed
56 | * @note none
57 | */
58 | uint8_t ads1118_interface_spi_init(void)
59 | {
60 | return spi_init(SPI_DEVICE_NAME, &gs_fd, SPI_MODE_TYPE_1, 1000 * 1000);
61 | }
62 |
63 | /**
64 | * @brief interface spi bus deinit
65 | * @return status code
66 | * - 0 success
67 | * - 1 spi deinit failed
68 | * @note none
69 | */
70 | uint8_t ads1118_interface_spi_deinit(void)
71 | {
72 | return spi_deinit(gs_fd);
73 | }
74 |
75 | /**
76 | * @brief interface spi bus transmit
77 | * @param[in] *tx pointer to a tx buffer
78 | * @param[out] *rx pointer to a rx buffer
79 | * @param[in] len length of the data buffer
80 | * @return status code
81 | * - 0 success
82 | * - 1 transmit failed
83 | * @note none
84 | */
85 | uint8_t ads1118_interface_spi_transmit(uint8_t *tx, uint8_t *rx, uint16_t len)
86 | {
87 | return spi_transmit(gs_fd, tx, rx ,len);
88 | }
89 |
90 | /**
91 | * @brief interface delay ms
92 | * @param[in] ms time
93 | * @note none
94 | */
95 | void ads1118_interface_delay_ms(uint32_t ms)
96 | {
97 | usleep(ms * 1000);
98 | }
99 |
100 | /**
101 | * @brief interface print format data
102 | * @param[in] fmt format data
103 | * @note none
104 | */
105 | void ads1118_interface_debug_print(const char *const fmt, ...)
106 | {
107 | char str[256];
108 | uint16_t len;
109 | va_list args;
110 |
111 | memset((char *)str, 0, sizeof(char) * 256);
112 | va_start(args, fmt);
113 | vsnprintf((char *)str, 255, (char const *)fmt, args);
114 | va_end(args);
115 |
116 | len = strlen((char *)str);
117 | (void)printf((uint8_t *)str, len);
118 | }
119 |
--------------------------------------------------------------------------------
/project/stm32f407/EW/stm32f407.dep:
--------------------------------------------------------------------------------
1 |
2 |
3 | 5
4 | 2710143745
5 |
6 | Release
7 |
8 | $PROJ_DIR$\..\interface\src\delay.c
9 | $PROJ_DIR$\..\interface\src\uart.c
10 | $PROJ_DIR$\..\usr\src\stm32f4xx_hal_msp.c
11 | $PROJ_DIR$\..\usr\src\shell.c
12 | $PROJ_DIR$\..\interface\src\clock.c
13 | $PROJ_DIR$\..\usr\src\stm32f4xx_it.c
14 | $PROJ_DIR$\..\usr\src\system_stm32f4xx.c
15 | $PROJ_DIR$\..\usr\src\main.c
16 | $PROJ_DIR$\..\usr\src\getopt.c
17 | $PROJ_DIR$\..\driver\src\stm32f407_driver_ads1118_interface.c
18 | $PROJ_DIR$\..\..\..\example\driver_ads1118_basic.c
19 | $PROJ_DIR$\..\..\..\test\driver_ads1118_mutichannel_test.c
20 | $PROJ_DIR$\..\..\..\src\driver_ads1118.c
21 | $PROJ_DIR$\..\..\..\test\driver_ads1118_read_test.c
22 | $PROJ_DIR$\..\..\..\example\driver_ads1118_shot.c
23 | $PROJ_DIR$\..\..\..\test\driver_ads1118_register_test.c
24 | $PROJ_DIR$\..\interface\src\spi.c
25 |
26 |
27 | [REBUILD_ALL]
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/project/stm32f407/EW/stm32f407.eww:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $WS_DIR$\stm32f407.ewp
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/project/stm32f407/cmsis/cmsis_version.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file cmsis_version.h
3 | * @brief CMSIS Core(M) Version definitions
4 | * @version V5.0.2
5 | * @date 19. April 2017
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
9 | *
10 | * SPDX-License-Identifier: Apache-2.0
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the License); you may
13 | * not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * 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, WITHOUT
20 | * 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 | #if defined ( __ICCARM__ )
26 | #pragma system_include /* treat file as system include file for MISRA check */
27 | #elif defined (__clang__)
28 | #pragma clang system_header /* treat file as system include file */
29 | #endif
30 |
31 | #ifndef __CMSIS_VERSION_H
32 | #define __CMSIS_VERSION_H
33 |
34 | /* CMSIS Version definitions */
35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */
37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
39 | #endif
40 |
--------------------------------------------------------------------------------
/project/stm32f407/cmsis/tz_context.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * @file tz_context.h
3 | * @brief Context Management for Armv8-M TrustZone
4 | * @version V1.0.1
5 | * @date 10. January 2018
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved.
9 | *
10 | * SPDX-License-Identifier: Apache-2.0
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the License); you may
13 | * not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * 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, WITHOUT
20 | * 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 | #if defined ( __ICCARM__ )
26 | #pragma system_include /* treat file as system include file for MISRA check */
27 | #elif defined (__clang__)
28 | #pragma clang system_header /* treat file as system include file */
29 | #endif
30 |
31 | #ifndef TZ_CONTEXT_H
32 | #define TZ_CONTEXT_H
33 |
34 | #include
35 |
36 | #ifndef TZ_MODULEID_T
37 | #define TZ_MODULEID_T
38 | /// \details Data type that identifies secure software modules called by a process.
39 | typedef uint32_t TZ_ModuleId_t;
40 | #endif
41 |
42 | /// \details TZ Memory ID identifies an allocated memory slot.
43 | typedef uint32_t TZ_MemoryId_t;
44 |
45 | /// Initialize secure context memory system
46 | /// \return execution status (1: success, 0: error)
47 | uint32_t TZ_InitContextSystem_S (void);
48 |
49 | /// Allocate context memory for calling secure software modules in TrustZone
50 | /// \param[in] module identifies software modules called from non-secure mode
51 | /// \return value != 0 id TrustZone memory slot identifier
52 | /// \return value 0 no memory available or internal error
53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module);
54 |
55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S
56 | /// \param[in] id TrustZone memory slot identifier
57 | /// \return execution status (1: success, 0: error)
58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id);
59 |
60 | /// Load secure context (called on RTOS thread context switch)
61 | /// \param[in] id TrustZone memory slot identifier
62 | /// \return execution status (1: success, 0: error)
63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id);
64 |
65 | /// Store secure context (called on RTOS thread context switch)
66 | /// \param[in] id TrustZone memory slot identifier
67 | /// \return execution status (1: success, 0: error)
68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id);
69 |
70 | #endif // TZ_CONTEXT_H
71 |
--------------------------------------------------------------------------------
/project/stm32f407/driver/src/stm32f407_driver_ads1118_interface.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 - present LibDriver All rights reserved
3 | *
4 | * The MIT License (MIT)
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | * @file stm32f407_driver_ads1118_interface.c
25 | * @brief stm32f407 driver ads1118 interface source file
26 | * @version 1.0.0
27 | * @author Shifeng Li
28 | * @date 2024-02-28
29 | *
30 | *
35 | */
36 |
37 | #ifndef CLOCK_H
38 | #define CLOCK_H
39 |
40 | #include "stm32f4xx_hal.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C"{
44 | #endif
45 |
46 | /**
47 | * @defgroup clock clock function
48 | * @brief clock function modules
49 | * @{
50 | */
51 |
52 | /**
53 | * @brief chip clock init
54 | * @note none
55 | */
56 | void clock_init(void);
57 |
58 | /**
59 | * @}
60 | */
61 |
62 | #ifdef __cplusplus
63 | }
64 | #endif
65 |
66 | #endif
67 |
--------------------------------------------------------------------------------
/project/stm32f407/interface/inc/delay.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 - present LibDriver All rights reserved
3 | *
4 | * The MIT License (MIT)
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | * @file delay.h
25 | * @brief delay header file
26 | * @version 1.0.0
27 | * @author Shifeng Li
28 | * @date 2022-11-11
29 | *
30 | *
history
31 | *
32 | *
Date
Version
Author
Description
33 | *
2022/11/11
1.0
Shifeng Li
first upload
34 | *
35 | */
36 |
37 | #ifndef DELAY_H
38 | #define DELAY_H
39 |
40 | #include "stm32f4xx_hal.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C"{
44 | #endif
45 |
46 | /**
47 | * @defgroup delay delay function
48 | * @brief delay function modules
49 | * @{
50 | */
51 |
52 | /**
53 | * @brief delay clock init
54 | * @return status code
55 | * - 0 success
56 | * @note none
57 | */
58 | uint8_t delay_init(void);
59 |
60 | /**
61 | * @brief delay us
62 | * @param[in] us time
63 | * @note none
64 | */
65 | void delay_us(uint32_t us);
66 |
67 | /**
68 | * @brief delay ms
69 | * @param[in] ms time
70 | * @note none
71 | */
72 | void delay_ms(uint32_t ms);
73 |
74 | /**
75 | * @}
76 | */
77 |
78 | #ifdef __cplusplus
79 | }
80 | #endif
81 |
82 | #endif
83 |
--------------------------------------------------------------------------------
/project/stm32f407/interface/src/clock.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 - present LibDriver All rights reserved
3 | *
4 | * The MIT License (MIT)
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | * @file clock.c
25 | * @brief clock source file
26 | * @version 1.0.0
27 | * @author Shifeng Li
28 | * @date 2022-11-11
29 | *
30 | *
history
31 | *
32 | *
Date
Version
Author
Description
33 | *
2022/11/11
1.0
Shifeng Li
first upload
34 | *
35 | */
36 |
37 | #include "clock.h"
38 |
39 | /**
40 | * @brief chip clock init
41 | * @note none
42 | */
43 | void clock_init(void)
44 | {
45 | RCC_OscInitTypeDef RCC_OscInitStructure;
46 | RCC_ClkInitTypeDef RCC_ClkInitStructure;
47 | HAL_StatusTypeDef ret;
48 |
49 | /* enable power clock */
50 | __HAL_RCC_PWR_CLK_ENABLE();
51 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
52 |
53 | /* use HSE */
54 | RCC_OscInitStructure.OscillatorType = RCC_OSCILLATORTYPE_HSE;
55 | RCC_OscInitStructure.HSEState = RCC_HSE_ON;
56 | RCC_OscInitStructure.PLL.PLLState = RCC_PLL_ON;
57 | RCC_OscInitStructure.PLL.PLLSource = RCC_PLLSOURCE_HSE;
58 | RCC_OscInitStructure.PLL.PLLM = 8;
59 | RCC_OscInitStructure.PLL.PLLN = 336;
60 | RCC_OscInitStructure.PLL.PLLP = 2;
61 | RCC_OscInitStructure.PLL.PLLQ = 7;
62 | ret = HAL_RCC_OscConfig(&RCC_OscInitStructure);
63 | if (ret != HAL_OK)
64 | {
65 | while(1);
66 | }
67 |
68 | /* config clock */
69 | RCC_ClkInitStructure.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
70 | RCC_ClkInitStructure.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
71 | RCC_ClkInitStructure.AHBCLKDivider = RCC_SYSCLK_DIV1;
72 | RCC_ClkInitStructure.APB1CLKDivider = RCC_HCLK_DIV4;
73 | RCC_ClkInitStructure.APB2CLKDivider = RCC_HCLK_DIV2;
74 | ret = HAL_RCC_ClockConfig(&RCC_ClkInitStructure, FLASH_LATENCY_5);
75 | if (ret != HAL_OK)
76 | {
77 | while(1);
78 | }
79 |
80 | /* check the id and enable flash prefetch buffer */
81 | if (HAL_GetREVID() == 0x1001)
82 | {
83 | __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
84 | }
85 |
86 | /* hal init */
87 | ret = HAL_Init();
88 | if (ret != HAL_OK)
89 | {
90 | while(1);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/project/stm32f407/interface/src/delay.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 - present LibDriver All rights reserved
3 | *
4 | * The MIT License (MIT)
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | * @file delay.c
25 | * @brief delay source file
26 | * @version 1.0.0
27 | * @author Shifeng Li
28 | * @date 2022-11-11
29 | *
30 | *
history
31 | *
32 | *
Date
Version
Author
Description
33 | *
2022/11/11
1.0
Shifeng Li
first upload
34 | *
35 | */
36 |
37 | #include "delay.h"
38 |
39 | static volatile uint32_t gs_fac_us = 0; /**< fac cnt */
40 |
41 | /**
42 | * @brief delay clock init
43 | * @return status code
44 | * - 0 success
45 | * @note none
46 | */
47 | uint8_t delay_init(void)
48 | {
49 | /* usr HCLK */
50 | HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
51 |
52 | /* set fac */
53 | gs_fac_us = 168;
54 |
55 | return 0;
56 | }
57 |
58 | /**
59 | * @brief delay us
60 | * @param[in] us time
61 | * @note none
62 | */
63 | void delay_us(uint32_t us)
64 | {
65 | uint32_t ticks;
66 | uint32_t told;
67 | uint32_t tnow;
68 | uint32_t tcnt;
69 | uint32_t reload;
70 |
71 | /* set the used param */
72 | tcnt = 0;
73 | reload = SysTick->LOAD;
74 | ticks = us * gs_fac_us;
75 | told = SysTick->VAL;
76 |
77 | /* delay */
78 | while (1)
79 | {
80 | tnow = SysTick->VAL;
81 | if (tnow != told)
82 | {
83 | if (tnow < told)
84 | {
85 | tcnt += told - tnow;
86 | }
87 | else
88 | {
89 | tcnt += reload - tnow + told;
90 | }
91 | told = tnow;
92 | if (tcnt >= ticks)
93 | {
94 | break;
95 | }
96 | }
97 | }
98 | }
99 |
100 | /**
101 | * @brief delay ms
102 | * @param[in] ms time
103 | * @note none
104 | */
105 | void delay_ms(uint32_t ms)
106 | {
107 | /* use the hal delay */
108 | HAL_Delay(ms);
109 | }
110 |
--------------------------------------------------------------------------------
/project/stm32f407/output/mdk/obj_delete.bat:
--------------------------------------------------------------------------------
1 | del *.bak /s
2 | del *.ddk /s
3 | del *.edk /s
4 | del *.lst /s
5 | del *.lnp /s
6 | del *.mpf /s
7 | del *.mpj /s
8 | del *.obj /s
9 | del *.omf /s
10 | ::del *.opt /s
11 | del *.plg /s
12 | del *.rpt /s
13 | del *.tmp /s
14 | del *.__i /s
15 | del *.crf /s
16 | del *.o /s
17 | del *.d /s
18 | del *.axf /s
19 | del *.tra /s
20 | del *.dep /s
21 | del *.iex /s
22 | del *.htm /s
23 | del *.sct /s
24 | del *.map /s
25 | exit
26 |
--------------------------------------------------------------------------------
/project/stm32f407/usr/inc/stm32f4xx_it.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 - present LibDriver All rights reserved
3 | *
4 | * The MIT License (MIT)
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | * @file stm32f4xx_it.h
25 | * @brief stm32f4xx it header file
26 | * @version 1.0.0
27 | * @author Shifeng Li
28 | * @date 2022-11-11
29 | *
30 | *
history
31 | *
32 | *
Date
Version
Author
Description
33 | *
2022/11/11
1.0
Shifeng Li
first upload
34 | *
35 | */
36 |
37 | #ifndef STM32F4XX_IT_H
38 | #define STM32F4XX_IT_H
39 |
40 | #include "stm32f4xx_hal.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | /**
47 | * @defgroup IT HAL_IT_Private_Functions
48 | * @{
49 | */
50 |
51 | /**
52 | * @brief nmi handler
53 | * @note none
54 | */
55 | void NMI_Handler(void);
56 |
57 | /**
58 | * @brief hardfault handler
59 | * @note none
60 | */
61 | void HardFault_Handler(void);
62 |
63 | /**
64 | * @brief memory manage handler
65 | * @note none
66 | */
67 | void MemManage_Handler(void);
68 |
69 | /**
70 | * @brief bus fault handler
71 | * @note none
72 | */
73 | void BusFault_Handler(void);
74 |
75 | /**
76 | * @brief usage fault handler
77 | * @note none
78 | */
79 | void UsageFault_Handler(void);
80 |
81 | /**
82 | * @brief svc handler
83 | * @note none
84 | */
85 | void SVC_Handler(void);
86 |
87 | /**
88 | * @brief debug handler
89 | * @note none
90 | */
91 | void DebugMon_Handler(void);
92 |
93 | /**
94 | * @brief pendsv handler
95 | * @note none
96 | */
97 | void PendSV_Handler(void);
98 |
99 | /**
100 | * @brief systick handler
101 | * @note none
102 | */
103 | void SysTick_Handler(void);
104 |
105 | /**
106 | * @brief usart1 irq handler
107 | * @note none
108 | */
109 | void USART1_IRQHandler(void);
110 |
111 | /**
112 | * @brief usart2 irq handler
113 | * @note none
114 | */
115 | void USART2_IRQHandler(void);
116 |
117 | /**
118 | * @}
119 | */
120 |
121 | #ifdef __cplusplus
122 | }
123 | #endif
124 |
125 | #endif
126 |
--------------------------------------------------------------------------------
/project/stm32f407/usr/inc/system_stm32f4xx.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file system_stm32f4xx.h
4 | * @author MCD Application Team
5 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * Copyright (c) 2017 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software is licensed under terms that can be found in the LICENSE file
13 | * in the root directory of this software component.
14 | * If no LICENSE file comes with this software, it is provided AS-IS.
15 | *
16 | ******************************************************************************
17 | */
18 |
19 | /** @addtogroup CMSIS
20 | * @{
21 | */
22 |
23 | /** @addtogroup stm32f4xx_system
24 | * @{
25 | */
26 |
27 | /**
28 | * @brief Define to prevent recursive inclusion
29 | */
30 | #ifndef __SYSTEM_STM32F4XX_H
31 | #define __SYSTEM_STM32F4XX_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /** @addtogroup STM32F4xx_System_Includes
38 | * @{
39 | */
40 |
41 | /**
42 | * @}
43 | */
44 |
45 |
46 | /** @addtogroup STM32F4xx_System_Exported_types
47 | * @{
48 | */
49 | /* This variable is updated in three ways:
50 | 1) by calling CMSIS function SystemCoreClockUpdate()
51 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq()
52 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
53 | Note: If you use this function to configure the system clock; then there
54 | is no need to call the 2 first functions listed above, since SystemCoreClock
55 | variable is updated automatically.
56 | */
57 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
58 |
59 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */
60 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */
61 |
62 | /**
63 | * @}
64 | */
65 |
66 | /** @addtogroup STM32F4xx_System_Exported_Constants
67 | * @{
68 | */
69 |
70 | /**
71 | * @}
72 | */
73 |
74 | /** @addtogroup STM32F4xx_System_Exported_Macros
75 | * @{
76 | */
77 |
78 | /**
79 | * @}
80 | */
81 |
82 | /** @addtogroup STM32F4xx_System_Exported_Functions
83 | * @{
84 | */
85 |
86 | extern void SystemInit(void);
87 | extern void SystemCoreClockUpdate(void);
88 | /**
89 | * @}
90 | */
91 |
92 | #ifdef __cplusplus
93 | }
94 | #endif
95 |
96 | #endif /*__SYSTEM_STM32F4XX_H */
97 |
98 | /**
99 | * @}
100 | */
101 |
102 | /**
103 | * @}
104 | */
105 |
--------------------------------------------------------------------------------
/test/driver_ads1118_mutichannel_test.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 - present LibDriver All rights reserved
3 | *
4 | * The MIT License (MIT)
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | * @file driver_ads1118_mutichannel_test.h
25 | * @brief driver ads1118 mutichannel test header file
26 | * @version 1.0.0
27 | * @author Shifeng Li
28 | * @date 2024-02-28
29 | *
30 | *
history
31 | *
32 | *
Date
Version
Author
Description
33 | *
2024/02/28
1.0
Shifeng Li
first upload
34 | *
35 | */
36 |
37 | #ifndef DRIVER_ADS1118_MUTICHANNEL_TEST_H
38 | #define DRIVER_ADS1118_MUTICHANNEL_TEST_H
39 |
40 | #include "driver_ads1118_interface.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C"{
44 | #endif
45 |
46 | /**
47 | * @addtogroup ads1118_test_driver
48 | * @{
49 | */
50 |
51 | /**
52 | * @brief multichannel test
53 | * @param[in] channel adc channel
54 | * @param[in] times test times
55 | * @return status code
56 | * - 0 success
57 | * - 1 test failed
58 | * @note none
59 | */
60 | uint8_t ads1118_multichannel_test(ads1118_channel_t channel, uint32_t times);
61 |
62 | /**
63 | * @}
64 | */
65 |
66 | #ifdef __cplusplus
67 | }
68 | #endif
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/test/driver_ads1118_read_test.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 - present LibDriver All rights reserved
3 | *
4 | * The MIT License (MIT)
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | * @file driver_ads1118_read_test.h
25 | * @brief driver ads1118 read test header file
26 | * @version 1.0.0
27 | * @author Shifeng Li
28 | * @date 2024-02-28
29 | *
30 | *
history
31 | *
32 | *
Date
Version
Author
Description
33 | *
2024/02/28
1.0
Shifeng Li
first upload
34 | *
35 | */
36 |
37 | #ifndef DRIVER_ADS1118_READ_TEST_H
38 | #define DRIVER_ADS1118_READ_TEST_H
39 |
40 | #include "driver_ads1118_interface.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C"{
44 | #endif
45 |
46 | /**
47 | * @addtogroup ads1118_test_driver
48 | * @{
49 | */
50 |
51 | /**
52 | * @brief read test
53 | * @param[in] times test times
54 | * @return status code
55 | * - 0 success
56 | * - 1 test failed
57 | * @note none
58 | */
59 | uint8_t ads1118_read_test(uint32_t times);
60 |
61 | /**
62 | * @}
63 | */
64 |
65 | #ifdef __cplusplus
66 | }
67 | #endif
68 |
69 | #endif
70 |
--------------------------------------------------------------------------------
/test/driver_ads1118_register_test.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 - present LibDriver All rights reserved
3 | *
4 | * The MIT License (MIT)
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | * @file driver_ads1118_register_test.h
25 | * @brief driver ads1118 register test header file
26 | * @version 1.0.0
27 | * @author Shifeng Li
28 | * @date 2024-02-28
29 | *
30 | *