no-OS
Loading...
Searching...
No Matches
camera_riscv.c File Reference

MAX78000 CPU1 QVGA camera capture and streaming statistics. More...

#include <errno.h>
#include <stdint.h>
#include <string.h>
#include "camera.h"
#include "cameraif.h"
#include "dma.h"
#include "dma_regs.h"
#include "mxc_device.h"
#include "mxc_errors.h"
#include "tmr.h"
#include "camera_ipc.h"
#include "maxim_coprocessor_riscv.h"
#include "maxim_ipc.h"
Include dependency graph for camera_riscv.c:

Classes

struct  camera_ae_registers
 
struct  frame_accumulator
 
struct  capture_context
 

Macros

#define CAMERA_CLOCK_HZ   10000000U
 
#define RISCV_CLOCK_HZ   60000000U
 
#define OV7692_CLKRC_REG   0x11U
 
#define OV7692_QVGA_CLKRC   0x01U
 
#define OV7692_BAND_50HZ_REG   0x50U
 
#define OV7692_BAND_60HZ_REG   0x51U
 
#define CAMERA_MAINS_HZ   50U
 
#define OV7692_QVGA_BAND_STEP   (CAMERA_MAINS_HZ == 60U ? 0x3fU : 0x4cU)
 
#define OV7692_BGAIN_REG   0x01U
 
#define OV7692_RGAIN_REG   0x02U
 
#define OV7692_GAIN_REG   0x00U
 
#define OV7692_AECH_REG   0x0fU
 
#define OV7692_AECL_REG   0x10U
 
#define OV7692_COM8_REG   0x13U
 
#define OV7692_COM8_AEC_ENABLE   0x01U
 
#define OV7692_COM8_AGC_ENABLE   0x04U
 
#define OV7692_COM8_AUTO   0xf7U
 
#define OV7692_COM8_MANUAL_WB   0xf5U
 
#define OV7692_REG15_REG   0x15U
 
#define OV7692_AEC_WPT_REG   0x24U
 
#define OV7692_AEC_BPT_REG   0x25U
 
#define OV7692_AEC_VPT_REG   0x26U
 
#define OV7692_SDE_CTRL_REG   0xd2U
 
#define OV7692_CONTRAST_SIGN_REG   0xd3U
 
#define OV7692_CONTRAST_GAIN_REG   0xd4U
 
#define OV7692_CONTRAST_CTRL_REG   0xd5U
 
#define OV7692_SATURATION_U_REG   0xd8U
 
#define OV7692_SATURATION_V_REG   0xd9U
 
#define CNN_QUAD0_DSRAM_START   0x50400000UL
 
#define CNN_QUAD1_DSRAM_START   0x50800000UL
 
#define CNN_QUAD2_DSRAM_START   0x50c00000UL
 
#define CNN_QUAD3_DSRAM_START   0x51000000UL
 
#define CNN_DSRAM_QUAD_BYTES   0x00020000UL
 
#define CNN_FRAME_BANK_COUNT   2U
 
#define CNN_ROWS_PER_QUAD   (CNN_DSRAM_QUAD_BYTES / CAMERA_LINE_BYTES)
 
#define CAMERA_STATS_SCALE   4U
 
#define CAMERA_STATS_WIDTH   (CAMERA_FRAME_WIDTH / CAMERA_STATS_SCALE)
 
#define CAMERA_STATS_HEIGHT   (CAMERA_FRAME_HEIGHT / CAMERA_STATS_SCALE)
 
#define CAMERA_STATS_PIXELS   (CAMERA_STATS_WIDTH * CAMERA_STATS_HEIGHT)
 

Functions

void rv_debug_safe_point (void)
 Set a debugger breakpoint here after requesting CAMERA_CMD_PAUSE.
 
int Camera_Power (int on)
 Camera power hook required by the MSDK camera driver.
 
void camera_riscv_fault (void)
 Report a CPU1 trap to the host and park the core.
 
void illegal_insn_handler (void)
 
void ecall_insn_handler (void)
 
int main (void)
 

Variables

uint32_t SystemCoreClock
 

Detailed Description

MAX78000 CPU1 QVGA camera capture and streaming statistics.

Author
Victor Pascu (victo.nosp@m.r.pa.nosp@m.scu@a.nosp@m.nalo.nosp@m.g.com)

