Esempio n. 1
0
int main() {
	volatile int sockfd;
	volatile int res1, res2;

	WDTCTL = WDTPW | WDTHOLD;
	ucs_clockinit(16000000, 1, 0);
	__delay_cycles(160000);

	wiznet_init();

	while (wiznet_phystate() < 0)
		__delay_cycles(160000);

	wiznet_ip_bin_w_reg(W52_SOURCEIP, myip);
	wiznet_ip_bin_w_reg(W52_SUBNETMASK, w52_const_subnet_classC);

	sockfd = wiznet_socket(IPPROTO_TCP);
	if (sockfd < 0)
		LPM4;

	res1 = wiznet_bind(sockfd, 80);  // Bind port 80
	if (res1 < 0)
		LPM4;

	while ( (res2 = wiznet_accept(sockfd)) == -EAGAIN ) {
		__delay_cycles(160000);
	}

	// Freeze at this point, with the socket open.  Telnet to port 80 should at least connect.

	LPM4;
	return 0;
}
Esempio n. 2
0
int main()
{
	WDTCTL = WDTPW + WDTHOLD; //Stop WDT

	ucs_clockinit(FREQ, 1, 0);
	gpio_init();


    // Timer 0 for output PWM (for 8bit values)
    TA0CTL = TASSEL_2 | MC_1;
    TA0CCR0 = 255;
    TA0CCTL1 |= OUTMOD_7;
    TA0CCR1 = 0; // Added for 0 output after reset


    // Timer 1 to interrupt at sample speed
    TA1CTL = TASSEL_2 | MC_1;
    TA1CCR0 = FREQ / SAMPLES_PER_SECOND - 1;
    TA1CCTL0 |= CCIE;

	_BIS_SR(GIE);       // Enable global interrupts


	while(1){
        
        if ( counter <= binary_data_size ) 
        {   // If data is still playing do LPM0 to keep
            // the timer running and audio playing.
			sample = audio_raw[counter++];
            LPM0;
        }
        else 
        {
            // If done playing go to LPM4 so that only
            // the button wakes MCU up.
            sample = 0;
            TA0CCR1 = 0;         // Added for guaranteed 0 output.
            __delay_cycles(500); // Needed to not have random pin output
            // We really dont want Vcc going through speaker when idle
            P1OUT &= ~RED_LED;
            LPM4;
        }
    }
}
Esempio n. 3
0
int main()
{
	WDTCTL = WDTPW | WDTHOLD;

	P4DIR |= BIT7;
	P4OUT |= BIT7;
	if (!ucs_clockinit(16000000, 1, 0))
		LPM4;
	P4OUT &= ~BIT7;
	UCSCTL5 = DIVS__4;

	// Chip select
	P2SEL &= ~BIT7;
	P2REN &= ~BIT7;
	P2DIR |= BIT7;
	P2OUT |= BIT7;  // Drive it high to disable LCD
	// Backlight
	P2SEL &= ~BIT6;
	P2REN &= ~BIT6;
	P2DIR |= BIT6;
	P2OUT &= ~BIT6; // Turn off backlight

	spi_init();
	msp1202_init();
	ste2007_contrast(8);
	msp1202_puts("Hi there my\n");
	msp1202_puts("name is Eric.\n");
	msp1202_move(8, 0);

	while(1) {
		__delay_cycles(16000000);
		msp1202_puts("txt 1");
		__delay_cycles(16000000);
		msp1202_puts("txt 2");
	}

	LPM4;

	return 0;
}
Esempio n. 4
0
int main() {
	int sockfd;
	uint8_t sockopen = 0;
	uint8_t netbuf[32];

	P1DIR |= BIT0;
	P4DIR |= BIT7;
	RED_SET; GREEN_CLEAR;

	WDTCTL = WDTPW | WDTHOLD;
        ucs_clockinit(16000000, 1, 0);
        __delay_cycles(160000);

	wiznet_debug_init();
	wiznet_init();

	while (!wiznet_phystate())
		__delay_cycles(160000);

	wiznet_ip_str_w_reg(W52_SOURCEIP, "10.104.115.180");
	wiznet_ip_bin_w_reg(W52_SUBNETMASK, w52_const_subnet_classC);

	sockfd = wiznet_socket(IPPROTO_TCP);
	if (sockfd < 0)
		LPM4;
	wiznet_debug_printf("wiznet_socket(): %d\n", sockfd);

	res1 = wiznet_bind(sockfd, 80);  // Bind port 80
	if (res1 < 0)
		LPM4;

	RED_CLEAR;
	while(1) {
		if (!sockopen) {
			res1 = wiznet_accept(sockfd);
			wiznet_debug_printf("accept: %d\n", res1);
			if (!res1 || res1 == -EISCONN)
				sockopen = 1;
		} else {
			res1 = wiznet_recv(sockfd, netbuf, 32, 1);
			wiznet_debug_printf("RECV: %d\n", res1);
			switch (res1) {
				case -ENOTCONN:
				case -ECONNABORTED:
				case -ENETDOWN:
					sockopen = 0;
					break;
				case -EAGAIN:
					break;
				default:
					wiznet_debug_printf("sending;\n");
					switch (res2 = wiznet_send(sockfd, netbuf, res1, 1)) {
						case -ENOTCONN:
						case -ECONNABORTED:
						case -ETIMEDOUT:
						case -ENETDOWN:
							wiznet_debug_printf("send failed: %d\n", res2);
							sockopen = 0;
							break;
						default:
							wiznet_debug_printf("send returned: %d\n", res2);
					}
			}
		}
		wiznet_debug_printf("irq_getsocket() = %d; recvsize = %d\n", wiznet_irq_getsocket(), wiznet_recvsize(sockfd));
		if (wiznet_irq_getsocket() == -EAGAIN && !wiznet_recvsize(sockfd)) {
			wiznet_debug_printf("LPM0;\n");
			LPM0;
			wiznet_debug_printf("wake;\n");
		}
	}

	return 0;
}