SCAMP-5c Vision System  1.0.0
An image sensor with a parallel processor on focal plane
Functions
spi_macros.h File Reference

Go to the source code of this file.

Functions

 spi_reset (void)
 reset/initialize the spi interface More...
 
 spi_begin (void)
 activate the spi interface
 
 spi_end (void)
 deactivate the spi interface
 
 spi_get_fifo_space (reg s)
 get status index of the least number of space in fifo More...
 
reg spi_port (rint e)
 get a value from the SPI input port More...
 
 spi_send_loop_counter ()
 send the loop counter as a standard packet (packet size: 12 bytes)
 
 spi_aout (areg r)
 send an AREG plane as a standard packet (packet size: 65552 bytes) More...
 
 spi_aout64 (areg r)
 send a 64x64 subsample of an AREG plane as a standard packet (packet size: 4120 bytes) More...
 
 spi_dout (dreg r)
 send a DREG plane as a standard packet (packet size: 8208 bytes) More...
 
 spi_scan_events (dreg r, r_int16 n)
 scan and send the coordinates of n points in a DREG plane (packet size: 16 + 2*n bytes) More...
 
 spi_scan_target (dreg r)
 scan and send the coordinates of the bounding box of '1's in a DREG plane (packet size: 16 bytes) More...
 
 spi_send_header (r_int16 w)
 send a spi header, which containing the payload size. The size of the header itself is always 8 bytes. More...
 
 spi_send_byte (r_int v)
 send a value More...
 
 spi_set_transfer_size (r_int16 w)
 change the transfer size, which is the number of bytes in a single transfer burst More...
 

Detailed Description

Author
Jianing Chen

Function Documentation

spi_reset ( void  )

reset/initialize the spi interface

This macro is usually used once before the beginning of the program.

Example Usage:

1 ipu.reset_loop_counter
2 
3 // initialize spi interface
4 spi_reset
5 
6 // main frame loop
7 #start
8  ipu.wait_frame_trigger
9  rpix(B,C)
10 
11  ...
12 
13 _jump(#start)
spi_get_fifo_space ( reg  s)

get status index of the least number of space in fifo

Parameters
[out]sthe ipu register to store the index

This macro is mostly used to gurantee that the fifo has enough space to buffer the in-out speed mismatch in spi communication.

The absolute safe way to achieve this is the make sure the fifo space is bigger than the size of all packets used in a frame iteration.

reg spi_port ( rint  e)

get a value from the SPI input port

Parameters
[in]eSPI input port option
Returns
the value presented in the port

The valid options for the input port is SPI_RX_0 to SPI_RX_7 .

See SPI Downwards Communication for some extra notes on receving data from host.

Example

The follow code use a value from SPI input port to threshold a image

1 ...
2 
3 s0 = spi.port(SPI_RX_0)
4 E = in(s0)
5 D = sub(C,E)
6 where(D)
7 R5 = FLAG
8 all
9 spi.begin
10 spi.dout(R5)
11 spi.end
12 ...
spi_aout ( areg  r)

send an AREG plane as a standard packet (packet size: 65552 bytes)

Parameters
[in]rthe AREG plane to be sent
spi_aout64 ( areg  r)

send a 64x64 subsample of an AREG plane as a standard packet (packet size: 4120 bytes)

Parameters
[in]rthe AREG plane to be sent
spi_dout ( dreg  r)

send a DREG plane as a standard packet (packet size: 8208 bytes)

Parameters
[in]rthe DREG plane to be sent
spi_scan_events ( dreg  r,
r_int16  n 
)

scan and send the coordinates of n points in a DREG plane (packet size: 16 + 2*n bytes)

Parameters
[in]rthe DREG plane to be scanned
[in]nmaximum number of points, can be a value between [0,65535]
spi_scan_target ( dreg  r)

scan and send the coordinates of the bounding box of '1's in a DREG plane (packet size: 16 bytes)

Parameters
[in]rthe DREG plane to be scanned
spi_send_header ( r_int16  w)

send a spi header, which containing the payload size. The size of the header itself is always 8 bytes.

Parameters
[in]wsize of the payload
spi_send_byte ( r_int  v)

send a value

Parameters
[in]vvalue to be sent
spi_set_transfer_size ( r_int16  w)

change the transfer size, which is the number of bytes in a single transfer burst

Parameters
[in]wnumber of bytes in a single transfer burst, between [16,4096]

This macro provide the optional setting of the transfer size, which may be used to optimize the spi communication for better bandwith or latency.

For more details about setting transfer size, see Optimizing Transfer Size.