Changeset 4a260f0 in rtems for c


Ignore:
Timestamp:
Sep 8, 2008, 9:51:46 AM (12 years ago)
Author:
Thomas Doerfler <Thomas.Doerfler@…>
Branches:
4.10, 4.11, 4.9, 5, master
Children:
b06d0552
Parents:
6a1c8435
Message:

corrected parameters in i2c driver for done signalling
updated mscan CAN driver

Location:
c/src/lib/libbsp/powerpc/gen5200
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/gen5200/ChangeLog

    r6a1c8435 r4a260f0  
     12008-09-08      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * include/mscan-base.h: Added bit timing macros.
     4
     52008-09-08      Thomas Doerfler <Thomas.Doerfler@embedded-brains.de>
     6
     7        * i2c/i2c.c, i2c/i2cdrv.c, i2c/mpc5200mbus.c, i2c/mpc5200mbus.h,
     8        include/i2c.h:
     9        converted done_arg to a void pointer
     10       
    1112008-09-06      Ralf Corsépius <ralf.corsepius@rtems.org>
    212
  • c/src/lib/libbsp/powerpc/gen5200/i2c/i2c.c

    r6a1c8435 r4a260f0  
    2424 */
    2525static void
    26 i2c_transfer_sema_done_func(uint32_t        arg)
    27 {
    28     rtems_id sema = (rtems_id)arg;
     26i2c_transfer_sema_done_func(void * arg)
     27{
     28    rtems_id sema = *(rtems_id *)arg;
    2929    rtems_semaphore_release(sema);
    3030}
     
    3939 */
    4040static void
    41 i2c_transfer_poll_done_func(uint32_t         arg)
     41i2c_transfer_poll_done_func(void *arg)
    4242{
    4343    bool *poll_done_flag = (bool *)arg;
     
    7373    if (sc != RTEMS_SUCCESSFUL)
    7474        return I2C_RESOURCE_NOT_AVAILABLE;
    75     sc = i2c_transfer(bus, nmsg, msg, i2c_transfer_sema_done_func, sema);
     75    sc = i2c_transfer(bus, nmsg, msg,
     76                      i2c_transfer_sema_done_func, &sema);
    7677    if (sc != RTEMS_SUCCESSFUL)
    7778    {
     
    99100i2c_transfer_wait_poll(i2c_bus_number bus, i2c_message *msg, int nmsg)
    100101{
    101     volatile bool poll_done_flag;
     102  /*
     103   * this looks nasty, but is correct:
     104   * we wait in this function, until the poll_done_flag is
     105   * set deep inside the i2c_poll() function
     106   */
     107    volatile rtems_boolean poll_done_flag;
    102108    rtems_status_code sc;
    103109    poll_done_flag = false;
    104     sc = i2c_transfer(bus, nmsg, msg, i2c_transfer_poll_done_func,
    105                       (uint32_t)&poll_done_flag);
     110    sc = i2c_transfer(bus, nmsg, msg,
     111                      i2c_transfer_poll_done_func,(void *)&poll_done_flag);
    106112    if (sc != RTEMS_SUCCESSFUL)
    107113        return sc;
  • c/src/lib/libbsp/powerpc/gen5200/i2c/i2cdrv.c

    r6a1c8435 r4a260f0  
    7171    int               nmsg;     /* number of messages in transfer */
    7272    i2c_transfer_done done;     /* transfer done callback function */
    73     uint32_t          done_arg; /* arbitrary argument to done callback */
     73    void *    done_arg_ptr;     /* arbitrary arg pointer to done callback */
    7474} i2c_qel;
    7575
     
    106106 */
    107107static void
    108 i2cdrv_done(uint32_t         arg)
     108i2cdrv_done(void * arg_ptr)
    109109{
    110110    rtems_interrupt_level level;
    111111    i2c_qel *qel = tqueue + tqueue_tail;
    112     qel->done(qel->done_arg);
     112    qel->done(qel->done_arg_ptr);
    113113    rtems_interrupt_disable(level);
    114114    tqueue_tail = (tqueue_tail + 1) % tqueue_size;
     
    141141            mpc5200mbus_select_clock_divider(&mbus[qel->bus], i2cdrv_bus_clock_div_current);
    142142        }
    143         sc = mpc5200mbus_i2c_transfer(&mbus[qel->bus], qel->nmsg, qel->msg, i2cdrv_done,
    144                                   (uint32_t)qel);
     143        sc = mpc5200mbus_i2c_transfer(&mbus[qel->bus], qel->nmsg, qel->msg,
     144                                      i2cdrv_done,qel);
    145145        if (sc != RTEMS_SUCCESSFUL)
    146146        {
     
    150150                qel->msg[i].status = I2C_RESOURCE_NOT_AVAILABLE;
    151151            }
    152             i2cdrv_done((uint32_t)qel);
     152            i2cdrv_done(qel);
    153153        }
    154154    }
     
    169169 *     msg - pointer to messages array
    170170 *     done - function which is called when transfer is finished
    171  *     done_arg - arbitrary argument passed to done funciton
     171 *     done_arg_ptr - arbitrary argument pointer passed to done funciton
    172172 *
    173173 * RETURNS:
     
    177177rtems_status_code
    178178i2c_transfer(i2c_bus_number bus, int nmsg, i2c_message *msg,
    179              i2c_transfer_done done, uint32_t         done_arg)
     179             i2c_transfer_done done, void *     done_arg_ptr)
    180180{
    181181    i2c_qel qel;
     
    196196    qel.nmsg = nmsg;
    197197    qel.done = done;
    198     qel.done_arg = done_arg;
     198    qel.done_arg_ptr = done_arg_ptr;
    199199    rtems_interrupt_disable(level);
    200200    if ((tqueue_head + 1) % tqueue_size == tqueue_tail)
  • c/src/lib/libbsp/powerpc/gen5200/i2c/mpc5200mbus.c

    r6a1c8435 r4a260f0  
    215215                        bus->msg = bus->cmsg = NULL;
    216216                        bus->nmsg = bus->byte = 0;
    217                         bus->done(bus->done_arg);
     217                        bus->done(bus->done_arg_ptr);
    218218                        break;
    219219                    }
     
    628628 *     msg - pointer to messages array
    629629 *     done - function which is called when transfer is finished
    630  *     done_arg - arbitrary argument passed to done funciton
     630 *     done_arg_ptr - arbitrary argument pointer passed to done funciton
    631631 *
    632632 * RETURNS:
     
    636636rtems_status_code
    637637mpc5200mbus_i2c_transfer(mpc5200mbus *bus, int nmsg, i2c_message *msg,
    638                      i2c_transfer_done done, uint32_t   done_arg)
     638                     i2c_transfer_done done, void *done_arg_ptr)
    639639{
    640640    if (bus->state == STATE_UNINITIALIZED)
     
    642642   
    643643    bus->done = done;
    644     bus->done_arg = done_arg;
     644    bus->done_arg_ptr = done_arg_ptr;
    645645    bus->cmsg = bus->msg = msg;
    646646    bus->nmsg = nmsg;
  • c/src/lib/libbsp/powerpc/gen5200/i2c/mpc5200mbus.h

    r6a1c8435 r4a260f0  
    5757    rtems_id               sema; /* MBUS semaphore */
    5858    i2c_transfer_done      done; /* Transfer done function */
    59     uint32_t         done_arg; /* Done function argument */
     59    void *         done_arg_ptr; /* Done function argument pointer */
    6060  int              bus_idx;  /* bus index: 0 or 1 */
    6161} mpc5200mbus;
     
    9999 *     msg - pointer to messages array
    100100 *     done - function which is called when transfer is finished
    101  *     done_arg - arbitrary argument passed to done funciton
     101 *     done_arg_ptr - arbitrary argument ptr passed to done funciton
    102102 *
    103103 * RETURNS:
     
    107107rtems_status_code
    108108mpc5200mbus_i2c_transfer(mpc5200mbus *bus, int nmsg, i2c_message *msg,
    109                      i2c_transfer_done done, uint32_t   done_arg);
     109                     i2c_transfer_done done, void * done_arg_ptr);
    110110
    111111/* mpc5200mbus_i2c_done --
  • c/src/lib/libbsp/powerpc/gen5200/include/i2c.h

    r6a1c8435 r4a260f0  
    6868                                   is failed */
    6969/* Type for function which is called when transfer over I2C bus is finished */
    70 typedef void (*i2c_transfer_done) (uint32_t        arg);
     70typedef void (*i2c_transfer_done) (void * arg);
    7171
    7272/* i2c_initialize --
     
    117117 *     msg - pointer to messages array
    118118 *     done - function which is called when transfer is finished
    119  *     done_arg - arbitrary argument passed to done funciton
     119 *     done_arg_ptr - arbitrary argument ptr passed to done funciton
    120120 *
    121121 * RETURNS:
     
    125125rtems_status_code
    126126i2c_transfer(i2c_bus_number bus, int nmsg, i2c_message *msg,
    127              i2c_transfer_done done, uint32_t         done_arg);
     127             i2c_transfer_done done, void *done_arg);
    128128
    129129/* i2c_transfer_wait --
  • c/src/lib/libbsp/powerpc/gen5200/include/mscan-base.h

    r6a1c8435 r4a260f0  
    9191 */
    9292
    93 #define BTR0_SJW(btr0)           ((btr0) << 6)
    94 #define BTR0_BRP(btr0)           ((btr0) << 0)
     93#define BTR0_SJW_MASK            0xc0
     94#define BTR0_BRP_MASK            0x3f
     95
     96#define BTR0_SJW( btr0)          ((btr0) << 6)
     97#define BTR0_BRP( btr0)          ((btr0) << 0)
     98
     99#define BTR0_GET_SJW( btr0)      (((btr0) & BTR0_SJW_MASK) >> 6)
     100#define BTR0_GET_BRP( btr0)      (((btr0) & BTR0_BRP_MASK) >> 0)
    95101
    96102/** @} */
     
    102108 */
    103109
     110#define BTR1_SAMP_MASK           0x80
     111#define BTR1_TSEG1_MASK          0x0f
     112#define BTR1_TSEG2_MASK          0x70
     113
    104114#define BTR1_SAMP                (1 << 7)
    105 #define BTR1_TSEG2(btr1)    ((btr1) << 4)
    106 #define BTR1_TSEG1(btr1)    ((btr1) << 0)
     115#define BTR1_TSEG1( btr1)        ((btr1) << 0)
     116#define BTR1_TSEG2( btr1)        ((btr1) << 4)
     117
     118#define BTR1_GET_TSEG1( btr0)    (((btr0) & BTR1_TSEG1_MASK) >> 0)
     119#define BTR1_GET_TSEG2( btr0)    (((btr0) & BTR1_TSEG2_MASK) >> 4)
    107120
    108121/** @} */
Note: See TracChangeset for help on using the changeset viewer.