master/sdo.c
branchstable-1.4
changeset 1686 e206f4485f60
parent 1685 399ef727bf62
child 1363 11c0b2caa253
equal deleted inserted replaced
1685:399ef727bf62 1686:e206f4485f60
    24  *
    24  *
    25  *****************************************************************************/
    25  *****************************************************************************/
    26 
    26 
    27 /**
    27 /**
    28    \file
    28    \file
    29    CANopen Sdo functions.
    29    CANopen SDO functions.
    30 */
    30 */
    31 
    31 
    32 /*****************************************************************************/
    32 /*****************************************************************************/
    33 
    33 
    34 #include <linux/slab.h>
    34 #include <linux/slab.h>
    40 /*****************************************************************************/
    40 /*****************************************************************************/
    41 
    41 
    42 /** Constructor.
    42 /** Constructor.
    43  */
    43  */
    44 void ec_sdo_init(
    44 void ec_sdo_init(
    45         ec_sdo_t *sdo, /**< Sdo. */
    45         ec_sdo_t *sdo, /**< SDO. */
    46         ec_slave_t *slave, /**< Parent slave. */
    46         ec_slave_t *slave, /**< Parent slave. */
    47         uint16_t index /**< Sdo index. */
    47         uint16_t index /**< SDO index. */
    48         )
    48         )
    49 {
    49 {
    50     sdo->slave = slave;
    50     sdo->slave = slave;
    51     sdo->index = index;
    51     sdo->index = index;
    52     sdo->object_code = 0x00;
    52     sdo->object_code = 0x00;
    55     INIT_LIST_HEAD(&sdo->entries);
    55     INIT_LIST_HEAD(&sdo->entries);
    56 }
    56 }
    57 
    57 
    58 /*****************************************************************************/
    58 /*****************************************************************************/
    59 
    59 
    60 /** Sdo destructor.
    60 /** SDO destructor.
    61  *
    61  *
    62  * Clears and frees an Sdo object.
    62  * Clears and frees an SDO object.
    63  */
    63  */
    64 void ec_sdo_clear(
    64 void ec_sdo_clear(
    65         ec_sdo_t *sdo /**< Sdo. */
    65         ec_sdo_t *sdo /**< SDO. */
    66         )
    66         )
    67 {
    67 {
    68     ec_sdo_entry_t *entry, *next;
    68     ec_sdo_entry_t *entry, *next;
    69 
    69 
    70     // free all entries
    70     // free all entries
    78         kfree(sdo->name);
    78         kfree(sdo->name);
    79 }
    79 }
    80 
    80 
    81 /*****************************************************************************/
    81 /*****************************************************************************/
    82 
    82 
    83 /** Get an Sdo entry from an Sdo via its subindex.
    83 /** Get an SDO entry from an SDO via its subindex.
    84  * 
    84  * 
    85  * \retval >0 Pointer to the requested Sdo entry.
    85  * \retval >0 Pointer to the requested SDO entry.
    86  * \retval NULL Sdo entry not found.
    86  * \retval NULL SDO entry not found.
    87  */
    87  */
    88 ec_sdo_entry_t *ec_sdo_get_entry(
    88 ec_sdo_entry_t *ec_sdo_get_entry(
    89         ec_sdo_t *sdo, /**< Sdo. */
    89         ec_sdo_t *sdo, /**< SDO. */
    90         uint8_t subindex /**< Entry subindex. */
    90         uint8_t subindex /**< Entry subindex. */
    91         )
    91         )
    92 {
    92 {
    93     ec_sdo_entry_t *entry;
    93     ec_sdo_entry_t *entry;
    94 
    94 
   101     return NULL;
   101     return NULL;
   102 }
   102 }
   103 
   103 
   104 /*****************************************************************************/
   104 /*****************************************************************************/
   105 
   105 
   106 /** Get an Sdo entry from an Sdo via its subindex.
   106 /** Get an SDO entry from an SDO via its subindex.
   107  *
   107  *
   108  * const version.
   108  * const version.
   109  * 
   109  * 
   110  * \retval >0 Pointer to the requested Sdo entry.
   110  * \retval >0 Pointer to the requested SDO entry.
   111  * \retval NULL Sdo entry not found.
   111  * \retval NULL SDO entry not found.
   112  */
   112  */
   113 const ec_sdo_entry_t *ec_sdo_get_entry_const(
   113 const ec_sdo_entry_t *ec_sdo_get_entry_const(
   114         const ec_sdo_t *sdo, /**< Sdo. */
   114         const ec_sdo_t *sdo, /**< SDO. */
   115         uint8_t subindex /**< Entry subindex. */
   115         uint8_t subindex /**< Entry subindex. */
   116         )
   116         )
   117 {
   117 {
   118     const ec_sdo_entry_t *entry;
   118     const ec_sdo_entry_t *entry;
   119 
   119