Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stm32f10x.h"
- #include "stm32f10x_gpio.h" //implementacja bibliotek
- #include "stm32f10x_rcc.h"
- GPIO_InitTypeDef GPIO_InitStructure ;
- GPIO_InitTypeDef GPIO_InitStructure1 ;
- GPIO_InitTypeDef GPIO_InitStructure12out ;
- GPIO_InitTypeDef GPIO_InitStructure12in ;
- GPIO_InitTypeDef GPIO_InitStructure10out ;
- unsigned char tab [ 16 ] = { 0xC0 , 0xF9 , 0xA4 , 0xB0 , 0x99 , 0x92 , 0x82 , 0xF8 , 0x80 ,
- 0x90 , 0x88 , 0x83 , 0xC6 , 0xA1 , 0x86 , 0x8E }; // utworzenie tablicy
- unsigned char cztery = 0x99 ;
- unsigned char dwa = 0xA4
- int main ( void ) {
- RCC_APB2PeriphClockCmd ( RCC_APB2Periph_GPIOC , ENABLE );
- GPIO_InitStructure . GPIO_Speed = GPIO_Speed_50MHz ;
- GPIO_InitStructure . GPIO_Mode = GPIO_Mode_Out_PP ;
- GPIO_InitStructure . GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 ;
- GPIO_Init ( GPIOC , & GPIO_InitStructure );
- while ( 1 ) {
- unsigned int i = 0 ;
- unsigned int j = 0 ;
- //wyś 1 wyjście
- RCC_APB2PeriphClockCmd ( RCC_APB2Periph_GPIOC , ENABLE );
- GPIO_InitStructure1 . GPIO_Speed = GPIO_Speed_50MHz ;
- GPIO_InitStructure1 . GPIO_Mode = GPIO_Mode_Out_PP ;
- GPIO_InitStructure1 . GPIO_Pin = GPIO_Pin_10 ;
- GPIO_Init ( GPIOC , & GPIO_InitStructure1 );
- //wyś 1 = 1
- GPIO_WriteBit ( GPIOC , GPIO_Pin_10 , Bit_SET ); // włączenie wyś 1
- //wyś 2 wejście
- RCC_APB2PeriphClockCmd ( RCC_APB2Periph_GPIOC , ENABLE );
- GPIO_InitStructure12in . GPIO_Speed = GPIO_Speed_50MHz ;
- GPIO_InitStructure12in . GPIO_Mode = GPIO_Mode_IN_FLOATING ;
- GPIO_InitStructure12in . GPIO_Pin = GPIO_Pin_12 ;
- GPIO_Init ( GPIOC , & GPIO_InitStructure12in );
- //wyś 2 = 1
- GPIO_WriteBit ( GPIOC , GPIO_Pin_12 , Bit_SET ); // właczenie wyś 2
- GPIOC -> ODR = dwa ; // wyswietlenie cyfry 2
- for ( i = 0 ; i < 40000 ; i ++); //delay
- //wyś 1 = 0
- GPIO_WriteBit ( GPIOC , GPIO_Pin_10 , Bit_RESET );
- //wyś 2 = 0
- GPIO_WriteBit ( GPIOC , GPIO_Pin_12 , Bit_RESET );
- //wyś 2 wyjście
- RCC_APB2PeriphClockCmd ( RCC_APB2Periph_GPIOC , ENABLE );
- GPIO_InitStructure12out . GPIO_Speed = GPIO_Speed_50MHz ;
- GPIO_InitStructure12out . GPIO_Mode = GPIO_Mode_Out_OD ;
- GPIO_InitStructure12out . GPIO_Pin = GPIO_Pin_12 ;
- GPIO_Init ( GPIOC , & GPIO_InitStructure12out );
- //wyś 2 = 1
- GPIO_WriteBit ( GPIOC , GPIO_Pin_12 , Bit_SET ); // właczenie wyś 2
- //wyś 1 wejście
- RCC_APB2PeriphClockCmd ( RCC_APB2Periph_GPIOC , ENABLE );
- GPIO_InitStructure10out . GPIO_Speed = GPIO_Speed_50MHz ;
- GPIO_InitStructure10out . GPIO_Mode = GPIO_Mode_IN_FLOATING ;
- GPIO_InitStructure10out . GPIO_Pin = GPIO_Pin_10 ;
- GPIO_Init ( GPIOC , & GPIO_InitStructure10out );
- //wyś 1 = 1
- GPIO_WriteBit ( GPIOC , GPIO_Pin_10 , Bit_SET ); // włączenie wyś 1
- GPIOC -> ODR = cztery ; // wyswietlenie cyfry 4
- for ( i = 0 ; i < 40000 ; i ++); //delay
- }
- }
- GPIOC -> ODR = jeden ; // wyswietlenie cyfry 1
- GPIOC -> ODR = dwa ; // wyswietlenie cyfry 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement