|
52 | 52 | OV5640_COLOR_JPEG = 3
|
53 | 53 |
|
54 | 54 | # fmt: off
|
| 55 | + |
| 56 | +_SYSTEM_RESET00 = const(0x3000) # Reset for Individual Block |
| 57 | +# (0: enable block; 1: reset block) |
| 58 | +# Bit[7]: Reset BIST |
| 59 | +# Bit[6]: Reset MCU program memory |
| 60 | +# Bit[5]: Reset MCU |
| 61 | +# Bit[4]: Reset OTP |
| 62 | +# Bit[3]: Reset STB |
| 63 | +# Bit[2]: Reset d5060 |
| 64 | +# Bit[1]: Reset timing control |
| 65 | +# Bit[0]: Reset array control |
| 66 | + |
| 67 | +_SYSTEM_RESET02 = const(0x3002) # Reset for Individual Block |
| 68 | +# (0: enable block; 1: reset block) |
| 69 | +# Bit[7]: Reset VFIFO |
| 70 | +# Bit[5]: Reset format |
| 71 | +# Bit[4]: Reset JFIFO |
| 72 | +# Bit[3]: Reset SFIFO |
| 73 | +# Bit[2]: Reset JPG |
| 74 | +# Bit[1]: Reset format MUX |
| 75 | +# Bit[0]: Reset average |
| 76 | + |
| 77 | +_CLOCK_ENABLE02 = const(0x3006) # Clock Enable Control |
| 78 | +# (0: disable clock; 1: enable clock) |
| 79 | +# Bit[7]: Enable PSRAM clock |
| 80 | +# Bit[6]: Enable FMT clock |
| 81 | +# Bit[5]: Enable JPEG 2x clock |
| 82 | +# Bit[3]: Enable JPEG clock |
| 83 | +# Bit[1]: Enable format MUX clock |
| 84 | +# Bit[0]: Enable average clock |
| 85 | + |
55 | 86 | _SYSTEM_CTROL0 = const(0x3008)
|
56 | 87 | # Bit[7]: Software reset
|
57 | 88 | # Bit[6]: Software power down
|
|
398 | 429 | 0x4713, 0x02, # jpg mode select
|
399 | 430 | _ISP_CONTROL_01, 0x83, # turn color matrix, awb and SDE
|
400 | 431 | # sys reset
|
401 |
| - 0x3000, 0x00, |
402 |
| - 0x3002, 0x1C, |
| 432 | + _SYSTEM_RESET00, 0x00, # enable all blocks |
| 433 | + _SYSTEM_RESET02, 0x1C, # reset jfifo, sfifo, jpg, fmux, avg |
403 | 434 | # clock enable
|
404 | 435 | 0x3004, 0xFF,
|
405 |
| - 0x3006, 0xC3, |
| 436 | + _CLOCK_ENABLE02, 0xC3, |
406 | 437 | # isp control
|
407 | 438 | 0x5000, 0xA7,
|
408 | 439 | _ISP_CONTROL_01, 0xA3, # +scaling?
|
|
541 | 572 | #_REG_DLY, 300,
|
542 | 573 | ]
|
543 | 574 |
|
| 575 | + |
| 576 | + |
| 577 | +_reset_awb = [ |
| 578 | + _ISP_CONTROL_01, 0x83, # turn color matrix, awb and SDE |
| 579 | + # sys reset |
| 580 | + _SYSTEM_RESET00, 0x00, # enable all blocks |
| 581 | + _SYSTEM_RESET02, 0x1C, # reset jfifo, sfifo, jpg, fmux, avg |
| 582 | + # clock enable |
| 583 | + #0x3004, 0xFF, |
| 584 | + #_CLOCK_ENABLE02, 0xC3, |
| 585 | + # isp control |
| 586 | + 0x5000, 0xA7, |
| 587 | + _ISP_CONTROL_01, 0xA3, # +scaling? |
| 588 | + 0x5003, 0x08, # special_effect |
| 589 | + # unknown |
| 590 | + 0x370C, 0x02, #!!IMPORTANT |
| 591 | + 0x3634, 0x40, #!!IMPORTANT |
| 592 | + # AEC/AGC |
| 593 | + 0x3A02, 0x03, |
| 594 | + 0x3A03, 0xD8, |
| 595 | + 0x3A08, 0x01, |
| 596 | + 0x3A09, 0x27, |
| 597 | + 0x3A0A, 0x00, |
| 598 | + 0x3A0B, 0xF6, |
| 599 | + 0x3A0D, 0x04, |
| 600 | + 0x3A0E, 0x03, |
| 601 | + 0x3A0F, 0x30, # ae_level |
| 602 | + 0x3A10, 0x28, # ae_level |
| 603 | + 0x3A11, 0x60, # ae_level |
| 604 | + 0x3A13, 0x43, |
| 605 | + 0x3A14, 0x03, |
| 606 | + 0x3A15, 0xD8, |
| 607 | + 0x3A18, 0x00, # gainceiling |
| 608 | + 0x3A19, 0xF8, # gainceiling |
| 609 | + 0x3A1B, 0x30, # ae_level |
| 610 | + 0x3A1E, 0x26, # ae_level |
| 611 | + 0x3A1F, 0x14, # ae_level |
| 612 | + # vcm debug |
| 613 | + 0x3600, 0x08, |
| 614 | + 0x3601, 0x33, |
| 615 | + # 50/60Hz |
| 616 | + 0x3C01, 0xA4, |
| 617 | + 0x3C04, 0x28, |
| 618 | + 0x3C05, 0x98, |
| 619 | + 0x3C06, 0x00, |
| 620 | + 0x3C07, 0x08, |
| 621 | + 0x3C08, 0x00, |
| 622 | + 0x3C09, 0x1C, |
| 623 | + 0x3C0A, 0x9C, |
| 624 | + 0x3C0B, 0x40, |
| 625 | + 0x460C, 0x22, # disable jpeg footer |
| 626 | + # BLC |
| 627 | + 0x4001, 0x02, |
| 628 | + 0x4004, 0x02, |
| 629 | + # AWB |
| 630 | + 0x5180, 0xFF, |
| 631 | + 0x5181, 0xF2, |
| 632 | + 0x5182, 0x00, |
| 633 | + 0x5183, 0x14, |
| 634 | + 0x5184, 0x25, |
| 635 | + 0x5185, 0x24, |
| 636 | + 0x5186, 0x09, |
| 637 | + 0x5187, 0x09, |
| 638 | + 0x5188, 0x09, |
| 639 | + 0x5189, 0x75, |
| 640 | + 0x518A, 0x54, |
| 641 | + 0x518B, 0xE0, |
| 642 | + 0x518C, 0xB2, |
| 643 | + 0x518D, 0x42, |
| 644 | + 0x518E, 0x3D, |
| 645 | + 0x518F, 0x56, |
| 646 | + 0x5190, 0x46, |
| 647 | + 0x5191, 0xF8, |
| 648 | + 0x5192, 0x04, |
| 649 | + 0x5193, 0x70, |
| 650 | + 0x5194, 0xF0, |
| 651 | + 0x5195, 0xF0, |
| 652 | + 0x5196, 0x03, |
| 653 | + 0x5197, 0x01, |
| 654 | + 0x5198, 0x04, |
| 655 | + 0x5199, 0x12, |
| 656 | + 0x519A, 0x04, |
| 657 | + 0x519B, 0x00, |
| 658 | + 0x519C, 0x06, |
| 659 | + 0x519D, 0x82, |
| 660 | + 0x519E, 0x38, |
| 661 | + # color matrix (Saturation) |
| 662 | + 0x5381, 0x1E, |
| 663 | + 0x5382, 0x5B, |
| 664 | + 0x5383, 0x08, |
| 665 | + 0x5384, 0x0A, |
| 666 | + 0x5385, 0x7E, |
| 667 | + 0x5386, 0x88, |
| 668 | + 0x5387, 0x7C, |
| 669 | + 0x5388, 0x6C, |
| 670 | + 0x5389, 0x10, |
| 671 | + 0x538A, 0x01, |
| 672 | + 0x538B, 0x98, |
| 673 | + # CIP control (Sharpness) |
| 674 | + 0x5300, 0x10, # sharpness |
| 675 | + 0x5301, 0x10, # sharpness |
| 676 | + 0x5302, 0x18, # sharpness |
| 677 | + 0x5303, 0x19, # sharpness |
| 678 | + 0x5304, 0x10, |
| 679 | + 0x5305, 0x10, |
| 680 | + 0x5306, 0x08, # denoise |
| 681 | + 0x5307, 0x16, |
| 682 | + 0x5308, 0x40, |
| 683 | + 0x5309, 0x10, # sharpness |
| 684 | + 0x530A, 0x10, # sharpness |
| 685 | + 0x530B, 0x04, # sharpness |
| 686 | + 0x530C, 0x06, # sharpness |
| 687 | + # GAMMA |
| 688 | + 0x5480, 0x01, |
| 689 | + 0x5481, 0x00, |
| 690 | + 0x5482, 0x1E, |
| 691 | + 0x5483, 0x3B, |
| 692 | + 0x5484, 0x58, |
| 693 | + 0x5485, 0x66, |
| 694 | + 0x5486, 0x71, |
| 695 | + 0x5487, 0x7D, |
| 696 | + 0x5488, 0x83, |
| 697 | + 0x5489, 0x8F, |
| 698 | + 0x548A, 0x98, |
| 699 | + 0x548B, 0xA6, |
| 700 | + 0x548C, 0xB8, |
| 701 | + 0x548D, 0xCA, |
| 702 | + 0x548E, 0xD7, |
| 703 | + 0x548F, 0xE3, |
| 704 | + 0x5490, 0x1D, |
| 705 | + # Special Digital Effects (SDE) (UV adjust) |
| 706 | + 0x5580, 0x06, # enable brightness and contrast |
| 707 | + 0x5583, 0x40, # special_effect |
| 708 | + 0x5584, 0x10, # special_effect |
| 709 | + 0x5586, 0x20, # contrast |
| 710 | + 0x5587, 0x00, # brightness |
| 711 | + 0x5588, 0x00, # brightness |
| 712 | + 0x5589, 0x10, |
| 713 | + 0x558A, 0x00, |
| 714 | + 0x558B, 0xF8, |
| 715 | + 0x501D, 0x40, # enable manual offset of contrast |
| 716 | +] |
544 | 717 | _sensor_format_jpeg = [
|
545 | 718 | _FORMAT_CTRL, 0x00, # YUV422
|
546 | 719 | _FORMAT_CTRL00, 0x30, # YUYV
|
547 |
| - 0x3002, 0x00, # 0x1c to 0x00 !!! |
548 |
| - 0x3006, 0xFF, # 0xc3 to 0xff !!! |
| 720 | + _SYSTEM_RESET02, 0x00, # enable everything |
| 721 | + _CLOCK_ENABLE02, 0xFF, # enable all clocks |
549 | 722 | 0x471C, 0x50, # 0xd0 to 0x50 !!!
|
550 | 723 | ]
|
551 | 724 |
|
|
567 | 740 | _sensor_format_rgb565 = [
|
568 | 741 | _FORMAT_CTRL, 0x01, # RGB
|
569 | 742 | _FORMAT_CTRL00, 0x61, # RGB565 (BGR)
|
| 743 | + _SYSTEM_RESET02, 0x1C, # reset jfifo, sfifo, jpg, fmux, avg |
| 744 | + _CLOCK_ENABLE02, 0xC3, # reset to how it was before (no jpg clock) |
| 745 | + |
570 | 746 | ]
|
571 | 747 |
|
572 | 748 | _ov5640_color_settings = {
|
|
0 commit comments