summaryrefslogtreecommitdiff
path: root/firmware/inc/platform/stm32f4xx/plat.h
blob: c07ae5643a0d05562cddbfee868f82db736c494a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _STM32_PLAT_H_
#define _STM32_PLAT_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <stdbool.h>
#include <seos.h>

enum PlatSleepDevID
{
    Stm32sleepDevTim2, /* we use this for short sleeps in WFI mode */
    Stm32sleepDevTim4, /* input capture uses this, potentially */
    Stm32sleepDevTim5, /* input capture uses this, potentially */
    Stm32sleepDevTim9, /* input capture uses this, potentially */
    Stm32sleepWakeup,  /* we use this to wakeup from AP */
    Stm32sleepDevSpi2, /* we use this to prevent stop mode during spi2 xfers */
    Stm32sleepDevSpi3, /* we use this to prevent stop mode during spi3 xfers */
    Stm32sleepDevI2c1, /* we use this to prevent stop mode during i2c1 xfers */
    Stm32sleepDevExti, /* we use this for max external interrupt latency */

    Stm32sleepDevNum,  //must be last always, and must be <= PLAT_MAX_SLEEP_DEVS
};

static inline const struct AppHdr* platGetInternalAppList(uint32_t *numAppsP)
{
    extern const struct AppHdr __internal_app_start, __internal_app_end;

    *numAppsP = &__internal_app_end - &__internal_app_start;
    return &__internal_app_start;
}

static inline uint8_t* platGetSharedAreaInfo(uint32_t *areaSzP)
{
    extern uint8_t __shared_start[];
    extern uint8_t __shared_end[];

    *areaSzP = __shared_end - __shared_start;
    return __shared_start;
}

//used for dropbox
void* platGetPersistentRamStore(uint32_t *bytes);

static inline void platWake(void)
{
}

// GCC aligns 64-bit types on an 8-byte boundary, but Cortex-M4 only requires
// 4-byte alignment for these types. So limit the return value, as we're
// interested in the minimum alignment requirement.
#if defined(__GNUC__) && !defined(alignof)
#define alignof(type) ((__alignof__(type) > 4) ? 4 : __alignof__(type))
#endif

#ifdef __cplusplus
}
#endif

#endif