Esempio n. 1
0
int main(void) {
    char tmp[256];

    const char message[] =
        "This royal throne of kings, this scepter'd isle, \n"
        "This earth of majesty, this seat of Mars, \n"
        "This other Eden, demi-paradise, \n"
        "This fortress built by Nature for herself\n"
        "Against infection and the hand of war, \n"
        "This happy breed of men, this little world,\n"
        "This precious stone set in the silver sea, \n"
        "Which serves it in the office of a wall, \n"
        "Or as a moat defensive to a house, \n"
        "Against the envy of less happier lands, \n"
        "This blessed plot, this earth, this realm, this England,";
    const uint16 messlen = strlen(message);

    TIM2_timer_start();
    usart_init(&Serial6, USART6, PC7, PC6, 57600);

    usart_print(&Serial6, "Basic initialization has been finished.\n");

    nokiaLCD.init();

    RCC_ClocksTypeDef RCC_Clocks;
    RCC_GetClocksFreq(&RCC_Clocks);

    usart_print(&Serial6, message);
    usart_print(&Serial6, "\r\n\r\n");
    usart_flush(&Serial6);

    sprintf(tmp, "Clock frequencies: SYSCLK = %dl, HCLK = %dl, PCLK1 = %dl\r\n",
            RCC_Clocks.SYSCLK_Frequency, RCC_Clocks.HCLK_Frequency, RCC_Clocks.PCLK1_Frequency);
    usart_print(&Serial6, tmp);

    GPIOMode(PinPort(LED1), (PinBit(LED1) | PinBit(LED2) | PinBit(LED3) | PinBit(LED4)),
             OUTPUT, FASTSPEED, PUSHPULL, NOPULL);

    nokiaLCD.clear();
    nokiaLCD.drawBitmap(Nokia5110::SFEFlame);
    delay(1000);

    uint16 shift = 0;
    nokiaLCD.selectFont(Nokia5110::PROPORTIONAL10x15);

    while (1) {
        nokiaLCD.clear();
        nokiaLCD.cursor(252 - shift );
        nokiaLCD.drawString("GNU is Nuke an Uran 01235y!");
//		nokiaLCD.drawFont(Nokia5110::Chicago10x15, 'A');
//		nokiaLCD.drawFont(Nokia5110::Chicago10x15, 'W');
        shift++;
        shift %= 252;
        delay(250);

        /*
        		if ( millis() / 125 != shift ) {
        			shift = millis()/ 125;
        			nokiaLCD.clear();
        			nokiaLCD.gotoXY(7- shift%7,0);
        			strncpy(tmp, message+((shift/7) % messlen), 48);
        			tmp[48] = 0;
        			nokiaLCD.drawString(tmp);
        //		usart_print(&Serial6, tmp);
        //		usart_print(&Serial6, "\r\n");
        		}
        		*/
    }
}
Esempio n. 2
0
File: main.c Progetto: ADTL/ARMWork
int main(void) {
	uint16_t bits;
	uint32_t intval = 40;
	uint32_t tnow;
	char tmp[92];
	RCC_ClocksTypeDef RCC_Clocks;
	uint16_t i;
	
	TIM2_timer_start();

	usart_begin(&USerial3, USART3, PC11, PC10, 19200);

	usart_print(&USerial3, 
			"Happy are those who know they are spiritually poor; \n"
			"The kingdom of heaven belongs to them!\n");
	usart_flush(&USerial3);
	
	RCC_GetClocksFreq(&RCC_Clocks);

	sprintf(tmp, "SYSCLK = %ul\n", RCC_Clocks.SYSCLK_Frequency);
	usart_print(&USerial3, tmp);
	sprintf(tmp, "PCLK1 = %ul\n", RCC_Clocks.PCLK1_Frequency);
	usart_flush(&USerial3);

	GPIOMode(PinPort(PD12),
			(PinBit(PD12) | PinBit(PD13) | PinBit(PD14) | PinBit(PD15)), OUTPUT,
			FASTSPEED, PUSHPULL, NOPULL);
			/*
	spi_begin(SPI2, PB13, PB14, PB15, PB12);
	digitalWrite(PB12, HIGH);
*/
	I2C1_Init();
/*
	i2c_begin(&Wire1, PB9, PB8, 100000);
	lcd.init(&Wire1);
	lcd.begin();
	lcd.setContrast(46);
	lcd.print("Yappee!");       // Classic Hello World!
*/
	bits = GPIO_ReadOutputData(GPIOD );
	GPIOWrite(GPIOD, PinBit(PD13) | (bits & 0x0fff));
	delay_ms(intval);
	tnow = millis() / 1000;
	while (tnow == millis() / 1000)
		;
	tnow = millis() / 1000;

	while (1) {
		bits = GPIO_ReadOutputData(GPIOD );

		GPIOWrite(GPIOD, PinBit(PD13) | (bits & 0x0fff));
		delay_ms(intval);
		GPIOWrite(GPIOD, PinBit(PD14) | (bits & 0x0fff));
		delay_ms(intval);
		GPIOWrite(GPIOD, PinBit(PD15) | (bits & 0x0fff));
		delay_ms(intval);
		GPIOWrite(GPIOD, PinBit(PD12) | (bits & 0x0fff));
		delay_ms(intval);
		//
		bits &= 0x0fff;
		switch ((tnow % 60) / 15) {
		case 3:
			bits |= PinBit(PD12);
		case 2:
			bits |= PinBit(PD15);
		case 1:
			bits |= PinBit(PD14);
		case 0:
		default:
			bits |= PinBit(PD13);
			break;
		}
		GPIOWrite(GPIOD, bits);

		while (tnow == millis() / 1000);
		tnow = millis() / 1000;

		//Serial3.print(tmp);
		sprintf(tmp, "%04ld\n", millis());
		usart_print(&USerial3, tmp);

		/*
		digitalWrite(PB12, LOW);
		spi_transfer(SPI2, (uint8_t *) tmp, 8);
		digitalWrite(PB12, HIGH);
*/
		i = 0;
		if (usart_available(&USerial3) > 0) {
			while (usart_available(&USerial3) > 0 && i < 92) {
				tmp[i++] = (char) usart_read(&USerial3);
			}
			tmp[i] = 0;
			usart_print(&USerial3, "> ");
			usart_print(&USerial3, tmp);
			usart_print(&USerial3, "\n");
		}

	}
	return 0;
}