📄 samspi.h
字号:
#ifndef _SAMSPI_H_
#define _SAMSPI_H_
/*
AT91SAM7S64 SPI Pins: Function (A/B)
PA12 - MISO - AT91C_PA12_MISO (1/0)
PA13 - MOSI - AT91C_PA13_MOSI (1/0)
PA14 - SCK - AT91C_PA14_SPCK (1/0)
Chip-Selects (available on different pins)
PA11 - NPCS0 - AT91C_PA11_NPCS0 (1/0)
PA31 - NPCS1 - AT91C_PA31_NPCS1 (1/0)
PA09 - NPCS1 - AT91C_PA9_NPCS1 (1/0)
...AT91C_PA3_NPCS3 (0/1)
...AT91C_PA5_NPCS3 (0/1)
...AT91C_PA10_NPCS2 (0/1)
...AT91C_PA22_NPCS3 (0/1)
...AT91C_PA30_NPCS2 (0/1)
*/
/* here: use NCPS1 @ PA31: */
#define NPCS_PDR_BIT (AT91C_PA31_NPCS1 | AT91C_PA22_NPCS3 | AT91C_PA11_NPCS0)
#define NPCS_ASR_BIT (AT91C_PA31_NPCS1 | AT91C_PA11_NPCS0)
#define NPCS_BSR_BIT AT91C_PA22_NPCS3
#define SPI_CSR_NUM 1
#define SPI_SCBR_MIN 2
/* PCS_0 for NPCS0, PCS_1 for NPCS1 ... */
/*
#define PCS_0 ((0<<0)|(1<<1)|(1<<2)|(1<<3))
#define PCS_1 ((1<<1)|(0<<1)|(1<<2)|(1<<3))
#define PCS_2 ((1<<1)|(1<<1)|(0<<2)|(1<<3))
#define PCS_3 ((1<<1)|(1<<1)|(1<<2)|(0<<3))
*/
#define PCS_0 0x0E
#define PCS_1 0x0D
#define PCS_2 0x0B
#define PCS_3 0x07
#if (SPI_CSR_NUM == 0)
#define SPI_MR_PCS PCS_0
#elif (SPI_CSR_NUM == 1)
#define SPI_MR_PCS PCS_1
#elif (SPI_CSR_NUM == 2)
#define SPI_MR_PCS PCS_2
#elif (SPI_CSR_NUM == 3)
#define SPI_MR_PCS PCS_3
#else
#error "SPI_CSR_NUM invalid"
// not realy - when using an external address decoder...
// but this code takes over the complete SPI-interace anyway
#endif
void SAMspiSetSCBR(unsigned char ch, unsigned char baudrate);
void SAMspiCfgCH(unsigned char ch, unsigned int mode);
unsigned short SAMspiSend(unsigned char ch, unsigned short data);
void SAMspiInit(void);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -