Browse Source

moved platform specific stuff from core

Ondřej Hruška 1 year ago
parent
commit
8e85d44e59
Signed by: Ondřej Hruška <ondra@ondrovo.com> GPG key ID: 2C5FD5035250423D
8 changed files with 290 additions and 221 deletions
  1. 40 19
      CMakeLists.txt
  2. 1 1
      GexCore
  3. 0 177
      GexUnits/test/unit_test.c
  4. 0 14
      GexUnits/test/unit_test.h
  5. 2 10
      GexUnits/units_manifest.h
  6. 76 0
      Inc/nrf_pins.h
  7. 109 0
      Inc/plat_compat.h
  8. 62 0
      Src/platform_resources.c

+ 40 - 19
CMakeLists.txt View File

@@ -1,3 +1,6 @@
1
+# This is a dummy CmakeLists.txt file for CLion.
2
+# It does not work, don't even try.
3
+
1 4
 cmake_minimum_required(VERSION 3.9)
2 5
 project(GEX_F072)
3 6
 
@@ -20,6 +23,22 @@ add_definitions(
20 23
         -DUSE_DEBUG_UART=1
21 24
         -DGEX_PLAT_F072_ZERO
22 25
         -DHAL_TSC_MODULE_ENABLED
26
+
27
+        -DENABLE_UNIT_1WIRE=1
28
+        -DENABLE_UNIT_ADC=1
29
+        -DENABLE_UNIT_DAC=1
30
+        -DENABLE_UNIT_DIGITAL_IN=1
31
+        -DENABLE_UNIT_DIGITAL_OUT=1
32
+        -DENABLE_UNIT_FCAP=1
33
+        -DENABLE_UNIT_I2C=1
34
+        -DENABLE_UNIT_NEOPIXEL=1
35
+        -DENABLE_UNIT_SIMPLE_PWM=1
36
+        -DENABLE_UNIT_SIPO=1
37
+        -DENABLE_UNIT_SPI=1
38
+        -DENABLE_UNIT_TEMPLATE=1
39
+        -DENABLE_UNIT_TEST=1
40
+        -DENABLE_UNIT_TOUCH=1
41
+        -DENABLE_UNIT_USART=1
23 42
 )
24 43
 
25 44
 FILE(GLOB_RECURSE SOURCE_FILES
@@ -28,8 +47,10 @@ FILE(GLOB_RECURSE SOURCE_FILES
28 47
         Drivers/*.h
29 48
         Middlewares/*.c
30 49
         Middlewares/*.h
31
-        User/*.c
32
-        User/*.h
50
+        GexCore/*.c
51
+        GexCore/*.h
52
+        GexUnits/*.c
53
+        GexUnits/*.h
33 54
         Src/*.c
34 55
         Src/*.h
35 56
 )
@@ -45,18 +66,18 @@ include_directories(
45 66
         Drivers/STM32F0xx_HAL_Driver/Inc/Legacy
46 67
 
47 68
         # USB Library
48
-        User/USB/STM32_USB_Device_Library/Core/Inc
69
+        GexCore/USB/STM32_USB_Device_Library/Core/Inc
49 70
         # USB Device Classes
50
-        User/USB/STM32_USB_Device_Library/Class/AUDIO/Inc
51
-        User/USB/STM32_USB_Device_Library/Class/CDC/Inc
52
-        User/USB/STM32_USB_Device_Library/Class/CustomHID/Inc
53
-        User/USB/STM32_USB_Device_Library/Class/DFU/Inc
54
-        User/USB/STM32_USB_Device_Library/Class/HID/Inc
55
-        User/USB/STM32_USB_Device_Library/Class/MSC/Inc
56
-        User/USB/STM32_USB_Device_Library/Class/MSC_CDC
71
+        GexCore/USB/STM32_USB_Device_Library/Class/AUDIO/Inc
72
+        GexCore/USB/STM32_USB_Device_Library/Class/CDC/Inc
73
+        GexCore/USB/STM32_USB_Device_Library/Class/CustomHID/Inc
74
+        GexCore/USB/STM32_USB_Device_Library/Class/DFU/Inc
75
+        GexCore/USB/STM32_USB_Device_Library/Class/HID/Inc
76
+        GexCore/USB/STM32_USB_Device_Library/Class/MSC/Inc
77
+        GexCore/USB/STM32_USB_Device_Library/Class/MSC_CDC
57 78
 
58 79
         # Other vendor libraries
59
-        User/USB/STM32_TouchSensing_Library/inc
80
+        GexCore/USB/STM32_TouchSensing_Library/inc
60 81
 
61 82
         # FreeRTOS
62 83
         Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS
@@ -65,15 +86,15 @@ include_directories(
65 86
         Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM0
66 87
 
67 88
         # Application
68
-        User
69
-        User/USB
70
-        User/utils
71
-        User/TinyFrame
72
-        User/framework
73
-        User/platform
74
-        User/tasks
75
-        User/units
89
+        GexCore
90
+        GexCore/USB
91
+        GexCore/utils
92
+        GexCore/TinyFrame
93
+        GexCore/framework
94
+        GexCore/platform
95
+        GexCore/tasks
76 96
         Inc
97
+        GexUnits
77 98
 )
78 99
 
79 100
 add_executable(main ${SOURCE_FILES})

+ 1 - 1
GexCore

@@ -1 +1 @@
1
-Subproject commit b8909fca0658712186632a31e96d4722f2186c58
1
+Subproject commit 20639b77a615eac5538941972f47fed717949e47

+ 0 - 177
GexUnits/test/unit_test.c View File

@@ -1,177 +0,0 @@
1
-//
2
-// Created by MightyPork on 2017/11/25.
3
-//
4
-
5
-#include "comm/messages.h"
6
-#include "unit_base.h"
7
-#include "unit_test.h"
8
-
9
-/** Private data structure */
10
-struct priv {
11
-    uint32_t unused;
12
-};
13
-
14
-// ------------------------------------------------------------------------
15
-
16
-/** Load from a binary buffer stored in Flash */
17
-static void Tst_loadBinary(Unit *unit, PayloadParser *pp)
18
-{
19
-    struct priv *priv = unit->data;
20
-
21
-    //
22
-}
23
-
24
-/** Write to a binary buffer for storing in Flash */
25
-static void Tst_writeBinary(Unit *unit, PayloadBuilder *pb)
26
-{
27
-    struct priv *priv = unit->data;
28
-
29
-    //
30
-}
31
-
32
-// ------------------------------------------------------------------------
33
-
34
-/** Parse a key-value pair from the INI file */
35
-static error_t Tst_loadIni(Unit *unit, const char *key, const char *value)
36
-{
37
-    return E_BAD_KEY;
38
-}
39
-
40
-/** Generate INI file section for the unit */
41
-static void Tst_writeIni(Unit *unit, IniWriter *iw)
42
-{
43
-    struct priv *priv = unit->data;
44
-
45
-    //
46
-}
47
-
48
-// ------------------------------------------------------------------------
49
-
50
-/** Allocate data structure and set defaults */
51
-static error_t Tst_preInit(Unit *unit)
52
-{
53
-    struct priv *priv = unit->data = calloc_ck(1, sizeof(struct priv));
54
-    if (priv == NULL) return E_OUT_OF_MEM;
55
-
56
-    //
57
-
58
-    return E_SUCCESS;
59
-}
60
-
61
-/** Finalize unit set-up */
62
-static error_t Tst_init(Unit *unit)
63
-{
64
-    bool suc = true;
65
-    struct priv *priv = unit->data;
66
-
67
-    //
68
-
69
-    return E_SUCCESS;
70
-}
71
-
72
-/** Tear down the unit */
73
-static void Tst_deInit(Unit *unit)
74
-{
75
-    struct priv *priv = unit->data;
76
-
77
-    //
78
-
79
-    // Free memory
80
-    free_ck(unit->data);
81
-}
82
-
83
-// ------------------------------------------------------------------------
84
-
85
-enum PinCmd_ {
86
-    CMD_PING = 0,
87
-    CMD_ECHO = 1,
88
-    CMD_BULKREAD = 2,
89
-    CMD_BULKWRITE = 3,
90
-};
91
-
92
-// this is a very long text for testing bulk read
93
-static const char *longtext = "The history of all hitherto existing societies is the history of class struggles.\n\nFreeman and slave, patrician and plebeian, lord and serf, guild-master and journeyman, in a word, oppressor and oppressed, stood in constant opposition to one another, carried on an uninterrupted, now hidden, now open fight, a fight that each time ended, either in a revolutionary re-constitution of society at large, or in the common ruin of the contending classes.\n\nIn the earlier epochs of history, we find almost everywhere a complicated arrangement of society into various orders, a manifold gradation of social rank. In ancient Rome we have patricians, knights, plebeians, slaves; in the Middle Ages, feudal lords, vassals, guild-masters, journeymen, apprentices, serfs; in almost all of these classes, again, subordinate gradations.\n\nThe modern bourgeois society that has sprouted from the ruins of feudal society has not done away with class antagonisms. It has but established new classes, new conditions of oppression, new forms of struggle in place of the old ones. Our epoch, the epoch of the bourgeoisie, possesses, however, this distinctive feature: it has simplified the class antagonisms. Society as a whole is more and more splitting up into two great hostile camps, into two great classes, directly facing each other: Bourgeoisie and Proletariat.\n\nFrom the serfs of the Middle Ages sprang the chartered burghers of the earliest towns. From these burgesses the first elements of the bourgeoisie were developed.\n\nThe discovery of America, the rounding of the Cape, opened up fresh ground for the rising bourgeoisie. The East-Indian and Chinese markets, the colonisation of America, trade with the colonies, the increase in the means of exchange and in commodities generally, gave to commerce, to navigation, to industry, an impulse never before known, and thereby, to the revolutionary element in the tottering feudal society, a rapid development.\n\nThe feudal system of industry, under which industrial production was monopolised by closed guilds, now no longer sufficed for the growing wants of the new markets. The manufacturing system took its place. The guild-masters were pushed on one side by the manufacturing middle class; division of labour between the different corporate guilds vanished in the face of division of labour in each single workshop.\n\nMeantime the markets kept ever growing, the demand ever rising. Even manufacture no longer sufficed. Thereupon, steam and machinery revolutionised industrial production. The place of manufacture was taken by the giant, Modern Industry, the place of the industrial middle class, by industrial millionaires, the leaders of whole industrial armies, the modern bourgeois.\n\nModern industry has established the world-market, for which the discovery of America paved the way. This market has given an immense development to commerce, to navigation, to communication by land. This development has, in its time, reacted on the extension of industry; and in proportion as industry, commerce, navigation, railways extended, in the same proportion the bourgeoisie developed, increased its capital, and pushed into the background every class handed down from the Middle Ages.\n\nWe see, therefore, how the modern bourgeoisie is itself the product of a long course of development, of a series of revolutions in the modes of production and of exchange.\n\nEach step in the development of the bourgeoisie was accompanied by a corresponding political advance of that class. An oppressed class under the sway of the feudal nobility, an armed and self-governing association in the mediaeval commune; here independent urban republic (as in Italy and Germany), there taxable \"third estate\" of the monarchy (as in France), afterwards, in the period of manufacture proper, serving either the semi-feudal or the absolute monarchy as a counterpoise against the nobility, and, in fact, corner-stone of the great monarchies in general, the bourgeoisie has at last, since the establishment of Modern Industry and of the world-market, conquered for itself, in the modern representative State, exclusive political sway. The executive of the modern State is but a committee for managing the common affairs of the whole bourgeoisie.";
94
-
95
-static void br_longtext(struct bulk_read *bulk, uint32_t chunk, uint8_t *buffer)
96
-{
97
-    // clean-up request
98
-    if (buffer == NULL) {
99
-        free_ck(bulk);
100
-        return;
101
-    }
102
-
103
-    memcpy(buffer, longtext+bulk->offset, chunk);
104
-}
105
-
106
-static void bw_dump(struct bulk_write *bulk, const uint8_t *chunk, uint32_t len)
107
-{
108
-    // clean-up request
109
-    if (chunk == NULL) {
110
-        free_ck(bulk);
111
-        return;
112
-    }
113
-
114
-    dbg("\r\nBulk write at %d, len %d", (int)bulk->offset, (int)len);
115
-    PUTSN((const char *) chunk, (uint16_t) len);
116
-    PUTS("\r\n");
117
-}
118
-
119
-/** Handle a request message */
120
-static error_t Tst_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command, PayloadParser *pp)
121
-{
122
-    switch (command) {
123
-        case CMD_PING:
124
-            com_respond_ok(frame_id);
125
-            return E_SUCCESS;
126
-
127
-        case CMD_ECHO:;
128
-            uint32_t len;
129
-            const uint8_t *data = pp_tail(pp, &len);
130
-            com_respond_buf(frame_id, MSG_SUCCESS, data, len);
131
-            return E_SUCCESS;
132
-
133
-        case CMD_BULKREAD:;
134
-            BulkRead *br = malloc_ck(sizeof(struct bulk_read));
135
-            assert_param(br);
136
-
137
-            br->len = (uint32_t) strlen(longtext);
138
-            br->frame_id = frame_id;
139
-            br->read = br_longtext;
140
-
141
-            bulkread_start(comm, br);
142
-            return E_SUCCESS;
143
-
144
-        case CMD_BULKWRITE:;
145
-            BulkWrite *bw = malloc_ck(sizeof(struct bulk_write));
146
-            assert_param(bw);
147
-
148
-            bw->len = 10240;
149
-            bw->frame_id = frame_id;
150
-            bw->write = bw_dump;
151
-
152
-            bulkwrite_start(comm, bw);
153
-            return E_SUCCESS;
154
-
155
-        default:
156
-            return E_UNKNOWN_COMMAND;
157
-    }
158
-}
159
-
160
-// ------------------------------------------------------------------------
161
-
162
-/** Unit template */
163
-const UnitDriver UNIT_TEST = {
164
-    .name = "TEST",
165
-    .description = "Test unit",
166
-    // Settings
167
-    .preInit = Tst_preInit,
168
-    .cfgLoadBinary = Tst_loadBinary,
169
-    .cfgWriteBinary = Tst_writeBinary,
170
-    .cfgLoadIni = Tst_loadIni,
171
-    .cfgWriteIni = Tst_writeIni,
172
-    // Init
173
-    .init = Tst_init,
174
-    .deInit = Tst_deInit,
175
-    // Function
176
-    .handleRequest = Tst_handleRequest,
177
-};

+ 0 - 14
GexUnits/test/unit_test.h View File

@@ -1,14 +0,0 @@
1
-//
2
-// Created by MightyPork on 2017/11/25.
3
-//
4
-// Testing unit that uses most of the protocol to verify the core functionality
5
-//
6
-
7
-#ifndef U_TEST_H
8
-#define U_TEST_H
9
-
10
-#include "unit.h"
11
-
12
-extern const UnitDriver UNIT_TEST;
13
-
14
-#endif //U_TEST_H

+ 2 - 10
GexUnits/units_manifest.h View File

@@ -1,7 +1,7 @@
1 1
 // This is a GEX units manifest file
2
-// For a unit to be included in the firmware, it's uppercase name
2
+// For a unit to be included in the firmware, its uppercase name
3 3
 // must be included in the GEX_UNITS list in build.mk, and it must have 
4
-// a section here.
4
+// an entry here.
5 5
 
6 6
 #ifdef ENABLE_UNIT_1WIRE
7 7
 #include "1wire/unit_1wire.h"
@@ -47,14 +47,6 @@
47 47
 #include "spi/unit_spi.h"
48 48
 #endif
49 49
 
50
-#ifdef ENABLE_UNIT_TEMPLATE
51
-#include "template/unit_template.h"
52
-#endif
53
-
54
-#ifdef ENABLE_UNIT_TEST
55
-#include "test/unit_test.h"
56
-#endif
57
-
58 50
 #ifdef ENABLE_UNIT_TOUCH
59 51
 #include "touch/unit_touch.h"
60 52
 #endif

+ 76 - 0
Inc/nrf_pins.h View File

@@ -0,0 +1,76 @@
1
+//
2
+// Created by MightyPork on 2018/04/06.
3
+//
4
+
5
+#ifndef GEX_CORE_NRF_PINS_H
6
+#define GEX_CORE_NRF_PINS_H
7
+
8
+#include "platform.h"
9
+#include "rsc_enum.h"
10
+
11
+#if defined(GEX_PLAT_F072_DISCOVERY) || defined(GEX_PLAT_F072_HUB)
12
+
13
+    // This config was used only for development when NRF was enabled for those platforms. It is normally disabled.
14
+    #define NRF_SPI            SPI1
15
+    #define NRF_R_SPI          R_SPI1
16
+
17
+    #define NRF_IRQ_Pin        LL_GPIO_PIN_10
18
+    #define NRF_IRQ_GPIO_Port  GPIOB
19
+    #define NRF_R_IRQ          R_PB10
20
+    #define NRF_EXTI_LINENUM   10
21
+    #define NRF_SYSCFG_EXTI_PORT LL_SYSCFG_EXTI_PORTB
22
+
23
+    #define NRF_NSS_Pin        LL_GPIO_PIN_11
24
+    #define NRF_NSS_GPIO_Port  GPIOB
25
+    #define NRF_R_NSS          R_PB11
26
+
27
+    #define NRF_CE_Pin         LL_GPIO_PIN_12
28
+    #define NRF_CE_GPIO_Port   GPIOB
29
+    #define NRF_R_CE           R_PB12
30
+
31
+    #define NRF_RST_Pin        LL_GPIO_PIN_13
32
+    #define NRF_RST_GPIO_Port  GPIOB
33
+    #define NRF_R_RST          R_PB13
34
+
35
+    #define NRF_R_SCK          R_PA5
36
+    #define NRF_SCK_AF         LL_GPIO_AF_0
37
+    #define NRF_R_MISO         R_PA6
38
+    #define NRF_MISO_AF        LL_GPIO_AF_0
39
+    #define NRF_R_MOSI         R_PA7
40
+    #define NRF_MOSI_AF        LL_GPIO_AF_0
41
+
42
+#elif defined(GEX_PLAT_F072_ZERO)
43
+
44
+    #define NRF_SPI            SPI2
45
+    #define NRF_R_SPI          R_SPI2
46
+
47
+    #define NRF_IRQ_Pin        LL_GPIO_PIN_15
48
+    #define NRF_IRQ_GPIO_Port  GPIOC
49
+    #define NRF_R_IRQ          R_PC15
50
+    #define NRF_EXTI_LINENUM   15
51
+    #define NRF_SYSCFG_EXTI_PORT LL_SYSCFG_EXTI_PORTC
52
+
53
+    #define NRF_NSS_Pin        LL_GPIO_PIN_13
54
+    #define NRF_NSS_GPIO_Port  GPIOC
55
+    #define NRF_R_NSS          R_PC13
56
+
57
+    #define NRF_CE_Pin         LL_GPIO_PIN_14
58
+    #define NRF_CE_GPIO_Port   GPIOC
59
+    #define NRF_R_CE           R_PC14
60
+
61
+    #define NRF_RST_Pin        LL_GPIO_PIN_12
62
+    #define NRF_RST_GPIO_Port  GPIOC
63
+    #define NRF_R_RST          R_PC12
64
+
65
+    #define NRF_R_SCK          R_PB13
66
+    #define NRF_SCK_AF         LL_GPIO_AF_0
67
+    #define NRF_R_MISO         R_PC2
68
+    #define NRF_MISO_AF        LL_GPIO_AF_1
69
+    #define NRF_R_MOSI         R_PC3
70
+    #define NRF_MOSI_AF        LL_GPIO_AF_1
71
+
72
+#else
73
+    #error "Missing NRF config for this platform."
74
+#endif
75
+
76
+#endif //GEX_NRF_PINS_H

+ 109 - 0
Inc/plat_compat.h View File

@@ -0,0 +1,109 @@
1
+//
2
+// Created by MightyPork on 2018/07/07.
3
+//
4
+
5
+#ifndef GEX_PLAT_COMPAT_H
6
+#define GEX_PLAT_COMPAT_H
7
+
8
+#define PLAT_AHB_MHZ 48
9
+#define PLAT_APB1_MHZ 48
10
+
11
+#include <stm32f0xx.h>
12
+#include <stm32f0xx_ll_adc.h>
13
+#include <stm32f0xx_ll_bus.h>
14
+#include <stm32f0xx_ll_comp.h>
15
+#include <stm32f0xx_ll_cortex.h>
16
+#include <stm32f0xx_ll_crc.h>
17
+#include <stm32f0xx_ll_crs.h>
18
+#include <stm32f0xx_ll_dac.h>
19
+#include <stm32f0xx_ll_dma.h>
20
+#include <stm32f0xx_ll_exti.h>
21
+#include <stm32f0xx_ll_gpio.h>
22
+#include <stm32f0xx_ll_i2c.h>
23
+#include <stm32f0xx_ll_iwdg.h>
24
+#include <stm32f0xx_ll_pwr.h>
25
+#include <stm32f0xx_ll_rcc.h>
26
+#include <stm32f0xx_ll_rtc.h>
27
+#include <stm32f0xx_ll_spi.h>
28
+#include <stm32f0xx_ll_system.h>
29
+#include <stm32f0xx_ll_tim.h>
30
+#include <stm32f0xx_ll_usart.h>
31
+#include <stm32f0xx_ll_utils.h>
32
+#include <stm32f0xx_ll_wwdg.h>
33
+
34
+#define GEX_PLAT_F072 1
35
+
36
+// size, determines position of the flash storage
37
+#define FLASH_SIZE (128*1024)
38
+#define SETTINGS_BLOCK_SIZE (1024*2) // this must be a multiple of FLASH pages
39
+#define SETTINGS_FLASH_ADDR (0x08000000 + FLASH_SIZE - SETTINGS_BLOCK_SIZE)
40
+
41
+// Number of GPIO ports A,B,C,D,E,F
42
+#define PORTS_COUNT 6
43
+#define PLAT_USB_PU_CTL 1
44
+
45
+#if defined(GEX_PLAT_F072_DISCOVERY)
46
+    // platform name for the version string
47
+    #define GEX_PLATFORM "STM32F072-Discovery"
48
+
49
+    // Lock jumper config
50
+    #define LOCK_JUMPER_PORT 'A'
51
+    #define LOCK_JUMPER_PIN  0
52
+    #define PLAT_LOCK_BTN 1 // toggle button instead of a jumper
53
+    #define PLAT_LOCK_1CLOSED 1 // toggle button active in log. 1
54
+
55
+    // Status LED config
56
+    #define STATUS_LED_PORT 'C'
57
+    #define STATUS_LED_PIN  6 // RED LED "UP"
58
+#elif defined(GEX_PLAT_F072_HUB)
59
+    // platform name for the version string
60
+    #define GEX_PLATFORM "STM32F072-HUB"
61
+
62
+    #define PLAT_FULL_XTAL 1
63
+
64
+    // Lock jumper config
65
+    #define LOCK_JUMPER_PORT 'D'
66
+    #define LOCK_JUMPER_PIN  2
67
+    #define PLAT_LOCK_BTN 1 // toggle button instead of a jumper
68
+    #define PLAT_LOCK_1CLOSED 0 // toggle button active in log. 1
69
+
70
+    // Status LED config
71
+    #define STATUS_LED_PORT 'A'
72
+    #define STATUS_LED_PIN  15 // RED LED "UP"
73
+#elif defined(GEX_PLAT_F072_ZERO)
74
+    // platform name for the version string
75
+    #define GEX_PLATFORM "STM32F072-ZERO"
76
+
77
+    #define PLAT_FULL_XTAL 1
78
+
79
+    // Lock jumper config
80
+    #define LOCK_JUMPER_PORT 'D'
81
+    #define LOCK_JUMPER_PIN  2
82
+    #define PLAT_LOCK_BTN 1 // toggle button instead of a jumper
83
+    #define PLAT_LOCK_1CLOSED 1 // toggle button active in log. 1
84
+
85
+    // Status LED config
86
+    #define STATUS_LED_PORT 'A'
87
+    #define STATUS_LED_PIN  15
88
+
89
+    #define SUPPORT_NRF 1
90
+#else
91
+    #error Bad platform
92
+#endif
93
+
94
+// Debug UART
95
+#define DEBUG_USART_BAUD 115200
96
+#define DEBUG_USART USART1
97
+#define DEBUG_USART_RSC R_USART1
98
+#define DEBUG_USART_PORT 'A'
99
+#define DEBUG_USART_PIN  9
100
+#define DEBUG_USART_AF  1
101
+#define DEBUG_USART_PCLK PLAT_APB1_HZ
102
+
103
+// FreeRTOS config
104
+#define PLAT_FREERTOS_LOWEST_INTERRUPT_PRIORITY          3
105
+#define PLAT_FREERTOS_MAX_SYSCALL_INTERRUPT_PRIORITY     1
106
+#define PLAT_FREERTOS_PRIO_BITS                          2
107
+#define PLAT_FREERTOS_USE_PORT_OPTIMISED_TASK_SELECTION  0
108
+
109
+#endif //GEX_PLAT_COMPAT_H

+ 62 - 0
Src/platform_resources.c View File

@@ -0,0 +1,62 @@
1
+//
2
+// Created by MightyPork on 2018/07/07.
3
+//
4
+
5
+#include "platform.h"
6
+#include "resources.h"
7
+
8
+uint32_t plat_init_resources2(void)
9
+{
10
+    uint32_t rv = 0; // accumulate error codes
11
+
12
+    // Free all present resources
13
+    {
14
+        rsc_free(NULL, R_ADC1);
15
+//        rsc_free(NULL, R_CAN1);
16
+//        rsc_free_range(NULL, R_COMP1, R_COMP2);
17
+        rsc_free(NULL, R_DAC1);
18
+//        rsc_free(NULL, R_HDMI_CEC);
19
+        rsc_free(NULL, R_TSC);
20
+        rsc_free_range(NULL, R_I2C1, R_I2C2);
21
+//        rsc_free_range(NULL, R_I2S1, R_I2S2);
22
+        rsc_free_range(NULL, R_SPI1, R_SPI2);
23
+        rsc_free_range(NULL, R_TIM1, R_TIM3);
24
+        rsc_free_range(NULL, R_TIM6, R_TIM7);
25
+        rsc_free_range(NULL, R_TIM14, R_TIM17);
26
+        rsc_free_range(NULL, R_USART1, R_USART4);
27
+        rsc_free_range(NULL, R_DMA1_1, R_DMA1_7);
28
+
29
+        rsc_free_range(NULL, R_PA0, R_PA15);
30
+        rsc_free_range(NULL, R_PB0, R_PB15);
31
+        rsc_free_range(NULL, R_PC0, R_PC15);
32
+        rsc_free(NULL, R_PD2);
33
+        rsc_free_range(NULL, R_PF0, R_PF1);
34
+    }
35
+
36
+    // Claim resources not available due to board layout or internal usage
37
+    {
38
+        // HAL timebase
39
+        rv |= rsc_claim(&UNIT_SYSTEM, R_TIM17);
40
+        // HSE crystal
41
+        rv |= rsc_claim(&UNIT_SYSTEM, R_PF0);
42
+
43
+#if PLAT_FULL_XTAL
44
+        rv |= rsc_claim(&UNIT_SYSTEM, R_PF1); // - not used in BYPASS mode
45
+#endif
46
+
47
+        // SWD
48
+//        rv |= rsc_claim(&UNIT_SYSTEM, R_PA13);
49
+//        rv |= rsc_claim(&UNIT_SYSTEM, R_PA14);
50
+        // USB
51
+        rv |= rsc_claim(&UNIT_SYSTEM, R_PA11);
52
+        rv |= rsc_claim(&UNIT_SYSTEM, R_PA12);
53
+
54
+#if defined(GEX_PLAT_F072_ZERO)
55
+        // unconnected pins
56
+        rv |= rsc_claim_range(&UNIT_PLATFORM, R_PC0, R_PC1);
57
+        rv |= rsc_claim_range(&UNIT_PLATFORM, R_PC4, R_PC9);
58
+#endif
59
+    }
60
+
61
+    return rv;
62
+}