Skip to content
Snippets Groups Projects
Commit 4a17f910 authored by Armin Luntzer's avatar Armin Luntzer
Browse files

* test proceudure uses RMAP_WRITE_ADDR_INC_REPLY without VERIFY flag, so now we do as well

* add FEE packet data structs
* calculate CRC8 for RMAP_WRITE_ADDR_INC_REPLY as well
* CRC8 calculation must be done on big-endian converted data block, fixed
* implement test procedures 1-3 in library demo code
parent 80893c50
No related branches found
No related tags found
No related merge requests found
...@@ -132,9 +132,23 @@ struct fee_event_dection { ...@@ -132,9 +132,23 @@ struct fee_event_dection {
} __attribute__((packed)); } __attribute__((packed));
__extension__
struct fee_data_pkt {
struct fee_data_hdr hdr;
uint8_t *data;
} __attribute__((packed));
__extension__
struct fee_pattern {
union {
uint16_t ccd:1;
uint16_t side:1;
uint16_t row:7;
uint16_t col:7;
uint16_t pat;
};
} __attribute__((packed));
......
...@@ -77,7 +77,7 @@ static int fee_read_cmd_register_internal(uint16_t trans_id, uint8_t *cmd, ...@@ -77,7 +77,7 @@ static int fee_read_cmd_register_internal(uint16_t trans_id, uint8_t *cmd,
static int fee_write_cmd_register_internal(uint16_t trans_id, uint8_t *cmd, static int fee_write_cmd_register_internal(uint16_t trans_id, uint8_t *cmd,
uint32_t addr) uint32_t addr)
{ {
return smile_fee_gen_cmd(trans_id, cmd, RMAP_WRITE_ADDR_INC_VERIFY_REPLY, return smile_fee_gen_cmd(trans_id, cmd, RMAP_WRITE_ADDR_INC_REPLY,
addr, 4); addr, 4);
} }
......
...@@ -28,11 +28,11 @@ ...@@ -28,11 +28,11 @@
#include <gresb.h> #include <gresb.h>
#include <smile_fee.h>
#include <smile_fee_cfg.h> #include <smile_fee_cfg.h>
#include <smile_fee_ctrl.h> #include <smile_fee_ctrl.h>
#include <smile_fee_rmap.h> #include <smile_fee_rmap.h>
#include <rmap.h> /* for FEE simulation */ #include <rmap.h> /* for FEE simulation */
/* whatever for now ... */ /* whatever for now ... */
...@@ -391,6 +391,70 @@ static int32_t rmap_tx(const void *hdr, uint32_t hdr_size, ...@@ -391,6 +391,70 @@ static int32_t rmap_tx(const void *hdr, uint32_t hdr_size,
} }
/**
* dirty hack for packet reception, more or less a copy of rmap_rx()
*/
static uint32_t pkt_rx(uint8_t *pkt)
{
int recv_bytes;
static uint32_t pkt_size; /* keep last packet size */
/* XXX: gresb-to-host header is just 4 bytes, but we need 2 extra in
* order to be able to distinguish between rmap and non-rmap packets
*
*
* NOTE THAT THIS IS A DIRTY HACK FOR THE DEMONSTRATOR ONLY, DO NOT DO
* THIS IN PRODUCTION CODE! EVER!
*/
uint8_t gresb_hdr[4+2];
uint8_t *recv_buffer;
if (!pkt) { /* next packet size requested */
/* try to grab a header */
recv_bytes = recv(bridge_fd, gresb_hdr, 6, MSG_PEEK | MSG_DONTWAIT);
/* we won't bother, this is a stupid demo, not production code */
if (recv_bytes <= 0)
return 0;
/* header is 4 bytes, but we need 6 */
if (recv_bytes < (4 + 2))
return 0;
pkt_size = gresb_get_spw_data_size(gresb_hdr);
/* XXX the protocol id is (or should be) in byte 6 */
if (gresb_hdr[5] != FEE_DATA_PROTOCOL)
return 0;
/* tell caller about next packet */
return pkt_size;
}
/* we packet space, now start receiving
* note the lack of basic sanity checks...
*/
/* buffer is payload + header */
recv_buffer = malloc(pkt_size + 4);
recv_bytes = recv(bridge_fd, recv_buffer, pkt_size + 4, 0);
/* the caller supplied their own buffer */
memcpy(pkt, gresb_get_spw_data(recv_buffer), pkt_size);
free(recv_buffer);
return pkt_size;
}
/** /**
* rx function for smile_fee_ctrl * rx function for smile_fee_ctrl
* *
...@@ -409,27 +473,37 @@ static uint32_t rmap_rx(uint8_t *pkt) ...@@ -409,27 +473,37 @@ static uint32_t rmap_rx(uint8_t *pkt)
int recv_bytes; int recv_bytes;
static uint32_t pkt_size; /* keep last packet size */ static uint32_t pkt_size; /* keep last packet size */
uint8_t gresb_hdr[4]; /* gresb-to-host header is 4 bytes */ /* XXX: gresb-to-host header is just 4 bytes, but we need 2 extra in
* order to be able to distinguish between rmap and non-rmap packets
*
*
* NOTE THAT THIS IS A DIRTY HACK FOR THE DEMONSTRATOR ONLY, DO NOT DO
* THIS IN PRODUCTION CODE! EVER!
*/
uint8_t gresb_hdr[4+2];
uint8_t *recv_buffer; uint8_t *recv_buffer;
if (!pkt) { /* next packet size requested */ if (!pkt) { /* next packet size requested */
/* try to grab a header */ /* try to grab a header */
recv_bytes = recv(bridge_fd, gresb_hdr, 6, MSG_PEEK | MSG_DONTWAIT);
//recv_bytes = recv(bridge_fd, gresb_hdr, 4, MSG_PEEK);
recv_bytes = recv(bridge_fd, gresb_hdr, 4, MSG_PEEK | MSG_DONTWAIT);
/* we won't bother, this is a stupid demo, not production code */ /* we won't bother, this is a stupid demo, not production code */
if (recv_bytes <= 0) if (recv_bytes <= 0)
return 0; return 0;
/* header is 4 bytes... */ /* header is 4 bytes, but we need 6 */
if (recv_bytes < 4) if (recv_bytes < (4 + 2))
return 0; return 0;
pkt_size = gresb_get_spw_data_size(gresb_hdr); pkt_size = gresb_get_spw_data_size(gresb_hdr);
/* XXX the protocol id is (or should be) in byte 6 */
if (gresb_hdr[5] != RMAP_PROTOCOL_ID)
return 0;
/* tell caller about next packet */ /* tell caller about next packet */
return pkt_size; return pkt_size;
} }
...@@ -530,33 +604,50 @@ static void sync_rmap(void) ...@@ -530,33 +604,50 @@ static void sync_rmap(void)
printf("synced\n\n"); printf("synced\n\n");
} }
/** /**
* SMILE FEE commanding demonstrator, this would run on the DPU * procedure Test 1: read a basic FEE register
* note: all values are random *
*/ */
static void smile_fee_demo(void) static void smile_fee_test1(void)
{ {
printf("sync vstart from FEE\n"); printf("Test1: read a basic FEE register\n");
printf("sync vstart/vend from FEE\n");
smile_fee_sync_vstart(FEE2DPU); smile_fee_sync_vstart(FEE2DPU);
sync_rmap();
printf("vstart: %x, vend %x\n", smile_fee_get_vstart(), smile_fee_get_vend());
printf("Test1 complete\n\n");
}
/**
* procedure Test 2: read, write & read a basic FEE register
*
*/
static void smile_fee_test2(void)
{
printf("Test 2: read, write & read a basic FEE register\n");
printf("sync ccd2 e/f single pixel threshold from FEE\n"); printf("sync ccd2 e/f single pixel threshold from FEE\n");
smile_fee_sync_ccd2_e_pix_treshold(FEE2DPU); smile_fee_sync_ccd2_e_pix_treshold(FEE2DPU);
sync_rmap(); sync_rmap();
printf("ccd2 e value now: %x\n", smile_fee_get_ccd2_e_pix_treshold()); printf("ccd2 e value currently: %x\n", smile_fee_get_ccd2_e_pix_treshold());
printf("ccd2 f value now: %x\n", smile_fee_get_ccd2_f_pix_treshold()); printf("ccd2 f value currently: %x\n", smile_fee_get_ccd2_f_pix_treshold());
printf("setting2 ccd e/f local values\n"); printf("setting2 ccd e/f local values\n");
smile_fee_set_ccd2_e_pix_treshold(0x7b); smile_fee_set_ccd2_e_pix_treshold(0x7b);
smile_fee_set_ccd2_f_pix_treshold(0x7c); smile_fee_set_ccd2_f_pix_treshold(0x7c);
printf("syncing ccd2 e/f single pixel thresold to FEE\n"); printf("ccd2 e local value now: %x\n", smile_fee_get_ccd2_e_pix_treshold());
printf("ccd2 f local value now: %x\n", smile_fee_get_ccd2_f_pix_treshold());
printf("syncing ccd2 e/f single pixel threshold to FEE\n");
smile_fee_sync_ccd2_e_pix_treshold(DPU2FEE); smile_fee_sync_ccd2_e_pix_treshold(DPU2FEE);
sync_rmap(); sync_rmap();
...@@ -565,7 +656,7 @@ static void smile_fee_demo(void) ...@@ -565,7 +656,7 @@ static void smile_fee_demo(void)
smile_fee_set_ccd2_e_pix_treshold(0x0); smile_fee_set_ccd2_e_pix_treshold(0x0);
smile_fee_set_ccd2_f_pix_treshold(0x0); smile_fee_set_ccd2_f_pix_treshold(0x0);
printf("syncing back ccd2 e/f single pixel thresold from FEE\n"); printf("syncing back ccd2 e/f single pixel threshold from FEE\n");
smile_fee_sync_ccd2_e_pix_treshold(FEE2DPU); smile_fee_sync_ccd2_e_pix_treshold(FEE2DPU);
sync_rmap(); sync_rmap();
...@@ -573,80 +664,127 @@ static void smile_fee_demo(void) ...@@ -573,80 +664,127 @@ static void smile_fee_demo(void)
printf("ccd1 value now: %x\n", smile_fee_get_ccd2_e_pix_treshold()); printf("ccd1 value now: %x\n", smile_fee_get_ccd2_e_pix_treshold());
printf("ccd2 value now: %x\n", smile_fee_get_ccd2_f_pix_treshold()); printf("ccd2 value now: %x\n", smile_fee_get_ccd2_f_pix_treshold());
printf("Test2 complete\n\n");
}
printf("standing by\n");
while(1) usleep(1000000); /* stop here for now */
/**
* procedure Test 3: Get 6x6 binned pattern images from "Frame Transfer Pattern
* Mode."
*
*/
printf("Configuring start of vertical row shared with charge injection\n");
smile_fee_set_vstart(35);
printf("Configuring duration of a parallel overlap period (TOI)\n"); static void smile_fee_test3(void)
smile_fee_set_parallel_toi_period(5); {
printf("Test 3: 6x6 binned pattern from frame transfer pattern mode\n");
printf("Syncing configured values to FEE via RMAP\n"); smile_fee_set_packet_size(0x30c);
smile_fee_sync_vstart(DPU2FEE); smile_fee_set_int_period(0x0fa0);
smile_fee_sync_parallel_toi_period(DPU2FEE);
printf("Waiting for sync to complete\n"); /* all above are reg4, this will suffice */
sync_rmap(); smile_fee_sync_packet_size(DPU2FEE);
printf("Verifying configured values in FEE\n"); smile_fee_set_correction_bypass(1);
smile_fee_set_digitise(1);
smile_fee_set_readout_nodes(3);
printf("Clearing local values\n"); /* all above are reg5, this will suffice */
smile_fee_set_vstart(0); smile_fee_sync_correction_bypass(DPU2FEE);
smile_fee_set_parallel_toi_period(0);
printf("Syncing configured values from FEE to DPU via RMAP\n"); smile_fee_set_ccd_mode_config(0x1);
smile_fee_sync_vstart(FEE2DPU); smile_fee_set_ccd_mode2_config(0x2);
smile_fee_sync_parallel_toi_period(FEE2DPU);
/* all above are reg32, this will suffice */
smile_fee_sync_ccd_mode_config(DPU2FEE);
sync_rmap(); /* make sure all parameters are set */
/* trigger packet transmission */
smile_fee_set_execute_op(0x1);
smile_fee_sync_execute_op(DPU2FEE);
printf("Waiting for sync to complete\n");
sync_rmap(); sync_rmap();
while (1)
{
static int ps = 1; /* times to print everything... */
static int pp = 1; /* times to print everything... */
int n, i;
struct fee_data_pkt *pkt;
struct fee_pattern *pat;
usleep(1000);
printf("Checking values: vertical row shared with charge injection: "); n = pkt_rx(NULL);
if (smile_fee_get_vstart() == 35) if (n)
printf("SUCCESS\n"); pkt = (struct fee_data_pkt *) malloc(n);
else else
printf("FAILURE\n"); continue;
n = pkt_rx((uint8_t *) pkt);
printf("Checking values: duration of a parallel overlap period (TOI): "); if (n <= 0)
printf("Error in pkt_rx()\n");
if (smile_fee_get_parallel_toi_period() == 5)
printf("SUCCESS\n");
else
printf("FAILURE\n");
pkt->hdr.data_len = __be16_to_cpu(pkt->hdr.data_len);
pkt->hdr.frame_cntr = __be16_to_cpu(pkt->hdr.frame_cntr);
pkt->hdr.seq_cntr = __be16_to_cpu(pkt->hdr.seq_cntr);
printf("Setting execute op flag to expedite operational parameters\n"); if (ps) {
smile_fee_set_execute_op(1); ps--;
printf("Syncing execute op flag to FEE via RMAP\n"); printf("data type %d len %d frame %d seq %d\n",
smile_fee_sync_execute_op(DPU2FEE); pkt->hdr.type.pkt_type,
printf("Waiting for sync to complete\n"); pkt->hdr.data_len,
sync_rmap(); pkt->hdr.frame_cntr,
pkt->hdr.seq_cntr);
}
pat = (struct fee_pattern *) &pkt->data;
n = pkt->hdr.data_len / sizeof(struct fee_pattern);
printf("Waiting for FEE to complete operation\n"); if (pp) {
pp--;
printf("n %d\n", n);
for (i = 0; i < n; i++) {
pat[i].pat = __be16_to_cpu(pat[i].pat);
printf("%d %d %d %d\n", pat[i].ccd, pat[i].side, pat[i].row, pat[i].col);
while (1) { }
printf("Syncing execute op flag from FEE to DPU via RMAP\n"); }
smile_fee_sync_execute_op(FEE2DPU);
printf("Waiting for sync to complete\n"); /* setup abort ... */
sync_rmap(); if (pkt->hdr.seq_cntr == 2555) /* gen stops about there? */
ps = -1;
if (!smile_fee_get_execute_op()) free(pkt);
/* abort ... */
if (ps < 0)
break; break;
}
printf("FEE hast not yet completed operation\n"); printf("Test3 complete\n\n");
} }
printf("FEE operation completed\n"); /**
* SMILE FEE commanding demonstrator, this would run on the DPU
*/
static void smile_fee_demo(void)
{
smile_fee_test1();
smile_fee_test2();
smile_fee_test3();
printf("standing by\n");
while(1) usleep(1000000); /* stop here for now */
} }
......
...@@ -558,6 +558,7 @@ int smile_fee_package(uint8_t *blob, ...@@ -558,6 +558,7 @@ int smile_fee_package(uint8_t *blob,
case RMAP_WRITE_ADDR_INC_VERIFY: case RMAP_WRITE_ADDR_INC_VERIFY:
case RMAP_WRITE_ADDR_SINGLE_VERIFY_REPLY: case RMAP_WRITE_ADDR_SINGLE_VERIFY_REPLY:
case RMAP_WRITE_ADDR_INC_VERIFY_REPLY: case RMAP_WRITE_ADDR_INC_VERIFY_REPLY:
case RMAP_WRITE_ADDR_INC_REPLY:
has_data_crc = 1; has_data_crc = 1;
n += 1; n += 1;
break; break;
...@@ -596,8 +597,8 @@ int smile_fee_package(uint8_t *blob, ...@@ -596,8 +597,8 @@ int smile_fee_package(uint8_t *blob,
} }
#endif /* __BYTE_ORDER__ */ #endif /* __BYTE_ORDER__ */
blob[cmd_size + 1 + data_size] = rmap_crc8(&blob[cmd_size + 1], data_size);
blob[cmd_size + 1 + data_size] = rmap_crc8(data, data_size);
} else { } else {
/* if no data is present, data crc is 0x0 */ /* if no data is present, data crc is 0x0 */
if (has_data_crc) if (has_data_crc)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment