-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlsspiconfig.c
82 lines (73 loc) · 2.72 KB
/
lsspiconfig.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//*****************************************************************************
//
// Application Name - LightServer
// File Name - lsspiconfig.c
// Application Version - 2.5.0
// Application Modify Date - 26th of December 2014
// Application Developer - Glenn Vassallo
// Application Contact - [email protected]
// Application Repository - https://github.com/remixed123/LightServer
//
// Application Overview - LightServer is a Wifi enabled embedded device which
// controls RGB Intelligent lighting in various ways.
// You can control the lights via iOS Apps or via a
// webpages that are on the device.This example project
// provides a starting
//
// File Overview - lsspiconfig.c contains a function to Configures SPI Clock
// for the particular protocolType and icType.
//
// Application Details - https://github.com/remixed123/LightServer/readme.txt
//
//*****************************************************************************
#include "lightserver.h"
#include "lsspisend.h"
#include "lsspiconfig.h"
/* SYS/BIOS Headers */
#include <ti/sysbios/knl/Task.h>
/* Peripheral Headers */
#include <ti/drivers/SPI.h>
#include "driverlib/ssi.h"
#include "driverlib/sysctl.h"
//*****************************************************************************
//! configureSPI
//!
//! Configures SPI Clock for the particular protocolType and icType
//!
//!
//****************************************************************************
lsresult_t configureSPI()
{
if (lightConfig.protocolType == 0) //WS8211 or TM1809
{
if (lightConfig.icType == 0 || lightConfig.icType == 1) //WS8211 or WS8212
{
SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); //80 MHz
SSIConfigSetExpClk(SSI0_BASE, 80000000, SSI_FRF_MOTO_MODE_3, SSI_MODE_MASTER, 8000000, 10);
}
else//TM1809 or other
{
SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); //80
SSIConfigSetExpClk(SSI0_BASE, 80000000, SSI_FRF_MOTO_MODE_3, SSI_MODE_MASTER, 8000000, 10);
}
}
else if (lightConfig.protocolType == 1) //CYT3005 Lights
{
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_1, SSI_MODE_MASTER, 1000000, 16);
}
// Enable the SPI SSI0 module.
SSIEnable(SSI0_BASE);
if (lightConfig.protocolType == 1) // Send Reset and Addressing details for Minleon lights
{
resetLights();
Task_sleep(1);
addressLights();
Task_sleep(10);
resetLights();
Task_sleep(1);
addressLights();
Task_sleep(10);
}
return LS_SUCCESS;
}