I connected my Flir Lepton Camera to my board, and I'm trying to have a continuous stream of the image, thanks to the program ThermalView (source code here: https://github.com/groupgets/LeptonModule/tree/master/software/ThermalView) I compiled and downloaded the following code on my board:
int main(void)
{
//HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_I2C1_Init();
MX_SPI1_Init();
MX_USART1_UART_Init();
MX_USART2_UART_Init();
SystemClock_Config();
leptonEnd();
// LEPTON VDD OFF
HAL_Delay(1000);
// LEPTON VDD ON
HAL_Delay(185);
LeptonConfigure_I2C();
while(1)
{
LeptonReadFrame();
frameToPc();
}
}
// Output image buffer to USART2
void frameToPc()
{
static uint8_t frameSkipper = 0;
uint8_t timeStamp = (HAL_GetTick() - last_frame_millis); // calculate time passed since last been here
last_frame_millis = HAL_GetTick();
if(frameSkipper==4)
{
//PSEDO//
//IMGtoRGB();
////////
uint8_t thermalView_header[] = {0xDE,0xAD,0xBE,0xEF}; // 4-byte header for ThermalView application
HAL_Delay(1000);
HAL_UART_Transmit_DMA(&huart2, &thermalView_header[0], 4); // print header
while(huart2.gState != HAL_UART_STATE_READY); // wait for transmission to complete
HAL_UART_Transmit_DMA(&huart2, &IMG[0], LEPTON_IMG_SIZE_BYTES);
frameSkipper = 0;
}
frameSkipper++;
}uint8_t LeptonReadFrame()
{
uint8_t i, frame_number, frame_complete=0;
uint16_t bad_frame_counter=0;
while(!frame_complete)
{
leptonBegin();
HAL_SPI_Receive(&hspi1, &FramePacket[0], LEPTON_PACKET_LENGTH, 1000); // READ LINE
leptonEnd();
//HAL_UART_Transmit(&huart2, &FramePacket[0], LEPTON_PACKET_LENGTH, 1000); // PRINT LINE
if( (FramePacket[0] & 0x0f) != 0x0f ) // not discard frame
{
frame_number = FramePacket[1];
if(frame_number < 60) // valid frame
{
bad_frame_counter = 0;
for(i= 0; i<LEPTON_PACKET_CONTENT_LENGTH; i++)
{
IMG[frame_number*LEPTON_PACKET_CONTENT_LENGTH+i] = FramePacket[i+4]; // copy line into IMG buffer, ignoring ID and CRC
}
}
else
{
bad_frame_counter++;
}
if(frame_number == 59)
{
frame_complete = 1;
}
if(bad_frame_counter>1000) // 800 lines = 5 bad frames = resync needed
{
bad_frame_counter = 0;
HAL_Delay(185); // CS is already disabled so the delay is enougth
}
}
}
return 1;
}
I'm succesfully getting a stream, but I have to put a delay of 1 sec between each frame, and have to skip frames between 2 frames I'm sending to the computer. If you pay attention to something wrong in the code which prevents increasing the frame rate, let me know.
Are you using a Lepton 2 or Lepton 3? The Lepton 3 will require acquisition of not only the "Frames" but also 4 "segments" There are also 2 blank screens output by the Lepton Modules. More details in this document:
http://www.flir.com/uploadedFiles/OEM/Products/LWIR-Cameras/Lepton/Lepton-vs-Lepton-3-App-Note.pdf
comparing the Lepton 2X series (80x60) resolution and the Lepton 3 (160x120) resolution. The four most significant differences between the Lepton and Lepton 3 VoSPI interfaces are: 1) On Lepton, reconstructing a video frame from the individual packets requires the host to decode the packet number from each packet header. On Lepton 3, the host must decode both the packet number and the segment number. 2) The total number of bits per frame is 4X greater for Lepton 3 than for Lepton. Consequently, the minimum SPI clock rate is 4X faster. The maximum SPI clock rate for both modules is 20 MHz. 3) Both Lepton and Lepton 3 provide the option to output a sync pulse on GPIO3. The frequency of the pulse is 4X higher on Lepton 3 than on Lepton. For Lepton 3, the sync pulse represents when the next available segment is available whereas for Lepton it indicates when the next available frame is available. 4) When telemetry is enabled in Lepton, it results in three extra video lines (63 total packets per frame). When telemetry is enabled in Lepton 3, it results in 1 additional packet per segment for a total of 2 extra video lines.
Im trying to get the lepton 3 to work on my stm32f746g-discovery board.