Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
max3100_hw.h File Reference
#include <stdbool.h>
#include "std.h"
#include "mcu_periph/spi_arch.h"
#include "led.h"
+ Include dependency graph for max3100_hw.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MAX3100_SS_PORT   0
 
#define MAX3100_SS_PIN   20
 
#define MAX3100_IO__(port, reg)   IO ## port ## reg
 
#define MAX3100_IO_(port, reg)   MAX3100_IO__(port, reg)
 
#define MAX3100_SS_IOCLR   MAX3100_IO_(MAX3100_SS_PORT, CLR)
 
#define MAX3100_SS_IODIR   MAX3100_IO_(MAX3100_SS_PORT, DIR)
 
#define MAX3100_SS_IOSET   MAX3100_IO_(MAX3100_SS_PORT, SET)
 
#define MAX3100_STATUS_IDLE   0
 Max3100 protocol status. More...
 
#define MAX3100_STATUS_WRITING   1
 
#define MAX3100_STATUS_READING   2
 
#define MAX3100_TX_BUF_LEN   256
 I/O Buffers. More...
 
#define MAX3100_RX_BUF_LEN   256
 
#define Max3100Select()
 
#define Max3100Unselect()
 
#define MAX3100_WRITE_CONF   ((1U<<15) | (1U<<14))
 
#define MAX3100_READ_CONF   ((0U<<15) | (1U<<14))
 
#define MAX3100_WRITE_DATA   ((1U<<15) | (0U<<14))
 
#define MAX3100_READ_DATA   ((0U<<15) | (0U<<14))
 
#define MAX3100_BIT_NOT_RM   (1U<<10)
 
#define MAX3100_BIT_NOT_TM   (1U<<11)
 
#define MAX3100_BIT_NOT_FEN   (1U<<13)
 
#define MAX3100_T_BIT   14
 
#define MAX3100_R_BIT   15
 
#define UART3100Init()   {} /* Already initialized as a module */
 Like UART macros. More...
 
#define UART3100CheckFreeSpace(_len)   (((int16_t)max3100_tx_extract_idx - max3100_tx_insert_idx + MAX3100_TX_BUF_LEN - 1) % MAX3100_TX_BUF_LEN >= _len)
 
#define UART3100Transmit(_x)   { max3100_putchar(_x); }
 
#define UART3100SendMessage()   {}
 
#define UART3100Getch()
 
#define UART3100ChAvailable()   (max3100_rx_extract_idx != max3100_rx_insert_idx)
 
#define Max3100TransmitConf(_conf)   max3100_transmit((_conf) | MAX3100_WRITE_CONF)
 
#define Max3100TransmitData(_data)   max3100_transmit((_data) | MAX3100_WRITE_DATA)
 
#define Max3100ReadData()   max3100_transmit(MAX3100_READ_DATA)
 

Functions

static void max3100_transmit (uint16_t data)
 
static void max3100_read_data (void)
 
static void max3100_flush (void)
 
static void max3100_putconfchar (char c)
 Warning: No bufferring; SPI must be available. More...
 
static void max3100_putchar (char c)
 
void max3100_init (void)
 
void max3100_debug (void)
 
static void max3100_event (void)
 

Variables

volatile uint8_t max3100_status
 
volatile bool max3100_data_available
 
volatile bool max3100_transmit_buffer_empty
 
volatile uint8_t max3100_tx_insert_idx
 
volatile uint8_t max3100_tx_extract_idx
 
volatile uint8_t max3100_rx_insert_idx
 
volatile uint8_t max3100_rx_extract_idx
 
volatile uint8_t max3100_tx_buf [MAX3100_TX_BUF_LEN]
 
volatile uint8_t max3100_rx_buf [MAX3100_RX_BUF_LEN]
 
volatile uint8_t read_byte1
 
volatile uint8_t read_byte2
 
bool read_bytes
 

Macro Definition Documentation

#define MAX3100_BIT_NOT_FEN   (1U<<13)

Definition at line 86 of file max3100_hw.h.

#define MAX3100_BIT_NOT_RM   (1U<<10)

Definition at line 84 of file max3100_hw.h.

Referenced by max3100_init().

#define MAX3100_BIT_NOT_TM   (1U<<11)

Definition at line 85 of file max3100_hw.h.

Referenced by max3100_init().

#define MAX3100_IO_ (   port,
  reg 
)    MAX3100_IO__(port, reg)

Definition at line 31 of file max3100_hw.h.

#define MAX3100_IO__ (   port,
  reg 
)    IO ## port ## reg

Definition at line 30 of file max3100_hw.h.

#define MAX3100_R_BIT   15

Definition at line 88 of file max3100_hw.h.

Referenced by SPI1_ISR().

#define MAX3100_READ_CONF   ((0U<<15) | (1U<<14))

Definition at line 68 of file max3100_hw.h.

#define MAX3100_READ_DATA   ((0U<<15) | (0U<<14))

Definition at line 70 of file max3100_hw.h.

#define MAX3100_RX_BUF_LEN   256

Definition at line 48 of file max3100_hw.h.

#define MAX3100_SS_IOCLR   MAX3100_IO_(MAX3100_SS_PORT, CLR)

Definition at line 33 of file max3100_hw.h.

#define MAX3100_SS_IODIR   MAX3100_IO_(MAX3100_SS_PORT, DIR)

Definition at line 34 of file max3100_hw.h.

Referenced by max3100_init().

#define MAX3100_SS_IOSET   MAX3100_IO_(MAX3100_SS_PORT, SET)

Definition at line 35 of file max3100_hw.h.

#define MAX3100_SS_PIN   20

Definition at line 28 of file max3100_hw.h.

Referenced by max3100_init().

#define MAX3100_SS_PORT   0

Definition at line 27 of file max3100_hw.h.

#define MAX3100_STATUS_IDLE   0

Max3100 protocol status.

Definition at line 38 of file max3100_hw.h.

Referenced by max3100_event(), max3100_flush(), max3100_init(), and SPI1_ISR().

#define MAX3100_STATUS_READING   2

Definition at line 40 of file max3100_hw.h.

Referenced by max3100_read_data(), and SPI1_ISR().

#define MAX3100_STATUS_WRITING   1

Definition at line 39 of file max3100_hw.h.

Referenced by max3100_flush(), and max3100_putconfchar().

#define MAX3100_T_BIT   14

Definition at line 87 of file max3100_hw.h.

Referenced by SPI1_ISR().

#define MAX3100_TX_BUF_LEN   256

I/O Buffers.

Definition at line 47 of file max3100_hw.h.

#define MAX3100_WRITE_CONF   ((1U<<15) | (1U<<14))

Definition at line 67 of file max3100_hw.h.

#define MAX3100_WRITE_DATA   ((1U<<15) | (0U<<14))

Definition at line 69 of file max3100_hw.h.

#define Max3100ReadData ( )    max3100_transmit(MAX3100_READ_DATA)

Definition at line 116 of file max3100_hw.h.

Referenced by max3100_read_data().

#define Max3100Select ( )
Value:
{ \
}
#define MAX3100_SS_IOCLR
Definition: max3100_hw.h:33
#define MAX3100_SS_PIN
Definition: max3100_hw.h:28

Definition at line 59 of file max3100_hw.h.

Referenced by max3100_transmit().

#define Max3100TransmitConf (   _conf)    max3100_transmit((_conf) | MAX3100_WRITE_CONF)

Definition at line 114 of file max3100_hw.h.

Referenced by max3100_init(), and max3100_putconfchar().

#define Max3100TransmitData (   _data)    max3100_transmit((_data) | MAX3100_WRITE_DATA)

Definition at line 115 of file max3100_hw.h.

Referenced by max3100_flush().

#define Max3100Unselect ( )
Value:
{ \
}
#define MAX3100_SS_PIN
Definition: max3100_hw.h:28
#define MAX3100_SS_IOSET
Definition: max3100_hw.h:35

Definition at line 63 of file max3100_hw.h.

Referenced by max3100_init(), and SPI1_ISR().

#define UART3100ChAvailable ( )    (max3100_rx_extract_idx != max3100_rx_insert_idx)

Definition at line 102 of file max3100_hw.h.

