diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-12-12 15:27:13 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-12-12 15:27:13 +0100 |
commit | d2dc73cab5b1c08822ce0066251e362f01525f10 (patch) | |
tree | 7ee30f3670a1df1d2acd0b84e64e8f3fdf7b47a3 /ipecamera | |
parent | d1a0a2e0322e6c5b05ba7817c1c0405dc20e5414 (diff) | |
download | pcitool-d2dc73cab5b1c08822ce0066251e362f01525f10.tar.gz pcitool-d2dc73cab5b1c08822ce0066251e362f01525f10.tar.bz2 pcitool-d2dc73cab5b1c08822ce0066251e362f01525f10.tar.xz pcitool-d2dc73cab5b1c08822ce0066251e362f01525f10.zip |
Minor fixes and improvements
Diffstat (limited to 'ipecamera')
-rw-r--r-- | ipecamera/events.c | 4 | ||||
-rw-r--r-- | ipecamera/ipecamera.c | 16 | ||||
-rw-r--r-- | ipecamera/model.h | 2 | ||||
-rw-r--r-- | ipecamera/private.h | 7 | ||||
-rw-r--r-- | ipecamera/reader.c | 4 |
5 files changed, 23 insertions, 10 deletions
diff --git a/ipecamera/events.c b/ipecamera/events.c index 173423b..a6cf57e 100644 --- a/ipecamera/events.c +++ b/ipecamera/events.c @@ -21,6 +21,7 @@ #include "events.h" int ipecamera_stream(pcilib_context_t *vctx, pcilib_event_callback_t callback, void *user) { + int run_flag = 1; int res, err = 0; int do_stop = 0; @@ -46,7 +47,7 @@ int ipecamera_stream(pcilib_context_t *vctx, pcilib_event_callback_t callback, v } // This loop iterates while the generation - while ((ctx->run_streamer)||(ctx->reported_id != ctx->event_id)) { + while ((run_flag)&&((ctx->run_streamer)||(ctx->reported_id != ctx->event_id))) { while (ctx->reported_id != ctx->event_id) { if ((ctx->event_id - ctx->reported_id) > (ctx->buffer_size - IPECAMERA_RESERVE_BUFFERS)) ctx->reported_id = ctx->event_id - (ctx->buffer_size - 1) - IPECAMERA_RESERVE_BUFFERS; else ++ctx->reported_id; @@ -57,6 +58,7 @@ int ipecamera_stream(pcilib_context_t *vctx, pcilib_event_callback_t callback, v res = callback(ctx->reported_id, (pcilib_event_info_t*)&info, user); if (res <= 0) { if (res < 0) err = -res; + run_flag = 0; break; } } diff --git a/ipecamera/ipecamera.c b/ipecamera/ipecamera.c index 0819284..c170174 100644 --- a/ipecamera/ipecamera.c +++ b/ipecamera/ipecamera.c @@ -95,8 +95,8 @@ pcilib_context_t *ipecamera_init(pcilib_t *pcilib) { FIND_REG(status_reg, "fpga", "status"); FIND_REG(control_reg, "fpga", "control"); - FIND_REG(start_reg, "fpga", "start_address"); - FIND_REG(end_reg, "fpga", "end_address"); + + FIND_REG(status3_reg, "fpga", "status3"); FIND_REG(n_lines_reg, "cmosis", "number_lines"); FIND_REG(line_reg, "cmosis", "start1"); @@ -583,15 +583,23 @@ int ipecamera_trigger(pcilib_context_t *vctx, pcilib_event_t event, size_t trigg pcilib_error("IPECamera imaging is not initialized"); return PCILIB_ERROR_NOTINITIALIZED; } + + pcilib_sleep_until_deadline(&ctx->next_trigger); +/* + do { + usleep(10); + GET_REG(status3_reg, value); + } while (value&0x20000000); +*/ + SET_REG(control_reg, IPECAMERA_FRAME_REQUEST|IPECAMERA_READOUT_FLAG); usleep(IPECAMERA_WAIT_FRAME_RCVD_TIME); CHECK_REG(status_reg, IPECAMERA_EXPECTED_STATUS); SET_REG(control_reg, IPECAMERA_IDLE|IPECAMERA_READOUT_FLAG); - // DS: Just measure when next trigger is allowed instead and wait in the beginning - usleep(IPECAMERA_NEXT_FRAME_DELAY); // minimum delay between End Of Readout and next Frame Req + pcilib_calc_deadline(&ctx->next_trigger, IPECAMERA_NEXT_FRAME_DELAY); return 0; } diff --git a/ipecamera/model.h b/ipecamera/model.h index 4a0fc8c..b01d895 100644 --- a/ipecamera/model.h +++ b/ipecamera/model.h @@ -83,7 +83,7 @@ pcilib_register_description_t ipecamera_registers[] = { {0x80, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "start_address", ""}, {0x90, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "end_address", ""}, {0x100, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "last_write_address", ""}, -{0x110, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "last_write_value", ""}, +{0x110, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "status3", ""}, {0x160, 0, 32, 0, 0, PCILIB_REGISTER_R , PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "reg9160", ""}, {0x170, 0, 32, 0, 0, PCILIB_REGISTER_R , PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "reg9170", ""}, {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL} diff --git a/ipecamera/private.h b/ipecamera/private.h index 3661cbe..e15d6ba 100644 --- a/ipecamera/private.h +++ b/ipecamera/private.h @@ -7,7 +7,7 @@ #define IPECAMERA_BUG_MULTIFRAME_PACKETS #define IPECAMERA_BUG_INCOMPLETE_PACKETS -#define IPECAMERA_DEFAULT_BUFFER_SIZE 64 //**< should be power of 2 */ +#define IPECAMERA_DEFAULT_BUFFER_SIZE 16//64 //**< should be power of 2 */ #define IPECAMERA_RESERVE_BUFFERS 2 //**< Return Frame is Lost error, if requested frame will be overwritten after specified number of frames #define IPECAMERA_SLEEP_TIME 250000 //**< Michele thinks 250 should be enough, but reset failing in this case */ #define IPECAMERA_NEXT_FRAME_DELAY 1000 //**< Michele requires 30000 to sync between End Of Readout and next Frame Req */ @@ -62,7 +62,7 @@ struct ipecamera_s { pcilib_event_callback_t cb; void *cb_user; - pcilib_event_id_t event_id; + volatile pcilib_event_id_t event_id; pcilib_event_id_t preproc_id; pcilib_event_id_t reported_id; @@ -70,7 +70,7 @@ struct ipecamera_s { pcilib_register_t packet_len_reg; pcilib_register_t control_reg, status_reg; - pcilib_register_t start_reg, end_reg; + pcilib_register_t status3_reg; pcilib_register_t n_lines_reg; uint16_t line_reg; pcilib_register_t exposure_reg; @@ -87,6 +87,7 @@ struct ipecamera_s { ipecamera_autostop_t autostop; struct timeval autostop_time; + struct timeval next_trigger; /**< The minimal delay between trigger signals is mandatory, this indicates time when next trigger is possible */ size_t buffer_size; /**< How many images to store */ size_t buffer_pos; /**< Current image offset in the buffer, due to synchronization reasons should not be used outside of reader_thread */ diff --git a/ipecamera/reader.c b/ipecamera/reader.c index f02df0f..3719709 100644 --- a/ipecamera/reader.c +++ b/ipecamera/reader.c @@ -75,6 +75,8 @@ static int ipecamera_data_callback(void *user, pcilib_dma_flags_t flags, size_t ctx->frame[ctx->buffer_pos].event.info.seqnum = ((uint32_t*)buf)[6] & 0xF0000000; ctx->frame[ctx->buffer_pos].event.info.offset = ((uint32_t*)buf)[7] & 0xF0000000; */ + ctx->frame[ctx->buffer_pos].event.info.seqnum = ctx->event_id + 1; + gettimeofday(&ctx->frame[ctx->buffer_pos].event.info.timestamp, NULL); } else { // pcilib_warning("Frame magic is not found, ignoring broken data..."); @@ -156,7 +158,7 @@ void *ipecamera_reader_thread(void *user) { } usleep(IPECAMERA_NOFRAME_SLEEP); } else pcilib_error("DMA error while reading IPECamera frames, error: %i", err); - } else printf("no error\n"); + } //else printf("no error\n"); //usleep(1000); } |