1
1
/*
2
- * TODO: Add license.
3
- * Copyright (c) 2021
2
+ * Copyright 2021 Arduino SA
4
3
*
5
- * This work is licensed under <>, see the file LICENSE for details.
4
+ * This program is free software: you can redistribute it and/or modify
5
+ * it under the terms of the GNU Lesser General Public License as published by
6
+ * the Free Software Foundation, either version 3 of the License, or
7
+ * (at your option) any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Lesser General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Lesser General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
6
16
*
7
17
* HM01B0 driver.
8
18
*/
@@ -161,6 +171,7 @@ static uint16_t himax_default_regs[][2] = {
161
171
{0x3059 , 0x1E },
162
172
{0x3064 , 0x00 },
163
173
{0x3065 , 0x04 }, // pad pull 0
174
+ {ANA_Register_17, 0x00 }, // Disable internal oscillator
164
175
165
176
{BLC_CFG, 0x43 }, // BLC_on, IIR
166
177
@@ -191,13 +202,13 @@ static uint16_t himax_default_regs[][2] = {
191
202
{0x2018 , 0x9B },
192
203
193
204
{AE_CTRL, 0x01 }, // Automatic Exposure
194
- {AE_TARGET_MEAN, 0x3C }, // AE target mean [Def: 0x3C]
205
+ {AE_TARGET_MEAN, 0x64 }, // AE target mean [Def: 0x3C]
195
206
{AE_MIN_MEAN, 0x0A }, // AE min target mean [Def: 0x0A]
196
207
{CONVERGE_IN_TH, 0x03 }, // Converge in threshold [Def: 0x03]
197
208
{CONVERGE_OUT_TH, 0x05 }, // Converge out threshold [Def: 0x05]
198
209
{MAX_INTG_H, (HIMAX_FRAME_LENGTH_QVGA-2 )>>8 }, // Maximum INTG High Byte [Def: 0x01]
199
210
{MAX_INTG_L, (HIMAX_FRAME_LENGTH_QVGA-2 )&0xFF }, // Maximum INTG Low Byte [Def: 0x54]
200
- {MAX_AGAIN_FULL, 0x03 }, // Maximum Analog gain in full frame mode [Def: 0x03]
211
+ {MAX_AGAIN_FULL, 0x04 }, // Maximum Analog gain in full frame mode [Def: 0x03]
201
212
{MAX_AGAIN_BIN2, 0x04 }, // Maximum Analog gain in bin2 mode [Def: 0x04]
202
213
{MAX_DGAIN, 0xC0 },
203
214
@@ -229,20 +240,20 @@ static uint16_t himax_default_regs[][2] = {
229
240
{OSC_CLK_DIV, 0x0B },
230
241
{IMG_ORIENTATION, 0x00 }, // change the orientation
231
242
{0x0104 , 0x01 },
232
- {0x0000 , 0x00 },
243
+ {0x0000 , 0x00 }, // EOF
233
244
};
234
245
235
- static uint16_t himax_full_regs[][2 ] = { // 'full' resolution is 320x320
246
+ static const uint16_t himax_full_regs[][2 ] = {
236
247
{0x0383 , 0x01 },
237
248
{0x0387 , 0x01 },
238
249
{0x0390 , 0x00 },
239
- {QVGA_WIN_EN, 0x00 }, // Disable QVGA window readout
250
+ {QVGA_WIN_EN, 0x00 },// Disable QVGA window readout
240
251
{MAX_INTG_H, (HIMAX_FRAME_LENGTH_FULL-2 )>>8 },
241
252
{MAX_INTG_L, (HIMAX_FRAME_LENGTH_FULL-2 )&0xFF },
242
253
{FRAME_LEN_LINES_H, (HIMAX_FRAME_LENGTH_FULL>>8 )},
243
254
{FRAME_LEN_LINES_L, (HIMAX_FRAME_LENGTH_FULL&0xFF )},
244
- {LINE_LEN_PCK_H, (HIMAX_FRAME_LENGTH_FULL >>8 )},
245
- {LINE_LEN_PCK_L, (HIMAX_FRAME_LENGTH_FULL &0xFF )},
255
+ {LINE_LEN_PCK_H, (HIMAX_LINE_LEN_PCK_FULL >>8 )},
256
+ {LINE_LEN_PCK_L, (HIMAX_LINE_LEN_PCK_FULL &0xFF )},
246
257
{GRP_PARAM_HOLD, 0x01 },
247
258
};
248
259
@@ -261,30 +272,35 @@ static regval_list_t himax_full_regs[] = { // 'full' resolution is 320x320
261
272
{0x0000 , 0x00 }, // EOF
262
273
};
263
274
264
- static uint16_t himax_qvga_regs[][2 ] = {
275
+ static const uint16_t himax_qvga_regs[][2 ] = {
265
276
{0x0383 , 0x01 },
266
277
{0x0387 , 0x01 },
267
278
{0x0390 , 0x00 },
279
+ {QVGA_WIN_EN, 0x01 },// Enable QVGA window readout
268
280
{MAX_INTG_H, (HIMAX_FRAME_LENGTH_QVGA-2 )>>8 },
269
281
{MAX_INTG_L, (HIMAX_FRAME_LENGTH_QVGA-2 )&0xFF },
270
282
{FRAME_LEN_LINES_H, (HIMAX_FRAME_LENGTH_QVGA>>8 )},
271
283
{FRAME_LEN_LINES_L, (HIMAX_FRAME_LENGTH_QVGA&0xFF )},
272
284
{LINE_LEN_PCK_H, (HIMAX_LINE_LEN_PCK_QVGA>>8 )},
273
285
{LINE_LEN_PCK_L, (HIMAX_LINE_LEN_PCK_QVGA&0xFF )},
274
- {0x0000 , 0x00 }, // EOF
286
+ {GRP_PARAM_HOLD, 0x01 },
287
+ {0x0000 , 0x00 }, // EOF
288
+
275
289
};
276
290
277
- static uint16_t himax_qqvga_regs[][2 ] = {
291
+ static const uint16_t himax_qqvga_regs[][2 ] = {
278
292
{0x0383 , 0x03 },
279
293
{0x0387 , 0x03 },
280
294
{0x0390 , 0x03 },
295
+ {QVGA_WIN_EN, 0x01 },// Enable QVGA window readout
281
296
{MAX_INTG_H, (HIMAX_FRAME_LENGTH_QQVGA-2 )>>8 },
282
297
{MAX_INTG_L, (HIMAX_FRAME_LENGTH_QQVGA-2 )&0xFF },
283
298
{FRAME_LEN_LINES_H, (HIMAX_FRAME_LENGTH_QQVGA>>8 )},
284
299
{FRAME_LEN_LINES_L, (HIMAX_FRAME_LENGTH_QQVGA&0xFF )},
285
300
{LINE_LEN_PCK_H, (HIMAX_LINE_LEN_PCK_QQVGA>>8 )},
286
301
{LINE_LEN_PCK_L, (HIMAX_LINE_LEN_PCK_QQVGA&0xFF )},
287
- {0x0000 , 0x00 }, // EOF
302
+ {GRP_PARAM_HOLD, 0x01 },
303
+ {0x0000 , 0x00 }, // EOF
288
304
};
289
305
290
306
int HM01B0::Init ()
@@ -314,7 +330,7 @@ int HM01B0::Reset()
314
330
delay (1 );
315
331
} while (reg_read (HM01B0_I2C_ADDR, MODE_SELECT, true ) != HIMAX_Standby && ((--max_timeout)>0 ) );
316
332
317
- return max_timeout> 0 ? 0 : -1 ;
333
+ return ( max_timeout > 0 ) ? 0 : -1 ;
318
334
}
319
335
320
336
int HM01B0::SetResolution (int32_t resolution)
@@ -447,7 +463,7 @@ uint8_t HM01B0::PrintRegs()
447
463
for (uint32_t i=0 ; himax_default_regs[i][0 ]; i++) {
448
464
printf (" 0x%04X: 0x%02X 0x%02X \n " ,
449
465
himax_default_regs[i][0 ],
450
- himax_default_regs[i][0 ],
466
+ himax_default_regs[i][1 ],
451
467
reg_read (HM01B0_I2C_ADDR, himax_default_regs[i][0 ], true ));
452
468
}
453
469
return 0 ;
0 commit comments