X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/8b8d26b693cd343024ab0853ab8a506bca3863a9..7eca1ac39aa9f2a65ba0607d55f7155f5a56ad15:/lincan/src/hms30c7202_can.c diff --git a/lincan/src/hms30c7202_can.c b/lincan/src/hms30c7202_can.c index df21d2d..1a18904 100644 --- a/lincan/src/hms30c7202_can.c +++ b/lincan/src/hms30c7202_can.c @@ -301,7 +301,7 @@ int hms30c7202_init_chip_data(struct candevice_t *candev, int chipnr) candev->chip[chipnr]->chip_base_addr=candev->io_addr; - candev->chip[chipnr]->clock = 16000000; + candev->chip[chipnr]->clock = 16000000/2; /*candev->chip[chipnr]->int_clk_reg = 0x0; candev->chip[chipnr]->int_bus_reg = 0x0; @@ -345,8 +345,9 @@ int hms30c7202_init_obj_data(struct canchip_t *chip, int objnr) * @address: memory address to write to * * The function hms30c7202_write_register() is used to write to hardware registers - * on the CAN chip. You should only have to edit this function if your hardware - * uses some specific write process. + * on the CAN chip. The registers are mapped on 32 bit bus on hms30c7202 + * and thus registers span is twice as one defined by C_CAN manual and defines. + * This function compensates this difference. * Return Value: The function does not return a value * File: src/template.c */ @@ -355,6 +356,9 @@ void hms30c7202_write_register(unsigned data, unsigned long address) { int i; //unsigned long usecs = 1; + + address = ((address & C_CAN_REGOFFS_MASK) << 1) | + (address & ~C_CAN_REGOFFS_MASK); //DEBUGMSG("Trying to write 0x%u16x to address 0x%lx\n",data,address); @@ -368,8 +372,9 @@ void hms30c7202_write_register(unsigned data, unsigned long address) * @address: memory address to read from * * The function hms30c7202_read_register() is used to read from hardware registers - * on the CAN chip. You should only have to edit this function if your hardware - * uses some specific read process. + * on the CAN chip. The registers are mapped on 32 bit bus on hms30c7202 + * and thus registers span is twice as one defined by C_CAN manual and defines. + * This function compensates this difference. * Return Value: The function returns the value stored in @address * File: src/template.c */ @@ -377,6 +382,9 @@ unsigned hms30c7202_read_register(unsigned long address) { u16 value, i; + address = ((address & C_CAN_REGOFFS_MASK) << 1) | + (address & ~C_CAN_REGOFFS_MASK); + //DEBUGMSG("Trying to read from address 0x%lx :",address); value = readw(address);