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
@ -72,7 +72,7 @@ extern "C"
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
#include "LEPTON_Types.h"
|
#include "LEPTON_Types.h"
|
||||||
#include "LEPTON_ErrorCodes.h"
|
#include "LEPTON_ErrorCodes.h"
|
||||||
|
#include "cambus.h"
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/** EXPORTED DEFINES **/
|
/** EXPORTED DEFINES **/
|
||||||
@ -89,6 +89,7 @@ extern "C"
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/** EXPORTED PUBLIC FUNCTIONS **/
|
/** EXPORTED PUBLIC FUNCTIONS **/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
void LEP_I2C_Init(cambus_t *bus);
|
||||||
|
|
||||||
extern LEP_RESULT LEP_I2C_MasterSelectDevice(LEP_CAMERA_PORT_DESC_T_PTR portDescPtr,
|
extern LEP_RESULT LEP_I2C_MasterSelectDevice(LEP_CAMERA_PORT_DESC_T_PTR portDescPtr,
|
||||||
LEP_PROTOCOL_DEVICE_E device);
|
LEP_PROTOCOL_DEVICE_E device);
|
||||||
|
|||||||
@ -74,20 +74,22 @@
|
|||||||
#include "LEPTON_ErrorCodes.h"
|
#include "LEPTON_ErrorCodes.h"
|
||||||
#include "LEPTON_I2C_Service.h"
|
#include "LEPTON_I2C_Service.h"
|
||||||
#include "cambus.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 **/
|
/** LOCAL DEFINES **/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
#define LEP_I2C_BUSY_BIT_MASK 0x0001 /* Bit 0 is the Busy Bit */
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/** LOCAL TYPE DEFINITIONS **/
|
/** LOCAL TYPE DEFINITIONS **/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/** PRIVATE DATA DECLARATIONS **/
|
/** PRIVATE DATA DECLARATIONS **/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@ -96,7 +98,6 @@ extern sensor_t sensor;
|
|||||||
/** PRIVATE FUNCTION DECLARATIONS **/
|
/** PRIVATE FUNCTION DECLARATIONS **/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/** EXPORTED PUBLIC DATA **/
|
/** EXPORTED PUBLIC DATA **/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@ -167,7 +168,9 @@ LEP_RESULT LEP_I2C_MasterReadData(LEP_UINT16 portID,
|
|||||||
LEP_RESULT result = LEP_OK;
|
LEP_RESULT result = LEP_OK;
|
||||||
|
|
||||||
for (int i = 0; i < dataLength; i++) {
|
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);
|
return(result);
|
||||||
@ -195,13 +198,14 @@ LEP_RESULT LEP_I2C_MasterWriteData(LEP_UINT16 portID,
|
|||||||
LEP_RESULT result = LEP_OK;
|
LEP_RESULT result = LEP_OK;
|
||||||
|
|
||||||
for (int i = 0; i < dataLength; i++) {
|
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);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LEP_RESULT LEP_I2C_MasterReadRegister(LEP_UINT16 portID,
|
LEP_RESULT LEP_I2C_MasterReadRegister(LEP_UINT16 portID,
|
||||||
LEP_UINT8 deviceAddress,
|
LEP_UINT8 deviceAddress,
|
||||||
LEP_UINT16 regAddress,
|
LEP_UINT16 regAddress,
|
||||||
@ -209,12 +213,13 @@ LEP_RESULT LEP_I2C_MasterReadRegister(LEP_UINT16 portID,
|
|||||||
{
|
{
|
||||||
LEP_RESULT result = LEP_OK;
|
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);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LEP_RESULT LEP_I2C_MasterWriteRegister(LEP_UINT16 portID,
|
LEP_RESULT LEP_I2C_MasterWriteRegister(LEP_UINT16 portID,
|
||||||
LEP_UINT8 deviceAddress,
|
LEP_UINT8 deviceAddress,
|
||||||
LEP_UINT16 regAddress,
|
LEP_UINT16 regAddress,
|
||||||
@ -222,12 +227,13 @@ LEP_RESULT LEP_I2C_MasterWriteRegister(LEP_UINT16 portID,
|
|||||||
{
|
{
|
||||||
LEP_RESULT result = LEP_OK;
|
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);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Driver Status
|
/* Driver Status
|
||||||
*/
|
*/
|
||||||
LEP_RESULT LEP_I2C_MasterStatus(LEP_UINT16 portID,
|
LEP_RESULT LEP_I2C_MasterStatus(LEP_UINT16 portID,
|
||||||
|
|||||||
@ -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_FSYNC, 0);
|
||||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_JPEGE, 0);
|
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_JPEGE, 0);
|
||||||
|
|
||||||
|
LEP_I2C_Init(&sensor->bus);
|
||||||
|
|
||||||
// Configure the DMA handler for Transmission process
|
// Configure the DMA handler for Transmission process
|
||||||
DMAHandle.Instance = LEPTON_SPI_DMA_STREAM;
|
DMAHandle.Instance = LEPTON_SPI_DMA_STREAM;
|
||||||
DMAHandle.Init.Request = LEPTON_SPI_DMA_REQUEST;
|
DMAHandle.Init.Request = LEPTON_SPI_DMA_REQUEST;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user