Dependencies:   mbed

Committer:
BenRJG
Date:
Tue Apr 03 20:00:23 2018 +0000
Revision:
4:bcef9164776e
Parent:
3:d6e142b6ead1
Child:
5:11489c0bd020
Created functions for reading & writing SPI data

Who changed what in which revision?

UserRevisionLine numberNew contents of line
BenRJG 1:acc66d3a1a1c 1 #ifndef _SPI_H_
BenRJG 1:acc66d3a1a1c 2 #define _SPI_H_
BenRJG 1:acc66d3a1a1c 3 //////Included Files//////
BenRJG 1:acc66d3a1a1c 4 #include "mbed.h"
BenRJG 1:acc66d3a1a1c 5 //////////////////////////
BenRJG 1:acc66d3a1a1c 6
BenRJG 4:bcef9164776e 7 ///////Definitions////////
BenRJG 1:acc66d3a1a1c 8 #define DD 25 //Display Delay us
BenRJG 1:acc66d3a1a1c 9 #define CD 2000 //Command Delay us
BenRJG 3:d6e142b6ead1 10
BenRJG 3:d6e142b6ead1 11 // Chip Select => 111(7) = Nothing, 110(6) = General, 101(5) = LCD, 011(3) = ADC//
BenRJG 4:bcef9164776e 12 #define CS_RESET 7 // RESET (No chip selected)
BenRJG 4:bcef9164776e 13 #define CS_GENERAL 6 // GENERAL
BenRJG 4:bcef9164776e 14 #define CS_LCD 5 // LCD
BenRJG 4:bcef9164776e 15 #define CS_ADC 3 // ADC
BenRJG 3:d6e142b6ead1 16
BenRJG 4:bcef9164776e 17 //////////////////////////
BenRJG 1:acc66d3a1a1c 18
BenRJG 4:bcef9164776e 19 ////////Functions/////////
BenRJG 1:acc66d3a1a1c 20 //Function Prototypes, will just output a string to display, see later//
BenRJG 2:b615682e3e4f 21 void SPI_INIT(void);
BenRJG 2:b615682e3e4f 22 void SPI_TEST(void);
BenRJG 2:b615682e3e4f 23
BenRJG 1:acc66d3a1a1c 24 int32_t bar_graph(uint8_t level); //Display a bar graph on the lcd 2nd line scale 0 to 15
BenRJG 1:acc66d3a1a1c 25 int32_t read_adc(void); //Read ADC and return the 12 Bit value 0 to 4095 NB has a 3V3 refernce voltage (for scaling)
BenRJG 1:acc66d3a1a1c 26 int32_t read_switches(void); //Read 4 Sliding switches on FPGA (Simulating OPTO-Switches from Motor(s)
BenRJG 1:acc66d3a1a1c 27
BenRJG 1:acc66d3a1a1c 28 int32_t lcd_cls(void); //LCD Functions here, Clear Screen, Locate and Display String
BenRJG 1:acc66d3a1a1c 29 int32_t lcd_locate(uint8_t line, uint8_t column); //Line Max is 2, Column max is 16
BenRJG 1:acc66d3a1a1c 30 int32_t lcd_display(char* str); //String str length maximum is 16
BenRJG 4:bcef9164776e 31
BenRJG 4:bcef9164776e 32 void spi_write_data(short destination, unsigned int data);
BenRJG 4:bcef9164776e 33 int32_t spi_read_data(short destination);
BenRJG 4:bcef9164776e 34 int32_t spi_read_write_data(short destination, unsigned int data);
BenRJG 4:bcef9164776e 35 //////////////////////////
BenRJG 4:bcef9164776e 36 #endif