mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Allow Lepton I2C bus to be selected
This commit is contained in:
parent
1ca66a7e10
commit
1598b68a43
@ -60,7 +60,7 @@
|
||||
**
|
||||
*******************************************************************************/
|
||||
#ifndef _LEPTON_I2C_SERVICE_H_
|
||||
#define _LEPTON_I2C_SERVICE_H_
|
||||
#define _LEPTON_I2C_SERVICE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@ -70,9 +70,9 @@ extern "C"
|
||||
/******************************************************************************/
|
||||
/** INCLUDE FILES **/
|
||||
/******************************************************************************/
|
||||
#include "LEPTON_Types.h"
|
||||
#include "LEPTON_ErrorCodes.h"
|
||||
|
||||
#include "LEPTON_Types.h"
|
||||
#include "LEPTON_ErrorCodes.h"
|
||||
#include "cambus.h"
|
||||
|
||||
/******************************************************************************/
|
||||
/** EXPORTED DEFINES **/
|
||||
@ -89,6 +89,7 @@ extern "C"
|
||||
/******************************************************************************/
|
||||
/** EXPORTED PUBLIC FUNCTIONS **/
|
||||
/******************************************************************************/
|
||||
void LEP_I2C_Init(cambus_t *bus);
|
||||
|
||||
extern LEP_RESULT LEP_I2C_MasterSelectDevice(LEP_CAMERA_PORT_DESC_T_PTR portDescPtr,
|
||||
LEP_PROTOCOL_DEVICE_E device);
|
||||
@ -96,9 +97,9 @@ extern "C"
|
||||
extern LEP_RESULT LEP_I2C_MasterOpen(LEP_UINT16 portID,
|
||||
LEP_UINT16 *portBaudRate);
|
||||
|
||||
extern LEP_RESULT LEP_I2C_MasterClose(LEP_CAMERA_PORT_DESC_T_PTR portDescPtr );
|
||||
extern LEP_RESULT LEP_I2C_MasterClose(LEP_CAMERA_PORT_DESC_T_PTR portDescPtr);
|
||||
|
||||
extern LEP_RESULT LEP_I2C_MasterReset(LEP_CAMERA_PORT_DESC_T_PTR portDescPtr );
|
||||
extern LEP_RESULT LEP_I2C_MasterReset(LEP_CAMERA_PORT_DESC_T_PTR portDescPtr);
|
||||
|
||||
extern LEP_RESULT LEP_I2C_MasterReadData(LEP_UINT16 portID,
|
||||
LEP_UINT8 deviceAddress,
|
||||
@ -124,7 +125,7 @@ extern "C"
|
||||
LEP_UINT16 regValue);
|
||||
|
||||
extern LEP_RESULT LEP_I2C_MasterStatus(LEP_UINT16 portID,
|
||||
LEP_UINT16 *portStatus );
|
||||
LEP_UINT16 *portStatus);
|
||||
|
||||
/******************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -74,20 +74,22 @@
|
||||
#include "LEPTON_ErrorCodes.h"
|
||||
#include "LEPTON_I2C_Service.h"
|
||||
#include "cambus.h"
|
||||
#include "sensor.h"
|
||||
extern sensor_t sensor;
|
||||
|
||||
static cambus_t *bus;
|
||||
|
||||
void LEP_I2C_Init(cambus_t *hbus)
|
||||
{
|
||||
bus = hbus;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/** LOCAL DEFINES **/
|
||||
/******************************************************************************/
|
||||
|
||||
#define LEP_I2C_BUSY_BIT_MASK 0x0001 /* Bit 0 is the Busy Bit */
|
||||
|
||||
/******************************************************************************/
|
||||
/** LOCAL TYPE DEFINITIONS **/
|
||||
/******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/** PRIVATE DATA DECLARATIONS **/
|
||||
/******************************************************************************/
|
||||
@ -96,7 +98,6 @@ extern sensor_t sensor;
|
||||
/** PRIVATE FUNCTION DECLARATIONS **/
|
||||
/******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/** EXPORTED PUBLIC DATA **/
|
||||
/******************************************************************************/
|
||||
@ -167,7 +168,9 @@ LEP_RESULT LEP_I2C_MasterReadData(LEP_UINT16 portID,
|
||||
LEP_RESULT result = LEP_OK;
|
||||
|
||||
for (int i = 0; i < dataLength; i++) {
|
||||
if (cambus_readw2(&sensor.bus, deviceAddress << 1, subAddress + (i * 2), &dataPtr[i])) return LEP_ERROR;
|
||||
if (cambus_readw2(bus, deviceAddress << 1, subAddress + (i * 2), &dataPtr[i])) {
|
||||
return LEP_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
@ -195,13 +198,14 @@ LEP_RESULT LEP_I2C_MasterWriteData(LEP_UINT16 portID,
|
||||
LEP_RESULT result = LEP_OK;
|
||||
|
||||
for (int i = 0; i < dataLength; i++) {
|
||||
if (cambus_writew2(&sensor.bus, deviceAddress << 1, subAddress + (i * 2), dataPtr[i])) return LEP_ERROR;
|
||||
if (cambus_writew2(bus, deviceAddress << 1, subAddress + (i * 2), dataPtr[i])) {
|
||||
return LEP_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
LEP_RESULT LEP_I2C_MasterReadRegister(LEP_UINT16 portID,
|
||||
LEP_UINT8 deviceAddress,
|
||||
LEP_UINT16 regAddress,
|
||||
@ -209,12 +213,13 @@ LEP_RESULT LEP_I2C_MasterReadRegister(LEP_UINT16 portID,
|
||||
{
|
||||
LEP_RESULT result = LEP_OK;
|
||||
|
||||
if (cambus_readw2(&sensor.bus, deviceAddress << 1, regAddress, regValue)) return LEP_ERROR;
|
||||
if (cambus_readw2(bus, deviceAddress << 1, regAddress, regValue)) {
|
||||
return LEP_ERROR;
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
LEP_RESULT LEP_I2C_MasterWriteRegister(LEP_UINT16 portID,
|
||||
LEP_UINT8 deviceAddress,
|
||||
LEP_UINT16 regAddress,
|
||||
@ -222,16 +227,17 @@ LEP_RESULT LEP_I2C_MasterWriteRegister(LEP_UINT16 portID,
|
||||
{
|
||||
LEP_RESULT result = LEP_OK;
|
||||
|
||||
if (cambus_writew2(&sensor.bus, deviceAddress << 1, regAddress, regValue)) return LEP_ERROR;
|
||||
if (cambus_writew2(bus, deviceAddress << 1, regAddress, regValue)) {
|
||||
return LEP_ERROR;
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/* Driver Status
|
||||
*/
|
||||
LEP_RESULT LEP_I2C_MasterStatus(LEP_UINT16 portID,
|
||||
LEP_UINT16 *portStatus )
|
||||
LEP_UINT16 *portStatus)
|
||||
{
|
||||
LEP_RESULT result = LEP_OK;
|
||||
|
||||
|
||||
@ -672,6 +672,8 @@ int lepton_init(sensor_t *sensor)
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_FSYNC, 0);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_JPEGE, 0);
|
||||
|
||||
LEP_I2C_Init(&sensor->bus);
|
||||
|
||||
// Configure the DMA handler for Transmission process
|
||||
DMAHandle.Instance = LEPTON_SPI_DMA_STREAM;
|
||||
DMAHandle.Init.Request = LEPTON_SPI_DMA_REQUEST;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user