Copyright 2026(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ CAMERA_CLOCK_HZ

#define CAMERA_CLOCK_HZ   10000000U

◆ CAMERA_MAINS_HZ

#define CAMERA_MAINS_HZ   50U

◆ CAMERA_STATS_HEIGHT

#define CAMERA_STATS_HEIGHT   (CAMERA_FRAME_HEIGHT / CAMERA_STATS_SCALE)

◆ CAMERA_STATS_PIXELS

#define CAMERA_STATS_PIXELS   (CAMERA_STATS_WIDTH * CAMERA_STATS_HEIGHT)

◆ CAMERA_STATS_SCALE

#define CAMERA_STATS_SCALE   4U

◆ CAMERA_STATS_WIDTH

#define CAMERA_STATS_WIDTH   (CAMERA_FRAME_WIDTH / CAMERA_STATS_SCALE)

◆ CNN_DSRAM_QUAD_BYTES

#define CNN_DSRAM_QUAD_BYTES   0x00020000UL

◆ CNN_FRAME_BANK_COUNT

#define CNN_FRAME_BANK_COUNT   2U

◆ CNN_QUAD0_DSRAM_START

#define CNN_QUAD0_DSRAM_START   0x50400000UL

◆ CNN_QUAD1_DSRAM_START

#define CNN_QUAD1_DSRAM_START   0x50800000UL

◆ CNN_QUAD2_DSRAM_START

#define CNN_QUAD2_DSRAM_START   0x50c00000UL

◆ CNN_QUAD3_DSRAM_START

#define CNN_QUAD3_DSRAM_START   0x51000000UL

◆ CNN_ROWS_PER_QUAD

#define CNN_ROWS_PER_QUAD   (CNN_DSRAM_QUAD_BYTES / CAMERA_LINE_BYTES)

◆ OV7692_AEC_BPT_REG

#define OV7692_AEC_BPT_REG   0x25U

◆ OV7692_AEC_VPT_REG

#define OV7692_AEC_VPT_REG   0x26U

◆ OV7692_AEC_WPT_REG

#define OV7692_AEC_WPT_REG   0x24U

◆ OV7692_AECH_REG

#define OV7692_AECH_REG   0x0fU

◆ OV7692_AECL_REG

#define OV7692_AECL_REG   0x10U

◆ OV7692_BAND_50HZ_REG

#define OV7692_BAND_50HZ_REG   0x50U

◆ OV7692_BAND_60HZ_REG

#define OV7692_BAND_60HZ_REG   0x51U

◆ OV7692_BGAIN_REG

#define OV7692_BGAIN_REG   0x01U

◆ OV7692_CLKRC_REG

#define OV7692_CLKRC_REG   0x11U

◆ OV7692_COM8_AEC_ENABLE

#define OV7692_COM8_AEC_ENABLE   0x01U

◆ OV7692_COM8_AGC_ENABLE

#define OV7692_COM8_AGC_ENABLE   0x04U

◆ OV7692_COM8_AUTO

#define OV7692_COM8_AUTO   0xf7U

◆ OV7692_COM8_MANUAL_WB

#define OV7692_COM8_MANUAL_WB   0xf5U

◆ OV7692_COM8_REG

#define OV7692_COM8_REG   0x13U

◆ OV7692_CONTRAST_CTRL_REG

#define OV7692_CONTRAST_CTRL_REG   0xd5U

◆ OV7692_CONTRAST_GAIN_REG

#define OV7692_CONTRAST_GAIN_REG   0xd4U

◆ OV7692_CONTRAST_SIGN_REG

#define OV7692_CONTRAST_SIGN_REG   0xd3U

◆ OV7692_GAIN_REG

#define OV7692_GAIN_REG   0x00U

◆ OV7692_QVGA_BAND_STEP

#define OV7692_QVGA_BAND_STEP   (CAMERA_MAINS_HZ == 60U ? 0x3fU : 0x4cU)

◆ OV7692_QVGA_CLKRC

#define OV7692_QVGA_CLKRC   0x01U

◆ OV7692_REG15_REG

#define OV7692_REG15_REG   0x15U

◆ OV7692_RGAIN_REG

#define OV7692_RGAIN_REG   0x02U

◆ OV7692_SATURATION_U_REG

#define OV7692_SATURATION_U_REG   0xd8U

◆ OV7692_SATURATION_V_REG

#define OV7692_SATURATION_V_REG   0xd9U

◆ OV7692_SDE_CTRL_REG

#define OV7692_SDE_CTRL_REG   0xd2U

◆ RISCV_CLOCK_HZ

#define RISCV_CLOCK_HZ   60000000U

Function Documentation

◆ Camera_Power()

int Camera_Power ( int on)

Camera power hook required by the MSDK camera driver.

The EVKIT camera socket has no software-controlled power switch.

Parameters
on- POWER_ON or POWER_OFF; ignored.
Returns
E_NO_ERROR.

◆ camera_riscv_fault()

void camera_riscv_fault ( void )

Report a CPU1 trap to the host and park the core.

◆ ecall_insn_handler()

void ecall_insn_handler ( void )

◆ illegal_insn_handler()

void illegal_insn_handler ( void )

◆ main()

int main ( void )

◆ rv_debug_safe_point()

void rv_debug_safe_point ( void )

Set a debugger breakpoint here after requesting CAMERA_CMD_PAUSE.

Variable Documentation

◆ SystemCoreClock

uint32_t SystemCoreClock
extern