1 /*
2  * Copyright (C) 2016 The Android Open Source Project
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 _VARIANT_LUNCHBOX_H_
18 #define _VARIANT_LUNCHBOX_H_
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #define PLATFORM_HW_TYPE  0x4C75   // 'Lu' -> lunchbox
25 //#define DEBUG_UART_PIN    16       // GPIOB0 is debug uart at 2MBps
26 
27 #define VARIANT_VER                 0x00000000
28 
29 //we have LSE in lunchbox
30 #define RTC_CLK                     RTC_CLK_LSE
31 // fCAL = fRTCCLK x [1 + (256 - CALM) / (2^20 + CALM - 256)]
32 // 32764.505 * (1 + (256 - 144)/(1048576 + 144 - 256)) = 32768.005
33 #define RTC_PREDIV_A                0UL
34 #define RTC_PREDIV_S                32759UL
35 #define RTC_CALM                    144UL
36 #define RTC_CALP                    0UL
37 
38 //spi bus for comms
39 #define PLATFORM_HOST_INTF_SPI_BUS  0
40 
41 #define SH_INT_WAKEUP               GPIO_PA(2)
42 #define SH_EXTI_WAKEUP_IRQ          EXTI2_IRQn
43 #define AP_INT_WAKEUP               GPIO_PA(3)
44 #undef AP_INT_NONWAKEUP
45 
46 #define DEBUG_LOG_EVT               0x3B474F4C
47 
48 #define BL_FLASH_TABLE                                                  \
49 {                                                                       \
50     { (uint8_t *)(&BL),                      0x04000, BL_FLASH_BL     },\
51     { (uint8_t *)(__eedata_start),           0x04000, BL_FLASH_EEDATA },\
52     { (uint8_t *)(__eedata_start + 0x04000), 0x04000, BL_FLASH_EEDATA },\
53     { (uint8_t *)(__code_start),             0x04000, BL_FLASH_KERNEL },\
54     { (uint8_t *)(__code_start + 0x04000),   0x10000, BL_FLASH_KERNEL },\
55     { (uint8_t *)(__code_start + 0x10000),   0x20000, BL_FLASH_KERNEL },\
56     { (uint8_t *)(__shared_start),           0x20000, BL_FLASH_SHARED },\
57     { (uint8_t *)(__shared_start + 0x20000), 0x20000, BL_FLASH_SHARED },\
58 }
59 
60 #define BMP280_I2C_BUS_ID           0
61 
62 #define BMI160_TO_ANDROID_COORDINATE(x, y, z)   \
63     do {                                        \
64         int32_t xi = x, yi = y, zi = z;         \
65         x = -yi; y = xi; z = zi;                \
66     } while (0)
67 
68 #define BMM150_TO_ANDROID_COORDINATE(x, y, z)   \
69     do {                                        \
70         int32_t xi = x, yi = y, zi = z;         \
71         x = xi; y = -yi; z = -zi;               \
72     } while (0)
73 
74 #define HALL_PIN        GPIO_PA(9)
75 #define HALL_IRQ        EXTI9_5_IRQn
76 
77 #define VSYNC_PIN       GPIO_PB(1)
78 #define VSYNC_IRQ       EXTI1_IRQn
79 
80 #define PROX_INT_PIN    GPIO_PB(10)
81 #define PROX_IRQ        EXTI15_10_IRQn
82 #define PROX_I2C_BUS_ID 0
83 
84 //define tap sensor threshold
85 #define TAP_THRESHOLD   0x01
86 
87 //define Accelerometer fast compensation config
88 #define ACC_FOC_CONFIG  0x3d
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif
95