PixArt Optical Track Sensor, OTS, library initial release v1.0. Supports PAT9125, PAT9126, PAT9130, PAA5101. Future to support PAT9150.

Fork of Pixart_OTS by Hill Chen

Committer:
PixArtHC
Date:
Wed Mar 06 21:02:39 2019 +0000
Revision:
0:2a85075b8467
Child:
1:95917b856631
PixArt Optical Track Sensor, OTS, library initial release v1.0. Supports PAT9125, PAT9126, PAT9130, PAA5101. Future to support PAT9150.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
PixArtHC 0:2a85075b8467 1 /* PixArt Optical Finger Navigation, OFN, sensor driver.
PixArtHC 0:2a85075b8467 2 * By PixArt Imaging Inc.
PixArtHC 0:2a85075b8467 3 * Primary Engineer: Hill Chen (PixArt USA)
PixArtHC 0:2a85075b8467 4 *
PixArtHC 0:2a85075b8467 5 * License: Apache-2.0; http://www.apache.org/licenses/LICENSE-2.0
PixArtHC 0:2a85075b8467 6 */
PixArtHC 0:2a85075b8467 7
PixArtHC 0:2a85075b8467 8 #pragma once
PixArtHC 0:2a85075b8467 9 #include <stdint.h>
PixArtHC 0:2a85075b8467 10
PixArtHC 0:2a85075b8467 11 static const uint8_t Pixart_OTS_9125_InitSetting[][2] =
PixArtHC 0:2a85075b8467 12 {
PixArtHC 0:2a85075b8467 13 { 0x7F, 0x00 }, //Switch to bank0
PixArtHC 0:2a85075b8467 14 { 0x09, 0x5A }, //Disables write-protect.
PixArtHC 0:2a85075b8467 15 { 0x0D, 0x65 }, //Sets X-axis resolution (necessary value here will depend on physical design and application).
PixArtHC 0:2a85075b8467 16 { 0x0E, 0xFF }, //Sets Y-axis resolution (necessary value here will depend on physical design and application).
PixArtHC 0:2a85075b8467 17 { 0x19, 0x04 }, //Sets 12-bit X/Y data format.
PixArtHC 0:2a85075b8467 18 //{ 0x4B, 0x04 }, //Needed for when using low-voltage rail (1.7-1.9V): Power saving configuration.
PixArtHC 0:2a85075b8467 19 { 0x09, 0x00 }, //Enable write protect
PixArtHC 0:2a85075b8467 20 };
PixArtHC 0:2a85075b8467 21
PixArtHC 0:2a85075b8467 22 static const uint8_t Pixart_OTS_9126_InitSetting[][2] =
PixArtHC 0:2a85075b8467 23 {
PixArtHC 0:2a85075b8467 24 { 0x09, 0x5A }, //Disables write-protect.
PixArtHC 0:2a85075b8467 25 { 0x0D, 0x65 }, //Sets X-axis resolution (necessary value here will depend on physical design and application).
PixArtHC 0:2a85075b8467 26 //{ 0x0E, 0x00 }, //Sets Y-axis resolution (necessary value here will depend on physical design and application).
PixArtHC 0:2a85075b8467 27 { 0x0E, 0x05 }, //Sets Y-axis resolution to a small number for demo, set 0 to avoid Y count.
PixArtHC 0:2a85075b8467 28 { 0x19, 0x04 }, //Sets 12-bit X/Y data format.
PixArtHC 0:2a85075b8467 29 //{ 0x4B, 0x04 }, //Needed for when using low-voltage rail (1.7-1.9V): Power saving configuration.
PixArtHC 0:2a85075b8467 30 { 0x7C, 0x82 },
PixArtHC 0:2a85075b8467 31 { 0x2B, 0x6D },
PixArtHC 0:2a85075b8467 32 { 0x2D, 0x00 },
PixArtHC 0:2a85075b8467 33 { 0x09, 0x00 }, //Enable write protect
PixArtHC 0:2a85075b8467 34 };
PixArtHC 0:2a85075b8467 35
PixArtHC 0:2a85075b8467 36 static const uint8_t Pixart_OTS_9150_InitSetting[][2] =
PixArtHC 0:2a85075b8467 37 {
PixArtHC 0:2a85075b8467 38 { 0x7F, 0x00 }, //Switch to bank0
PixArtHC 0:2a85075b8467 39 { 0x09, 0x5A }, //Disables write-protect.
PixArtHC 0:2a85075b8467 40
PixArtHC 0:2a85075b8467 41 { 0x09, 0x00 }, //Enable write protect
PixArtHC 0:2a85075b8467 42 };
PixArtHC 0:2a85075b8467 43
PixArtHC 0:2a85075b8467 44 static const uint8_t Pixart_OTS_9130_InitSetting[][2] =
PixArtHC 0:2a85075b8467 45 {
PixArtHC 0:2a85075b8467 46 { 0x7F, 0x00 }, // switch to bank0, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 47 { 0x05, 0xA8 }, // sleep mode disabled
PixArtHC 0:2a85075b8467 48 { 0x09, 0x5A }, // disable write protect
PixArtHC 0:2a85075b8467 49 { 0x51, 0x06 }, // set LD current source to 6
PixArtHC 0:2a85075b8467 50 { 0x0D, 0x1F }, // CPI resolution setting for X-direction
PixArtHC 0:2a85075b8467 51 { 0x0E, 0x1F }, // CPI resolution setting for Y-direction
PixArtHC 0:2a85075b8467 52 { 0x07, 0x00 },
PixArtHC 0:2a85075b8467 53 { 0x1B, 0x42 },
PixArtHC 0:2a85075b8467 54 { 0x2E, 0x40 },
PixArtHC 0:2a85075b8467 55 { 0x32, 0x40 },
PixArtHC 0:2a85075b8467 56 { 0x33, 0x02 },
PixArtHC 0:2a85075b8467 57 { 0x34, 0x00 },
PixArtHC 0:2a85075b8467 58 { 0x36, 0xE0 },
PixArtHC 0:2a85075b8467 59 { 0x38, 0xA0 },
PixArtHC 0:2a85075b8467 60 { 0x39, 0x01 },
PixArtHC 0:2a85075b8467 61 { 0x3E, 0x14 },
PixArtHC 0:2a85075b8467 62 { 0x44, 0x02 },
PixArtHC 0:2a85075b8467 63 { 0x4A, 0xE0 },
PixArtHC 0:2a85075b8467 64 { 0x4F, 0x02 },
PixArtHC 0:2a85075b8467 65 { 0x52, 0x0D }, // Turn off internal VDDA
PixArtHC 0:2a85075b8467 66 { 0x57, 0x03 },
PixArtHC 0:2a85075b8467 67 { 0x59, 0x03 },
PixArtHC 0:2a85075b8467 68 { 0x5B, 0x03 },
PixArtHC 0:2a85075b8467 69 { 0x5C, 0xFF },
PixArtHC 0:2a85075b8467 70
PixArtHC 0:2a85075b8467 71 { 0x7F, 0x01 }, // switch to bank1, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 72 { 0x00, 0x25 },
PixArtHC 0:2a85075b8467 73 { 0x07, 0x78 },
PixArtHC 0:2a85075b8467 74 { 0x20, 0x00 },
PixArtHC 0:2a85075b8467 75 { 0x21, 0x40 },
PixArtHC 0:2a85075b8467 76 { 0x23, 0x00 },
PixArtHC 0:2a85075b8467 77 { 0x2F, 0x64 },
PixArtHC 0:2a85075b8467 78 { 0x37, 0x30 },
PixArtHC 0:2a85075b8467 79 { 0x3B, 0x64 },
PixArtHC 0:2a85075b8467 80 { 0x43, 0x0A },
PixArtHC 0:2a85075b8467 81 { 0x59, 0x01 },
PixArtHC 0:2a85075b8467 82 { 0x5A, 0x01 },
PixArtHC 0:2a85075b8467 83 { 0x5C, 0x04 },
PixArtHC 0:2a85075b8467 84 { 0x5E, 0x04 },
PixArtHC 0:2a85075b8467 85
PixArtHC 0:2a85075b8467 86 { 0x7F, 0x02 }, // switch to bank2, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 87 { 0x51, 0x02 },
PixArtHC 0:2a85075b8467 88
PixArtHC 0:2a85075b8467 89 { 0x7F, 0x03 }, // switch to bank3, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 90 { 0x05, 0x0C },
PixArtHC 0:2a85075b8467 91 { 0x06, 0x0C },
PixArtHC 0:2a85075b8467 92 { 0x07, 0x0C },
PixArtHC 0:2a85075b8467 93 { 0x08, 0x0C },
PixArtHC 0:2a85075b8467 94
PixArtHC 0:2a85075b8467 95 { 0x7F, 0x04 }, // switch to bank4, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 96 { 0x05, 0x01 },
PixArtHC 0:2a85075b8467 97 { 0x53, 0x08 },
PixArtHC 0:2a85075b8467 98
PixArtHC 0:2a85075b8467 99 { 0x7F, 0x05 }, // switch to bank5, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 100 { 0x00, 0x02 },
PixArtHC 0:2a85075b8467 101 { 0x09, 0x01 },
PixArtHC 0:2a85075b8467 102 { 0x0A, 0x1C },
PixArtHC 0:2a85075b8467 103 { 0x0B, 0x24 },
PixArtHC 0:2a85075b8467 104 { 0x0C, 0x1C },
PixArtHC 0:2a85075b8467 105 { 0x0D, 0x24 },
PixArtHC 0:2a85075b8467 106 { 0x12, 0x08 },
PixArtHC 0:2a85075b8467 107 { 0x14, 0x02 },
PixArtHC 0:2a85075b8467 108 { 0x16, 0x02 },
PixArtHC 0:2a85075b8467 109 { 0x18, 0x1C },
PixArtHC 0:2a85075b8467 110 { 0x19, 0x24 },
PixArtHC 0:2a85075b8467 111 { 0x1A, 0x1C },
PixArtHC 0:2a85075b8467 112 { 0x1B, 0x24 },
PixArtHC 0:2a85075b8467 113 { 0x20, 0x08 },
PixArtHC 0:2a85075b8467 114 { 0x22, 0x02 },
PixArtHC 0:2a85075b8467 115 { 0x24, 0x02 },
PixArtHC 0:2a85075b8467 116 { 0x26, 0x88 },
PixArtHC 0:2a85075b8467 117 { 0x2F, 0x7C },
PixArtHC 0:2a85075b8467 118 { 0x30, 0x07 },
PixArtHC 0:2a85075b8467 119 { 0x3D, 0x00 },
PixArtHC 0:2a85075b8467 120 { 0x3E, 0x98 },
PixArtHC 0:2a85075b8467 121
PixArtHC 0:2a85075b8467 122 { 0x7F, 0x06 }, // switch to bank6, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 123 { 0x34, 0x03 },
PixArtHC 0:2a85075b8467 124
PixArtHC 0:2a85075b8467 125 { 0x7F, 0x07 }, // switch to bank7, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 126 { 0x00, 0x01 },
PixArtHC 0:2a85075b8467 127 { 0x02, 0xC4 },
PixArtHC 0:2a85075b8467 128 { 0x03, 0x13 },
PixArtHC 0:2a85075b8467 129 { 0x06, 0x0C },
PixArtHC 0:2a85075b8467 130 { 0x0F, 0x0A },
PixArtHC 0:2a85075b8467 131 { 0x14, 0x02 },
PixArtHC 0:2a85075b8467 132 { 0x35, 0x39 },
PixArtHC 0:2a85075b8467 133 { 0x36, 0x3F },
PixArtHC 0:2a85075b8467 134 { 0x46, 0x03 },
PixArtHC 0:2a85075b8467 135 { 0x47, 0x0F },
PixArtHC 0:2a85075b8467 136 { 0x4B, 0x97 },
PixArtHC 0:2a85075b8467 137
PixArtHC 0:2a85075b8467 138 { 0x7F, 0x00 }, // switch to bank0, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 139 { 0x09, 0x00 }, // enable write protect
PixArtHC 0:2a85075b8467 140 };
PixArtHC 0:2a85075b8467 141
PixArtHC 0:2a85075b8467 142 static const uint8_t Pixart_OTS_5101_InitSetting[][2] =
PixArtHC 0:2a85075b8467 143 {
PixArtHC 0:2a85075b8467 144 { 0x7F,0x00 }, // Bank0, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 145 { 0x05,0xA8 },
PixArtHC 0:2a85075b8467 146 { 0x07,0xCC },
PixArtHC 0:2a85075b8467 147 { 0x0A,0x17 },
PixArtHC 0:2a85075b8467 148 { 0x0D,0x05 },
PixArtHC 0:2a85075b8467 149 { 0x0E,0x05 },
PixArtHC 0:2a85075b8467 150 { 0x1B,0x43 },
PixArtHC 0:2a85075b8467 151 { 0x25,0x2E },
PixArtHC 0:2a85075b8467 152 { 0x26,0x35 },
PixArtHC 0:2a85075b8467 153 { 0x2E,0x40 },
PixArtHC 0:2a85075b8467 154 { 0x32,0x40 },
PixArtHC 0:2a85075b8467 155 { 0x33,0x02 },
PixArtHC 0:2a85075b8467 156 { 0x34,0x00 },
PixArtHC 0:2a85075b8467 157 { 0x36,0xE0 },
PixArtHC 0:2a85075b8467 158 { 0x3E,0x14 },
PixArtHC 0:2a85075b8467 159 { 0x44,0x02 },
PixArtHC 0:2a85075b8467 160 { 0x51,0x06 },
PixArtHC 0:2a85075b8467 161 { 0x52,0x0C },
PixArtHC 0:2a85075b8467 162 { 0x57,0x05 },
PixArtHC 0:2a85075b8467 163 { 0x59,0x03 },
PixArtHC 0:2a85075b8467 164 { 0x5B,0x04 },
PixArtHC 0:2a85075b8467 165 { 0x5D,0x3B },
PixArtHC 0:2a85075b8467 166 { 0x7C,0xC8 },
PixArtHC 0:2a85075b8467 167
PixArtHC 0:2a85075b8467 168 { 0x7F,0x01 }, // Bank1, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 169 { 0x00,0x2F },
PixArtHC 0:2a85075b8467 170 { 0x08,0x1C },
PixArtHC 0:2a85075b8467 171 { 0x0A,0x02 },
PixArtHC 0:2a85075b8467 172 { 0x19,0x40 },
PixArtHC 0:2a85075b8467 173 { 0x1B,0x10 },
PixArtHC 0:2a85075b8467 174 { 0x1D,0x18 },
PixArtHC 0:2a85075b8467 175 { 0x1F,0x12 },
PixArtHC 0:2a85075b8467 176 { 0x20,0x00 },
PixArtHC 0:2a85075b8467 177 { 0x21,0x80 },
PixArtHC 0:2a85075b8467 178 { 0x23,0x60 },
PixArtHC 0:2a85075b8467 179 { 0x25,0x64 },
PixArtHC 0:2a85075b8467 180 { 0x27,0x64 },
PixArtHC 0:2a85075b8467 181 { 0x2B,0x78 },
PixArtHC 0:2a85075b8467 182 { 0x2F,0x78 },
PixArtHC 0:2a85075b8467 183 { 0x39,0x78 },
PixArtHC 0:2a85075b8467 184 { 0x3B,0x78 },
PixArtHC 0:2a85075b8467 185 { 0x3D,0x78 },
PixArtHC 0:2a85075b8467 186 { 0x3F,0x78 },
PixArtHC 0:2a85075b8467 187 { 0x44,0x7E },
PixArtHC 0:2a85075b8467 188 { 0x45,0xF4 },
PixArtHC 0:2a85075b8467 189 { 0x46,0x01 },
PixArtHC 0:2a85075b8467 190 { 0x47,0x2C },
PixArtHC 0:2a85075b8467 191 { 0x49,0x90 },
PixArtHC 0:2a85075b8467 192 { 0x4A,0x05 },
PixArtHC 0:2a85075b8467 193 { 0x4B,0xDC },
PixArtHC 0:2a85075b8467 194 { 0x4C,0x07 },
PixArtHC 0:2a85075b8467 195 { 0x4D,0x08 },
PixArtHC 0:2a85075b8467 196 { 0x51,0x02 },
PixArtHC 0:2a85075b8467 197 { 0x52,0xBC },
PixArtHC 0:2a85075b8467 198 { 0x53,0x02 },
PixArtHC 0:2a85075b8467 199 { 0x54,0xBC },
PixArtHC 0:2a85075b8467 200 { 0x55,0x07 },
PixArtHC 0:2a85075b8467 201 { 0x56,0x08 },
PixArtHC 0:2a85075b8467 202 { 0x57,0x07 },
PixArtHC 0:2a85075b8467 203 { 0x58,0x08 },
PixArtHC 0:2a85075b8467 204 { 0x59,0x08 },
PixArtHC 0:2a85075b8467 205 { 0x5A,0x08 },
PixArtHC 0:2a85075b8467 206
PixArtHC 0:2a85075b8467 207 { 0x7F,0x02 }, // Bank2, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 208 { 0x07,0x1B },
PixArtHC 0:2a85075b8467 209 { 0x08,0x1F },
PixArtHC 0:2a85075b8467 210 { 0x09,0x23 },
PixArtHC 0:2a85075b8467 211 { 0x51,0x01 },
PixArtHC 0:2a85075b8467 212
PixArtHC 0:2a85075b8467 213 { 0x7F,0x03 }, // Bank3, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 214 { 0x07,0x07 },
PixArtHC 0:2a85075b8467 215 { 0x08,0x06 },
PixArtHC 0:2a85075b8467 216 { 0x2F,0x00 },
PixArtHC 0:2a85075b8467 217 { 0x30,0x20 },
PixArtHC 0:2a85075b8467 218 { 0x32,0x59 },
PixArtHC 0:2a85075b8467 219 { 0x33,0xD8 },
PixArtHC 0:2a85075b8467 220 { 0x34,0x4E },
PixArtHC 0:2a85075b8467 221 { 0x35,0x20 },
PixArtHC 0:2a85075b8467 222 { 0x36,0x5B },
PixArtHC 0:2a85075b8467 223 { 0x37,0xCC },
PixArtHC 0:2a85075b8467 224 { 0x38,0x50 },
PixArtHC 0:2a85075b8467 225 { 0x39,0x14 },
PixArtHC 0:2a85075b8467 226
PixArtHC 0:2a85075b8467 227 { 0x7F,0x04 }, // Bank4, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 228 { 0x05,0x01 },
PixArtHC 0:2a85075b8467 229 { 0x2C,0x06 },
PixArtHC 0:2a85075b8467 230 { 0x2E,0x0C },
PixArtHC 0:2a85075b8467 231 { 0x30,0x0C },
PixArtHC 0:2a85075b8467 232 { 0x32,0x06 },
PixArtHC 0:2a85075b8467 233 { 0x34,0x03 },
PixArtHC 0:2a85075b8467 234 { 0x38,0x17 },
PixArtHC 0:2a85075b8467 235 { 0x39,0x71 },
PixArtHC 0:2a85075b8467 236 { 0x3A,0x18 },
PixArtHC 0:2a85075b8467 237 { 0x3B,0x4D },
PixArtHC 0:2a85075b8467 238 { 0x3C,0x18 },
PixArtHC 0:2a85075b8467 239 { 0x3D,0x4D },
PixArtHC 0:2a85075b8467 240 { 0x3E,0x14 },
PixArtHC 0:2a85075b8467 241 { 0x3F,0xD1 },
PixArtHC 0:2a85075b8467 242 { 0x40,0x14 },
PixArtHC 0:2a85075b8467 243 { 0x41,0xDD },
PixArtHC 0:2a85075b8467 244 { 0x42,0x0A },
PixArtHC 0:2a85075b8467 245 { 0x43,0x6C },
PixArtHC 0:2a85075b8467 246 { 0x44,0x08 },
PixArtHC 0:2a85075b8467 247 { 0x45,0xAD },
PixArtHC 0:2a85075b8467 248 { 0x46,0x06 },
PixArtHC 0:2a85075b8467 249 { 0x47,0xF2 },
PixArtHC 0:2a85075b8467 250 { 0x48,0x06 },
PixArtHC 0:2a85075b8467 251 { 0x49,0xEC },
PixArtHC 0:2a85075b8467 252 { 0x4A,0x06 },
PixArtHC 0:2a85075b8467 253 { 0x4B,0xEC },
PixArtHC 0:2a85075b8467 254 { 0x53,0x08 },
PixArtHC 0:2a85075b8467 255
PixArtHC 0:2a85075b8467 256 { 0x7F,0x05 }, // Bank5, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 257 { 0x03,0x00 },
PixArtHC 0:2a85075b8467 258 { 0x09,0x01 },
PixArtHC 0:2a85075b8467 259 { 0x0B,0xFF },
PixArtHC 0:2a85075b8467 260 { 0x0D,0xFF },
PixArtHC 0:2a85075b8467 261 { 0x0F,0xFF },
PixArtHC 0:2a85075b8467 262 { 0x11,0xFF },
PixArtHC 0:2a85075b8467 263 { 0x12,0xD2 },
PixArtHC 0:2a85075b8467 264 { 0x13,0xD2 },
PixArtHC 0:2a85075b8467 265 { 0x19,0xFF },
PixArtHC 0:2a85075b8467 266 { 0x1B,0xFF },
PixArtHC 0:2a85075b8467 267 { 0x1D,0xFF },
PixArtHC 0:2a85075b8467 268 { 0x1F,0xFF },
PixArtHC 0:2a85075b8467 269 { 0x20,0xD2 },
PixArtHC 0:2a85075b8467 270 { 0x21,0xD2 },
PixArtHC 0:2a85075b8467 271 { 0x2F,0x7C },
PixArtHC 0:2a85075b8467 272 { 0x30,0x05 },
PixArtHC 0:2a85075b8467 273 { 0x41,0x02 },
PixArtHC 0:2a85075b8467 274 { 0x53,0xFF },
PixArtHC 0:2a85075b8467 275 { 0x5F,0x02 },
PixArtHC 0:2a85075b8467 276
PixArtHC 0:2a85075b8467 277 { 0x7F,0x06 }, // Bank6, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 278 { 0x2A,0x05 }, // Write ONLY address, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 279 { 0x35,0x19 },
PixArtHC 0:2a85075b8467 280
PixArtHC 0:2a85075b8467 281 { 0x7F,0x07 }, // Bank7, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 282 { 0x00,0x01 },
PixArtHC 0:2a85075b8467 283 { 0x14,0x03 },
PixArtHC 0:2a85075b8467 284 { 0x15,0x14 },
PixArtHC 0:2a85075b8467 285 { 0x46,0x03 },
PixArtHC 0:2a85075b8467 286
PixArtHC 0:2a85075b8467 287 { 0x7F,0x00 }, // Bank0, not allowed to perform SPIWriteRead
PixArtHC 0:2a85075b8467 288 };