Skip to content

Commit e4b1509

Browse files
author
Seppo Takalo
committed
Add enough stubs to allow drivers/* to compile.
1 parent 7831b8f commit e4b1509

File tree

9 files changed

+231
-4
lines changed

9 files changed

+231
-4
lines changed

UNITTESTS/target_h/PinNames.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,18 @@ typedef enum {
3434
} PinName;
3535

3636
typedef enum {
37+
PullNone,
38+
PullUp,
39+
PullDown
3740
} PinMode;
3841

42+
typedef enum {
43+
PortA = 0,
44+
} PortName;
45+
3946
#ifdef __cplusplus
4047
}
4148
#endif
49+
#include "pinmap.h"
4250

4351
#endif

UNITTESTS/target_h/cmsis_os2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ typedef void *osEventFlagsId_t;
6464

6565
/// Attributes structure for thread.
6666
typedef struct {
67+
int unused;
6768
} osThreadAttr_t;
6869

6970
#define osWaitForever 0xFFFFFFFFU ///< Wait forever timeout value.

UNITTESTS/target_h/device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
#define MBED_DEVICE_H
2020

2121
#include "objects.h"
22+
#include "PinNames.h"
2223

2324
#endif

UNITTESTS/target_h/gpio_object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extern "C" {
2727
#endif
2828

2929
typedef struct {
30+
int unused;
3031
} gpio_t;
3132

3233
#ifdef __cplusplus

UNITTESTS/target_h/objects.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,42 @@ struct serial_s {
3333
int x;
3434
};
3535

36+
struct dac_s {
37+
int unused;
38+
};
39+
40+
struct i2c_s {
41+
int unused;
42+
};
43+
44+
struct qspi_s {
45+
int unused;
46+
};
47+
48+
struct spi_s {
49+
int unused;
50+
};
51+
52+
struct analogin_s {
53+
int unused;
54+
};
55+
56+
struct port_s {
57+
int unused;
58+
};
59+
60+
struct pwmout_s {
61+
int unused;
62+
};
63+
64+
struct flash_s {
65+
int unused;
66+
};
67+
68+
struct can_s {
69+
int unused;
70+
};
71+
3672
#include "gpio_object.h"
3773

3874
#ifdef __cplusplus

UNITTESTS/target_h/platform/CThunk.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* Copyright (c) 2019 ARM Limited
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef __CTHUNK_H__
18+
#define __CTHUNK_H__
19+
20+
/**
21+
* Class for created a pointer with data bound to it
22+
*
23+
* @note Synchronization level: Not protected
24+
*/
25+
template<class T>
26+
class CThunk {
27+
public:
28+
typedef void (T::*CCallbackSimple)(void);
29+
typedef void (T::*CCallback)(void *context);
30+
CThunk()
31+
{}
32+
CThunk(T *instance)
33+
{}
34+
CThunk(T &instance)
35+
{}
36+
void callback(CCallback callback)
37+
{}
38+
39+
void callback(CCallbackSimple callback)
40+
{
41+
}
42+
uint32_t entry(void)
43+
{
44+
45+
return 0;
46+
}
47+
};
48+
49+
50+
#endif/*__CTHUNK_H__*/
51+
52+

UNITTESTS/target_h/platform/mbed_power_mgmt.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,19 @@
2323
#define MBED_POWER_MGMT_H
2424
extern void mock_system_reset();
2525

26-
MBED_NORETURN static inline void system_reset(void)
26+
static inline void system_reset(void)
2727
{
2828
mock_system_reset();
2929
}
3030

31+
void sleep_manager_lock_deep_sleep(void)
32+
{
33+
}
34+
35+
void sleep_manager_unlock_deep_sleep(void)
36+
{
37+
}
38+
39+
3140
#endif
3241

UNITTESTS/target_h/rtos/Semaphore.h

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/*
2-
* Copyright (c) , Arm Limited and affiliates.
1+
/* Copyright (c) 2019 ARM Limited
32
* SPDX-License-Identifier: Apache-2.0
43
*
54
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,4 +14,23 @@
1514
* limitations under the License.
1615
*/
1716

18-
typedef void *Semaphore;
17+
#ifndef SEMAPHORE_H
18+
#define SEMAPHORE_H
19+
20+
#include <stdint.h>
21+
#include "cmsis_os2.h"
22+
23+
namespace rtos {
24+
class Semaphore {
25+
public:
26+
Semaphore(int32_t count = 0) {};
27+
Semaphore(int32_t count, uint16_t max_count) {};
28+
void acquire() {};
29+
bool try_acquire() { return false; };
30+
bool try_acquire_for(uint32_t millisec) { return false; };
31+
bool try_acquire_until(uint64_t millisec) { return false; };
32+
osStatus release(void) {return 0;};
33+
};
34+
}
35+
36+
#endif

UNITTESTS/target_h/rtos/Thread.h

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* Copyright (c) 2019 ARM Limited
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*/
22+
#ifndef THREAD_H
23+
#define THREAD_H
24+
25+
#include <stdint.h>
26+
#include "cmsis_os.h"
27+
28+
namespace rtos {
29+
30+
class Thread {
31+
public:
32+
33+
Thread(osPriority priority = osPriorityNormal,
34+
uint32_t stack_size = OS_STACK_SIZE,
35+
unsigned char *stack_mem = nullptr, const char *name = nullptr)
36+
{
37+
}
38+
39+
Thread(uint32_t tz_module, osPriority priority = osPriorityNormal,
40+
uint32_t stack_size = OS_STACK_SIZE,
41+
unsigned char *stack_mem = nullptr, const char *name = nullptr)
42+
{
43+
}
44+
45+
osStatus start(mbed::Callback<void()> task) {
46+
return 0;
47+
}
48+
49+
osStatus join() {return 0;};
50+
osStatus terminate(){return 0;};
51+
osStatus set_priority(osPriority priority){return 0;};
52+
osPriority get_priority() const{return osPriorityNormal;};
53+
uint32_t flags_set(uint32_t flags){return 0;};
54+
55+
/** State of the Thread */
56+
enum State {
57+
Inactive, /**< NOT USED */
58+
Ready, /**< Ready to run */
59+
Running, /**< Running */
60+
WaitingDelay, /**< Waiting for a delay to occur */
61+
WaitingJoin, /**< Waiting for thread to join. Only happens when using RTX directly. */
62+
WaitingThreadFlag, /**< Waiting for a thread flag to be set */
63+
WaitingEventFlag, /**< Waiting for a event flag to be set */
64+
WaitingMutex, /**< Waiting for a mutex event to occur */
65+
WaitingSemaphore, /**< Waiting for a semaphore event to occur */
66+
WaitingMemoryPool, /**< Waiting for a memory pool */
67+
WaitingMessageGet, /**< Waiting for message to arrive */
68+
WaitingMessagePut, /**< Waiting for message to be send */
69+
WaitingInterval, /**< NOT USED */
70+
WaitingOr, /**< NOT USED */
71+
WaitingAnd, /**< NOT USED */
72+
WaitingMailbox, /**< NOT USED (Mail is implemented as MemoryPool and Queue) */
73+
74+
/* Not in sync with RTX below here */
75+
Deleted, /**< The task has been deleted or not started */
76+
};
77+
78+
State get_state() const {
79+
return Ready;
80+
};
81+
uint32_t stack_size() const {
82+
return 0;
83+
};
84+
uint32_t free_stack() const {
85+
return 0;
86+
};
87+
uint32_t used_stack() const {
88+
return 0;
89+
};
90+
uint32_t max_stack() const {
91+
return 0;
92+
};
93+
const char *get_name() const {
94+
return "";
95+
};
96+
osThreadId_t get_id() const {
97+
return 0;
98+
};
99+
};
100+
}
101+
#endif

0 commit comments

Comments
 (0)