void DisplayDigit( uint8_t digit, uint8_t value, uint8_t dp ) //digit: melyik kijelzõre írjuk az adatot, értéke:0...5) { //value:0,1,...,F kijelzendõ szám; dp:0->nincs tizedespont 1->van uint16_t portval; uint16_t select=digit<<13; //shiftelés 7sel0,..,7sel2: PB13,..PB15; a 16 bites port felsõ 3 bitjét állítjuk, ezért select értéke 13-mal shiftelve van fölfele select: abcxxxxxxxxxxxxx a,b,c az értékes bit uint16_t data=SegmentTable[value]; //kiválasztjuk a tömbbõl a kiküldendõ adatot, a kijelzendõ szám(value) alapján data<<=8; //shiftelés 0xab00 DB0..DB7->PE8..Pe15: E port felsõ 8 bitje, ezért shiftejük 8-cal az értéket GPIO_ResetBits(GPIOB,GPIO_Pin_8); //7seg_clk lefutó él (D flipflophoz) portval=GPIO_ReadOutputData(GPIOB); //kiolvassuk a B port jelenlegi értékét (select itt kerül a port lábaira portval&=0x1FFF; //port többi bitjét ne piszkáljuk, ezért a felsõ 3 bitet(13,14,15) kinulázzuk, a többi értékénél marad portval|=select; //select értékét átmentjük a port felsõ 3 bitjébe (select alsó 13 bitje 0) GPIO_Write(GPIOB,portval); //kiküldjük az adatot a B portra (7sel0,7sel1,7sel2 értéket kap, amik demuxon keresztül kiválasztanak egy db kijelzõt, amit meghajtunk) portval=GPIO_ReadOutputData(GPIOE); //hasonlóan az E portnál is portval&=0x00FF; //alsó 8 bitet változatlanul kell visszaírni portval|=data; //data értéke bekerül a port felsõ 8 bitjébe GPIO_Write(GPIOE,portval); //adatkiírás if(dp) GPIO_SetBits(GPIOE,GPIO_Pin_15); //ha kell tizedespont, állítjuk a megfelelõ lábat else GPIO_ResetBits(GPIOE,GPIO_Pin_15); GPIO_SetBits(GPIOB,GPIO_Pin_8); //7seg_clk felfutó él-> D-flipflop kimenetén megjelenik az adat GPIO_ResetBits(GPIOE,GPIO_Pin_7); //#7sen: engedélyezzük a demux-t és D-flipflop-ot (low active) }
void BSP_LED_Toggle (CPU_INT08U led) { CPU_INT32U pins; switch (led) { case 0: pins = GPIO_ReadOutputData(GPIOD); pins ^= BSP_GPIOD_LEDS; GPIO_SetBits( GPIOD, pins & BSP_GPIOD_LEDS); GPIO_ResetBits(GPIOD, (~pins) & BSP_GPIOD_LEDS); break; case 1: case 2: case 3: pins = GPIO_ReadOutputData(GPIOD); if ((pins & (1 << (led + BSP_LED_START_BIT))) == 0) { GPIO_SetBits( GPIOD, (1 << (led + BSP_LED_START_BIT))); } else { GPIO_ResetBits(GPIOD, (1 << (led + BSP_LED_START_BIT))); } break; default: break; } }
void CLed::Toggle (u8 led) { uint16_t pins; switch (led) { case 0: pins = GPIO_ReadOutputData(BSP_LED_GPIO); pins ^= BSP_LEDS; GPIO_SetBits( BSP_LED_GPIO, pins & BSP_LEDS); GPIO_ResetBits(BSP_LED_GPIO, (~pins) & BSP_LEDS); break; case 1: case 2: case 3: case 4: pins = GPIO_ReadOutputData(BSP_LED_GPIO); if ((pins & (1 << (led + BSP_LED_START_BIT))) == 0) { GPIO_SetBits( BSP_LED_GPIO, (1 << (led + BSP_LED_START_BIT))); } else { GPIO_ResetBits(BSP_LED_GPIO, (1 << (led + BSP_LED_START_BIT))); } break; default: break; } }
void iris_auto_motor_run(u8 mode) { static u8 i=0; u16 temp = 0; switch(mode) { case 1: temp = GPIO_ReadOutputData(IRIS_AUTO_PORT); temp &= 0xFFF0; temp |= ((u16)iris_auto_table[i]); GPIO_Write(IRIS_AUTO_PORT, temp); i++; if(i>=4) i = 0; zoom_run_state_pre = zoom_run_state; zoom_run_state = 1; break; case 2: temp = GPIO_ReadOutputData(IRIS_AUTO_PORT); temp &= 0xFFF0; temp |= ((u16)iris_auto_table[i]); GPIO_Write(IRIS_AUTO_PORT, temp); //i--; if(i == 0) i = 4-1; else i--; zoom_run_state_pre = zoom_run_state; zoom_run_state = 1; break; case 0: md127_keepmode(); zoom_run_state_pre = zoom_run_state; zoom_run_state = 0; break; default: return; } md127_keepmode(); }
/** **=========================================================================== ** ** Abstract: main program ** **=========================================================================== */ int main(void) { int i = 0; unsigned int ledState=0x1000; unsigned int portState; /** * IMPORTANT NOTE! * The symbol VECT_TAB_SRAM needs to be defined when building the project * if code has been located to RAM and interrupts are used. * Otherwise the interrupt table located in flash will be used. * See also the <system_*.c> file and how the SystemInit() function updates * SCB->VTOR register. * E.g. SCB->VTOR = 0x20000000; */ GPIO_Config(); GPIO_ResetBits(GPIOD, GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15); /* Infinite loop */ while (1) { if (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0)) { portState=GPIO_ReadOutputData(GPIOD); portState&=0x0FFF; GPIO_Write(GPIOD, portState | ledState); ledState=ledState<<1; if (ledState>0x8000) ledState=0x1000; for(i=0; i<200000; i++) __NOP(); } } }
/** * Initializes the analog input multiplexer, configuring the processor's peripherals and setting * the multiplexer to its default state. * * @param none * @retval none */ void InputMultiplexerInit(void) { GPIO_InitTypeDef GPIO_InitStructure; /* Enable the GPIO Clock */ RCC_AHB1PeriphClockCmd(OCAL_CONTROL_GPIO_CLK, ENABLE); /* Configure the DEMUX GPIO pins */ GPIO_InitStructure.GPIO_Pin = OCAL_CONTROL_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; /* At most the multiplexer can handle a few hundred Hz */ GPIO_Init(OCAL_CONTROL_GPIO_PORT, &GPIO_InitStructure); GPIO_WriteBit(OCAL_CONTROL_GPIO_PORT, OCAL_CONTROL_PIN, OCAL_SELECT); /* TODO: This is temporary until the REV D boards arrive. Should be EXT_ANALOG_SELECT */ /* Enable the DEMUX GPIO Clock */ RCC_AHB1PeriphClockCmd(EXT_ANALOG_IN_GPIO_CLK, ENABLE); /* Configure the DEMUX GPIO pins */ GPIO_InitStructure.GPIO_Pin = EXT_ANALOG_IN_MUX_PINS; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; /* At most the multiplexer can handle a few hundred Hz */ GPIO_Init(EXT_ANALOG_IN_MUX_PORT, &GPIO_InitStructure); GPIO_Write(EXT_ANALOG_IN_MUX_PORT, (EXTERN_0 | (GPIO_ReadOutputData(EXT_ANALOG_IN_MUX_PORT ) & EXT_ANALOG_IN_BITMASK ))); }
//***********点使能第几路红外发射管 void Light(u8 port_num) { u8 kk,led_light=0; if(port_num&BIT0) led_light|=BIT7; if(port_num&BIT1) led_light|=BIT6; if(port_num&BIT2) led_light|=BIT5; kk =GPIO_ReadOutputData(GPIOC)&0x1f; GPIO_Write(GPIOC, kk|led_light); }
unsigned char CheckMotorStatus(void) { unsigned char MotorRunning = 0; //读取列与行状态,未检测第10列(正反转) if(! ( ((GPIO_ReadOutputData(GPIOA)&0x8A10)<0x8A10) | ((GPIO_ReadOutputData(GPIOB)&0xEC00)<0xEC00)\ | ((GPIO_ReadOutputData(GPIOC)&0x1680)<0x1680) | ((GPIO_ReadOutputData(GPIOD)&0xA200)<0xA200)\ | ((GPIO_ReadOutputData(GPIOE)&0x780)<0x780) | ((GPIO_ReadOutputData(GPIOA)&0x1501)<0x1501)\ | ((GPIO_ReadOutputData(GPIOC)&0xE940)<0xE940) | ((GPIO_ReadOutputData(GPIOD)&0x5510)<0x5510)\ | ((GPIO_ReadOutputData(GPIOE)&0x007C)<0x007C) )) { MotorRunning = 0; } else MotorRunning = 1; return MotorRunning; }
void md127_keepmode(void)//保持上一输入状态函数 { u16 temp; temp = GPIO_ReadOutputData(IRIS_AUTO_PORT); temp &= 0xFFF0; temp |= ((u16)0X0F); GPIO_Write(IRIS_AUTO_PORT, temp); }
/*----------------------------------------------------------------------------*/ static void DATA(uint8_t d) { uint32_t port; port = GPIO_ReadOutputData(GPIOA); port &= ~(LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7); port |= (d & 1) ? LCD_D4 : 0; port |= (d & 2) ? LCD_D5 : 0; port |= (d & 4) ? LCD_D6 : 0; port |= (d & 8) ? LCD_D7 : 0; GPIO_Write(GPIOA, port); }
/***************************************************************************//** * @brief Write 4-bits to LCD controller ******************************************************************************/ void Lcd_Write_4bits(uc8 byte) { uint16_t u16Temp=0; GPIO_WriteBit(GPIOA, RW, Bit_RESET); GPIO_WriteBit(GPIOA, EN, Bit_SET); u16Temp = GPIO_ReadOutputData(GPIOB)&0xFFF0; u16Temp |= SWAP_DATA[byte&0x0F]; GPIO_Write(GPIOB, u16Temp); Delay(10000); GPIO_WriteBit(GPIOA, EN, Bit_RESET); Delay(10000); }
void BSP_LED_Toggle (CPU_INT08U led) { CPU_INT32U pins; pins = GPIO_ReadOutputData(GPIOC); switch (led) { case 0: BSP_LED_Toggle(1); BSP_LED_Toggle(2); BSP_LED_Toggle(3); BSP_LED_Toggle(4); break; case 1: if ((pins & BSP_GPIOF_LED1) == 0) { GPIO_SetBits( GPIOF, BSP_GPIOF_LED1); } else { GPIO_ResetBits(GPIOF, BSP_GPIOF_LED1); } break; case 2: if ((pins & BSP_GPIOF_LED2) == 0) { GPIO_SetBits( GPIOF, BSP_GPIOF_LED2); } else { GPIO_ResetBits(GPIOF, BSP_GPIOF_LED2); } break; case 3: if ((pins & BSP_GPIOF_LED3) == 0) { GPIO_SetBits( GPIOF, BSP_GPIOF_LED3); } else { GPIO_ResetBits(GPIOF, BSP_GPIOF_LED3); } break; case 4: if ((pins & BSP_GPIOF_LED4) == 0) { GPIO_SetBits( GPIOF, BSP_GPIOF_LED4); } else { GPIO_ResetBits(GPIOF, BSP_GPIOF_LED4); } break; default: break; } }
void md127_forward(void)//正向前进函数 { u16 temp; temp = GPIO_ReadOutputData(IRIS_AUTO_PORT); temp &= 0xFFF0; temp |= ((u16)iris_auto_table[test_127]); GPIO_Write(IRIS_AUTO_PORT, temp); test_127++; if(test_127>3) test_127=0; }
void md127_reverse(void)//反向函数 { u16 temp; temp = GPIO_ReadOutputData(IRIS_AUTO_PORT); temp &= 0xFFF0; temp |= ((u16)iris_auto_table[test_127]); GPIO_Write(IRIS_AUTO_PORT, temp); test_127++; if(test_127>7) test_127=0; }
/** * Selects the specified external input. This will cause the board to temporarily enter the ADC_EXTERNAL_MUXING * state (which will also sample the boards temperature sensor). This function is non-blocking but any analog * sampling will be held up by the state machine until the muxing process is completed. * * @param input ExternalMuxedInput_t The external input to select. * @retval none */ static void SelectExternalInput(ExternalMuxedInput_t input) { /* Verify that the internal input parameter is set */ if (input == NULL_CHANNEL ) { #ifdef INPUT_MULTIPLEXER_DEBUG printf("[Analog Input Multiplexer] Attempted to select an input as external when it is not configured to be.\n\r"); #endif return; } /* Make the switch */ SelectInternalInput(EXTERNAL_ANALOG_IN); GPIO_Write(EXT_ANALOG_IN_MUX_PORT, (input | (GPIO_ReadOutputData(EXT_ANALOG_IN_MUX_PORT ) & EXT_ANALOG_IN_BITMASK ))); /* Wait for the external multiplexing relays to conduct */ MuxCompleteTime = GetLocalTime() + EXTERNAL_MUX_DELAY; /* Change ADC state machine to ADC_MUXING state */ ADC_External_Muxing(); }
void bsp_led_bottom_toggle(BSP_LED_BOTTOM_Def led) { s32 pins; if( led >= ledBottomMax ) return; pins = GPIO_ReadOutputData(led_bottom_group[ led ].gpio_reg); if ((pins & led_bottom_group[led].pin) == 0) { GPIO_SetBits(led_bottom_group[led].gpio_reg, led_bottom_group[led].pin); } else { GPIO_ResetBits(led_bottom_group[led].gpio_reg, led_bottom_group[led].pin); } }
void bsp_led_core_toggle(BSP_LED_CORE_Def led) { s32 pins; if( led >= ledCoreMax ) return; pins = GPIO_ReadOutputData(led_core_group[ led ].gpio_reg); if ((pins & led_core_group[led].pin) == 0) { GPIO_SetBits(led_core_group[led].gpio_reg, led_core_group[led].pin); } else { GPIO_ResetBits(led_core_group[led].gpio_reg, led_core_group[led].pin); } }
/* The Demo Task */ void Task_Demo(void* param) { uint16_t ledVal = 0x1000; uint16_t portVal; while(1) { ledVal <<= 1; if ( ledVal == 0) ledVal = 0x1000; portVal = GPIO_ReadOutputData(GPIOD); portVal &= 0x0fff; portVal |= ledVal; GPIO_Write(GPIOD,portVal); OSTimeDly(OS_TICKS_PER_SEC/4); } }
void Dio_WriteChannel(Dio_ChannelType channelId, Dio_LevelType level) { VALIDATE( DioGlobal.InitRun, DIO_WRITECHANNEL_ID, DIO_E_UNINIT ); /** @req SWS_Dio_00074 */ VALIDATE( IS_VALID_CHANNEL(channelId), DIO_WRITECHANNEL_ID, DIO_E_PARAM_INVALID_CHANNEL_ID); Dio_PortLevelType portVal = GPIO_ReadOutputData(GPIO_ports[DIO_GET_PORT_FROM_CHANNEL_ID(channelId)]); Dio_PortLevelType bit = DIO_GET_BIT_FROM_CHANNEL_ID(channelId); if(level == STD_HIGH){ portVal |= bit; }else{ portVal &= ~bit; } Dio_WritePort(DIO_GET_PORT_FROM_CHANNEL_ID(channelId), portVal); return; }
void Dio_WriteChannelGroup(const Dio_ChannelGroupType *channelGroupIdPtr, Dio_PortLevelType level) { VALIDATE( DioGlobal.InitRun, DIO_WRITECHANNELGROUP_ID, DIO_E_UNINIT ); /** @req SWS_Dio_00114 */ VALIDATE( IS_VALID_CHANNELGROUP(channelGroupIdPtr), DIO_WRITECHANNELGROUP_ID, DIO_E_PARAM_INVALID_GROUP_ID ); // Shift up and apply mask so that no unwanted bits are affected level = (level << channelGroupIdPtr->offset) & channelGroupIdPtr->mask; // Read port and clear out masked bits Dio_PortLevelType portVal = GPIO_ReadOutputData(GPIO_ports[channelGroupIdPtr->port]) & (~channelGroupIdPtr->mask); // Or in the upshifted masked level portVal |= level; Dio_WritePort(channelGroupIdPtr->port, portVal); return; }
void lcd_write(uint8_t data, uint8_t rs) { __IO uint8_t outputdata; if(rs) { //write data lcd_rs_high(); } else { //write instruction lcd_rs_low(); } lcd_rw_low(); //set to write //set data pins to output GPIO_InitStructure.GPIO_Pin = DATA_PORT_Pin_0 | DATA_PORT_Pin_1 | DATA_PORT_Pin_2 | DATA_PORT_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_Init(LCD_PORT, &GPIO_InitStructure); /** * Preserve the RS,RW,E bits in order to write out: * our data goe son the 4 most significant bits with * the high nibble output first. */ outputdata = (uint8_t)GPIO_ReadOutputData(LCD_PORT); outputdata &= 0x05; //we're only interested in the lower bits (RS,RW,E) //output high nibble first GPIO_Write(LCD_PORT, outputdata | (data & 0xF0)); //push data lcd_e_toggle(); GPIO_Write(LCD_PORT, outputdata | ((data << 4) & 0xF0)); //push data lcd_e_toggle(); GPIO_Write(LCD_PORT, outputdata | 0xF0); //set pins high as inactive state }
pio_type platform_pio_op( unsigned port, pio_type pinmask, int op ) { pio_type retval = 1; GPIO_InitTypeDef GPIO_InitStructure; GPIO_TypeDef * base = pio_port[ port ]; switch( op ) { case PLATFORM_IO_PORT_SET_VALUE: GPIO_Write(base, pinmask); break; case PLATFORM_IO_PIN_SET: GPIO_SetBits(base, pinmask); break; case PLATFORM_IO_PIN_CLEAR: GPIO_ResetBits(base, pinmask); break; case PLATFORM_IO_PORT_DIR_INPUT: pinmask = GPIO_Pin_All; case PLATFORM_IO_PIN_DIR_INPUT: GPIO_InitStructure.GPIO_Pin = pinmask; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(base, &GPIO_InitStructure); break; case PLATFORM_IO_PORT_DIR_OUTPUT: pinmask = GPIO_Pin_All; case PLATFORM_IO_PIN_DIR_OUTPUT: GPIO_InitStructure.GPIO_Pin = pinmask; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(base, &GPIO_InitStructure); break; case PLATFORM_IO_PORT_GET_VALUE: retval = pinmask == PLATFORM_IO_READ_IN_MASK ? GPIO_ReadInputData(base) : GPIO_ReadOutputData(base); break; case PLATFORM_IO_PIN_GET: retval = GPIO_ReadInputDataBit(base, pinmask); break; case PLATFORM_IO_PIN_PULLUP: GPIO_InitStructure.GPIO_Pin = pinmask; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_Init(base, &GPIO_InitStructure); break; case PLATFORM_IO_PIN_PULLDOWN: GPIO_InitStructure.GPIO_Pin = pinmask; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; GPIO_Init(base, &GPIO_InitStructure); break; case PLATFORM_IO_PIN_NOPULL: GPIO_InitStructure.GPIO_Pin = pinmask; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(base, &GPIO_InitStructure); break; default: retval = 0; break; } return retval; }
void MotorColStop(int Col) { unsigned char i; switch (Col) { case 1: GPIO_SetBits(GPIOC, GPIO_Pin_12);//Col 1st GPIO_SetBits(GPIOA, GPIO_Pin_4); break; case 2: GPIO_SetBits(GPIOC, GPIO_Pin_10);//Col 2nd GPIO_SetBits(GPIOE, GPIO_Pin_7); break; case 3: GPIO_SetBits(GPIOA, GPIO_Pin_15);//Col 3rd GPIO_SetBits(GPIOE, GPIO_Pin_8); break; case 4: GPIO_SetBits(GPIOA, GPIO_Pin_11);//Col 4th GPIO_SetBits(GPIOE, GPIO_Pin_9); break; case 5: GPIO_SetBits(GPIOA, GPIO_Pin_9);//Col 5th GPIO_SetBits(GPIOE, GPIO_Pin_10); break; case 6: GPIO_SetBits(GPIOC, GPIO_Pin_9);//Col 6th GPIO_SetBits(GPIOB, GPIO_Pin_10); break; case 7: GPIO_SetBits(GPIOC, GPIO_Pin_7);//Col 7th GPIO_SetBits(GPIOB, GPIO_Pin_11); break; case 8: GPIO_SetBits(GPIOD, GPIO_Pin_15);//Col 8th GPIO_SetBits(GPIOB, GPIO_Pin_13); break; case 9: GPIO_SetBits(GPIOD, GPIO_Pin_13);//Col 9th GPIO_SetBits(GPIOB, GPIO_Pin_15); break; case 10: GPIO_SetBits(GPIOD, GPIO_Pin_11);//Col 10th GPIO_SetBits(GPIOB, GPIO_Pin_12); break; case 11: GPIO_SetBits(GPIOD, GPIO_Pin_9);//Col 11th GPIO_SetBits(GPIOB, GPIO_Pin_14); break; default: break; } //必须所有的列关闭,行才能关闭,if的条件中!0 = 1, 则所有的为0,相或才能为0; //若要每个为0,则必须大于等于0x8A10,如果要等于8A10,则必须所有的都为高电平 if(! (((GPIO_ReadOutputData(GPIOA)&0x8A10)<0x8A10) | ((GPIO_ReadOutputData(GPIOB)&0xEC00)<0xEC00)\ | ((GPIO_ReadOutputData(GPIOC)&0x1680)<0x1680) | ((GPIO_ReadOutputData(GPIOD)&0xA200)<0xA200)\ | ((GPIO_ReadOutputData(GPIOE)&0x780)<0x780) ))//未检测10列的正反转 { for(i = 1; i <=9; i++) { MotorRowStop(i); } } }
void ledToggle(uint16_t mask){ uint16_t state = GPIO_ReadOutputData(GPIOB); state ^= (0xffff & mask); GPIO_Write(GPIOB, state); }
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; }