#define UART3100CheckFreeSpace (   _len)    (((int16_t)max3100_tx_extract_idx - max3100_tx_insert_idx + MAX3100_TX_BUF_LEN - 1) % MAX3100_TX_BUF_LEN >= _len)

Definition at line 92 of file max3100_hw.h.

#define UART3100Getch ( )
Value:
({\
max3100_rx_extract_idx++; /* Since size=256 */ \
ret; \
})
volatile uint8_t max3100_rx_buf[MAX3100_RX_BUF_LEN]
Definition: max3100_hw.c:39
unsigned char uint8_t
Definition: types.h:14
volatile uint8_t max3100_rx_extract_idx
Definition: max3100_hw.c:36

Definition at line 96 of file max3100_hw.h.

#define UART3100Init ( )    {} /* Already initialized as a module */

Like UART macros.

Definition at line 91 of file max3100_hw.h.

#define UART3100SendMessage ( )    {}

Definition at line 95 of file max3100_hw.h.

#define UART3100Transmit (   _x)    { max3100_putchar(_x); }

Definition at line 94 of file max3100_hw.h.

Function Documentation

void max3100_debug ( void  )

Definition at line 167 of file max3100_hw.c.

Referenced by max3100_event().

+ Here is the caller graph for this function:

static void max3100_event ( void  )
inlinestatic

Definition at line 150 of file max3100_hw.h.

References max3100_data_available, max3100_debug(), max3100_flush(), max3100_read_data(), max3100_status, MAX3100_STATUS_IDLE, and read_bytes.

+ Here is the call graph for this function:

static void max3100_flush ( void  )
inlinestatic
static void max3100_putchar ( char  c)
inlinestatic

Definition at line 141 of file max3100_hw.h.

References max3100_tx_buf, and max3100_tx_insert_idx.

static void max3100_putconfchar ( char  c)
inlinestatic

Warning: No bufferring; SPI must be available.

Definition at line 136 of file max3100_hw.h.

References max3100_status, MAX3100_STATUS_WRITING, and Max3100TransmitConf.

static void max3100_read_data ( void  )
inlinestatic

Definition at line 119 of file max3100_hw.h.

References max3100_status, MAX3100_STATUS_READING, and Max3100ReadData.

Referenced by max3100_event().

+ Here is the caller graph for this function:

static void max3100_transmit ( uint16_t  data)
inlinestatic

Definition at line 104 of file max3100_hw.h.

References Max3100Select, SpiClearRti(), SpiEnable, SpiEnableRti(), and SSPDR.

+ Here is the call graph for this function:

Variable Documentation

volatile bool max3100_data_available

Definition at line 32 of file max3100_hw.c.

Referenced by EXTINT_ISR(), max3100_event(), and max3100_init().

volatile uint8_t max3100_rx_buf[MAX3100_RX_BUF_LEN]

Definition at line 39 of file max3100_hw.c.

Referenced by SPI1_ISR().

volatile uint8_t max3100_rx_extract_idx

Definition at line 36 of file max3100_hw.c.

Referenced by max3100_init().

volatile uint8_t max3100_rx_insert_idx

Definition at line 36 of file max3100_hw.c.

Referenced by max3100_init(), and SPI1_ISR().

volatile uint8_t max3100_status
volatile bool max3100_transmit_buffer_empty

Definition at line 33 of file max3100_hw.c.

Referenced by max3100_flush(), max3100_init(), and SPI1_ISR().

volatile uint8_t max3100_tx_buf[MAX3100_TX_BUF_LEN]

Definition at line 38 of file max3100_hw.c.

Referenced by max3100_flush(), and max3100_putchar().

volatile uint8_t max3100_tx_extract_idx

Definition at line 35 of file max3100_hw.c.

Referenced by max3100_flush(), and max3100_init().

volatile uint8_t max3100_tx_insert_idx

Definition at line 35 of file max3100_hw.c.

Referenced by max3100_flush(), max3100_init(), and max3100_putchar().

volatile uint8_t read_byte1
volatile uint8_t read_byte2
bool read_bytes

Definition at line 42 of file max3100_hw.c.

Referenced by max3100_event(), and SPI1_ISR().