Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch67 committed Nov 6, 2016
1 parent a5a77fd commit d44b119
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 61 deletions.
61 changes: 0 additions & 61 deletions STM32F103C8T6/uartdev/notmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,69 +58,8 @@ static void hexstring ( unsigned int d )
uart_putc(0x0A);
}

static unsigned int b12input;
static unsigned int b12output;
static unsigned int b12odrbb;
static unsigned int b12idrbb;

static void pull_up ( void )
{
PUT32(GPIOBBASE+0x04,b12input);
PUT32(b12odrbb,1);
}
static void pull_down ( void )
{
PUT32(GPIOBBASE+0x04,b12output);
PUT32(b12odrbb,0);
}

int notmain ( void )
{
unsigned int ra;
unsigned int rb;
unsigned int rc;


hexstring(0xAAAAAAAA);

PUT32(STK_CSR,4);
PUT32(STK_RVR,0xFFFFFFFF);
PUT32(STK_CVR,0x00000000);
PUT32(STK_CSR,5);

ra=GET32(RCCBASE+0x18);
ra|=1<<3; //enable port b
PUT32(RCCBASE+0x18,ra);
//config
ra=GET32(GPIOBBASE+0x04);
b12input =(ra&~(0xF<<16))|(0x8<<16);
b12output=(ra&~(0xF<<16))|(0x5<<16);
b12odrbb=PERIPH_BB_BASE|(((GPIOBBASE+0x0C)&0x000FFFFF)<<5)|(12<<2);
b12idrbb=PERIPH_BB_BASE|(((GPIOBBASE+0x08)&0x000FFFFF)<<5)|(12<<2);

pull_down();
//480us 3840
rb=GET32(STK_CVR);
while(1)
{
ra=GET32(STK_CVR);
rc=(rb-ra)&STK_MASK; //count down
if(rc>4000) break;
}
pull_up();
rb=GET32(STK_CVR);
while(1)
{
if(GET32(b12idrbb)==0) break;
}
ra=GET32(STK_CVR);
while(1)
{
if(GET32(b12idrbb)) break;
}
rc=GET32(STK_CVR);
hexstring((rb-ra)&STK_MASK); //count down
hexstring((rb-rc)&STK_MASK); //count down

return(0);
}
11 changes: 11 additions & 0 deletions STM32F103C8T6/uartdev/uartdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ void dummy ( unsigned int );
#define RCC_CR (RCC_BASE+0x00)
#define RCC_CFGR (RCC_BASE+0x04)

#define GPIOBBASE 0x40010C00
#define RCCBASE 0x40021000

#define STK_CSR 0xE000E010
#define STK_RVR 0xE000E014
#define STK_CVR 0xE000E018
#define STK_MASK 0x00FFFFFF

#define PERIPH_BB_BASE 0x42000000

static void clock_init ( void )
{
unsigned int ra;
Expand Down Expand Up @@ -112,6 +122,7 @@ static void hexstring ( unsigned int d )
uart_putc(0x0D);
uart_putc(0x0A);
}

int notmain ( void )
{
clock_init();
Expand Down

0 comments on commit d44b119

Please sign in to comment.