summaryrefslogtreecommitdiff
path: root/firmware/src/p2m.c
blob: d4ecb21aa2253f7353dc674b8270fcb47b177a72 (plain)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
 * THE AUTHORS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. USE IT AT YOUR OWN RISK */

#include <LPC17xx.h>

#define SPI

#ifdef DMA

#include "dac.h"
#include "sample.h"

int main (void) 
{
	dac_init();

	//	int i = 0;
	while(1) {
		//		fiprintf(stderr, "Play #%d: %d samples\n\r", i++, sizeof(samples) / sizeof(short));
		dac_play_samples(samples, sizeof(samples) / sizeof(short));
	}
	return 0;
}

#endif
volatile uint32_t temp;

void _delay(uint32_t del);

#ifdef BLINKY

int main (void) 
{
    LPC_SC->PCONP |= ( 1 << 15 ); // power up GPIO
    LPC_GPIO1->FIODIR |= 1 << 29; // puts P1.29 into output mode.
    while(1)
    {
        LPC_GPIO1->FIOPIN |= 1 << 29; // make P1.29 high
        _delay( 1 << 24 );
        LPC_GPIO1->FIOPIN &= ~( 1 << 29 ); // make P1.29 low
        _delay( 1 << 24 );
    }
    return 0;
  
}

#endif

#ifdef UART

#include "LPC17xx.h"
#include <stdint.h>
#include "uart.h"

int main (void)
{ 
	/* SystemClockUpdate() updates the SystemFrequency variable */
	// SystemCoreClockUpdate();//SystemClockUpdate();
  UARTInit(0, 115200);	/* baud rate setting */
	//  UARTInit(1, 8000);	/* baud rate setting */

	LPC_SC->PCONP |= ( 1 << 15 ); // power up GPIO
	LPC_GPIO1->FIODIR |= 1 << 29; // puts P1.29 into output mode.

  while (1) {
		LPC_GPIO1->FIOPIN |= 1 << 29; // make P1.29 high

		//LPC_UART0->IER = IER_THRE | IER_RLS;			// Disable RBR
		UARTSend(0, (uint8_t *)"hello\n\r", 7);
		//LPC_UART0->IER = IER_THRE | IER_RLS | IER_RBR;	// Re-enable RBR

		_delay( 1 << 22 );

		///

		LPC_GPIO1->FIOPIN &= ~( 1 << 29 ); // make P1.29 low
		/*
		LPC_UART0->IER = IER_THRE | IER_RLS;			// Disable RBR
		UARTSend( 0, (uint8_t *)"l", 1);
		LPC_UART0->IER = IER_THRE | IER_RLS | IER_RBR;	// Re-enable RBR
		*/
		_delay( 1 << 22 );

  }
}

#endif

#ifdef SPI

#include "LPC17xx.h"
#include <stdint.h>
#include "uart.h"
#include <wm8523.h>

int main (void)
{ 
  UARTInit(0, 115200);	/* baud rate setting */

	UARTSend(0, (uint8_t *)"init\n\r", 6);

	WM8523_Init();

  while (1) {
		UARTSend(0, (uint8_t *)"hello\n\r", 7);

		_delay( 1 << 22 );
  }
}

#endif

void _delay(uint32_t del)
{
    uint32_t i;
    for(i=0;i<del;i++)
        temp = i;
}