Re: Timing on the Raspberry Pi, and 1541 drive emulation

From: Rob Eaglestone <robert.eaglestone_at_gmail.com>
Date: Thu, 4 Sep 2014 18:20:02 -0500
Message-ID: <CABNTyr-obCxUwsPBomNCkSzEepO8a0jTsFc4kdkfJwR2-KeV6A@mail.gmail.com>
Thanks Chris!  (And Nate!)

Between my initial email and yours, I had functions written but no
certainty that they'd work.  I'll hack on your codebase instead.

E.G. my bad code looks like:

int set_CLK( uint8_t highOrLow )
{
    // Set CLK to be an output
    bcm2835_gpio_fsel(CLK, BCM2835_GPIO_FSEL_OUTP);
    bcm2835_gpio_write(CLK, highOrLow);
}

int wait_for_CLK_to_go( uint8_t toState )
{
    // Set CLK to be an input
    bcm2835_gpio_fsel(CLK, BCM2835_GPIO_FSEL_INPT);

    // Wait awhile for CLK to be 'toState'
    int ok = 0;
    for( int i=0; i<100 || !ok; i++ )
    {
       uint8_t val = bcm2835_gpio_lev(CLK);
       if( val == toState ) ok = 1;
       bcm2835_delayMicroseconds( 1000 ); // whatever
    }
    return ok; // 1 if it's in 'toState', 0 if not.
}

int xmit_handshake()
{
   set_CLK( HIGH );
   wait_for_DAT_to_go( HIGH );
   set_CLK( LOW );

   int status = wait_for_DAT_to_go( LOW );

 /// also have to handle EOI here...

   return status;
}

int xmit_bit( byte val )
{
   set_CLK( HIGH );
   set_DAT( LOW );
   bcm2835_delayMicroseconds( 64 );

   val == 1? set_DAT( HIGH ) : set_DAT( LOW );
   set_CLK( LOW );
   bcm2835_delayMicroseconds( 64 );
}

... and so on.




On Thu, Sep 4, 2014 at 6:03 PM, Chris Osborn <fozztexx@fozztexx.com> wrote:

>
> On Sep 4, 2014, at 3:47 PM, Rob Eaglestone <robert.eaglestone@gmail.com>
> wrote:
>
> > So, shall I just hack ninepin's kernel code?  Or is there another way to
> get C to sleep reliably (with great accuracy) on the Raspberry Pi?
>
> The kernel module should be able to handle all the IEC protocol details
> for you, and you should be able to write your 1541 emulation in user space.
> The kernel module will take care of all the timing details, leaving your
> program to deal with interpreting the data. If you look at the project
> you'll see that all the disk emulation is handled outside of the kernel.
>
> --
> Follow me on twitter: @FozzTexx
> Check out my blog: http://insentricity.com
>
>
>        Message was sent through the cbm-hackers mailing list
>


       Message was sent through the cbm-hackers mailing list
Received on 2014-09-05 00:01:17

Archive generated by hypermail 2.2.0.