labSPI

Dependencies:   mbed

Fork of MCP4922_Sinewave by FRA221_2015

Committer:
butsaba
Date:
Thu Nov 05 07:29:03 2015 +0000
Revision:
3:863a9b7d417a
Parent:
2:2244c8986987
Child:
4:1a2a74472be9
123

Who changed what in which revision?

UserRevisionLine numberNew contents of line
soulx 2:2244c8986987 1
jf1vrr 0:5737b1972549 2 #include "mbed.h"
jf1vrr 0:5737b1972549 3 #include "MCP4922.h"
jf1vrr 0:5737b1972549 4
soulx 2:2244c8986987 5 MCP4922 MCP(SPI_MOSI, SPI_SCK,SPI_CS); // MOSI, SCLK, CS
jf1vrr 0:5737b1972549 6
jf1vrr 0:5737b1972549 7
jf1vrr 0:5737b1972549 8 /**** Main Function ***/
soulx 2:2244c8986987 9 int main(void)
soulx 2:2244c8986987 10 {
butsaba 3:863a9b7d417a 11 MCP.frequency(1000000);
butsaba 3:863a9b7d417a 12 int i;
butsaba 3:863a9b7d417a 13 float a,y;
soulx 2:2244c8986987 14 while(1) {
butsaba 3:863a9b7d417a 15
butsaba 3:863a9b7d417a 16
butsaba 3:863a9b7d417a 17 for(a=1;a<=360;a++)
butsaba 3:863a9b7d417a 18 {
butsaba 3:863a9b7d417a 19 y= sin(a*(6.28/360));
butsaba 3:863a9b7d417a 20 MCP.writeA((y+1)*2000);
butsaba 3:863a9b7d417a 21 }
butsaba 3:863a9b7d417a 22
butsaba 3:863a9b7d417a 23
soulx 2:2244c8986987 24 }
jf1vrr 0:5737b1972549 25 }