Rev 1711 | Go to most recent revision | Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1703 | arune | 1 | |
| 2 | #include "act_pcaPWM.h" |
||
| 3 | #include "drivers/io/PCA9634.h" |
||
| 4 | |||
| 5 | #ifdef act_pcaPWM_USEEEPROM |
||
| 6 | #include "act_pcaPWM_eeprom.h" |
||
| 7 | struct eeprom_act_pcaPWM EEMEM eeprom_act_pcaPWM = |
||
| 8 | { |
||
| 9 | { |
||
| 10 | ///TODO: Define initialization values on the EEPROM variables here, this will generate a *.eep file that can be used to store this values to the node, can in future be done with a EEPROM module and the make-scrips. Write the values in the exact same order as the struct is defined in the *.h file. |
||
| 11 | 0xAB, // x |
||
| 12 | 0x1234 // y |
||
| 13 | 0x12345678 // z |
||
| 14 | }, |
||
| 15 | |||
| 16 | }; |
||
| 17 | #endif |
||
| 18 | |||
| 19 | void act_pcaPWM_Init(void) |
||
| 20 | { |
||
| 21 | #ifdef act_pcaPWM_USEEEPROM |
||
| 22 | if (EEDATA_OK) |
||
| 23 | { |
||
| 24 | ///TODO: Use stored data to set initial values for the module |
||
| 25 | blablaX = eeprom_read_byte(EEDATA.x); |
||
| 26 | blablaY = eeprom_read_word(EEDATA16.y); |
||
| 27 | blablaZ = eeprom_read_dword(EEDATA32.y); |
||
| 28 | } else |
||
| 29 | { //The CRC of the EEPROM is not correct, store default values and update CRC |
||
| 30 | eeprom_write_byte_crc(EEDATA.x, 0xAB, WITHOUT_CRC); |
||
| 31 | eeprom_write_word_crc(EEDATA16.y, 0x1234, WITHOUT_CRC); |
||
| 32 | eeprom_write_dword_crc(EEDATA32.y, 0x12345678, WITHOUT_CRC); |
||
| 33 | EEDATA_UPDATE_CRC; |
||
| 34 | } |
||
| 35 | #endif |
||
| 36 | ///TODO: Initialize hardware etc here |
||
| 37 | |||
| 38 | // to use PCINt lib, call this function: (the callback function look as a timer callback function) |
||
| 39 | // Pcint_SetCallbackPin(act_pcaPWM_PCINT, EXP_C , &act_pcaPWM_pcint_callback); |
||
| 40 | |||
| 41 | } |
||
| 42 | |||
| 43 | void act_pcaPWM_Process(void) |
||
| 44 | { |
||
| 45 | ///TODO: Stuff that needs doing is done here |
||
| 46 | } |
||
| 47 | |||
| 48 | void act_pcaPWM_HandleMessage(StdCan_Msg_t *rxMsg) |
||
| 49 | { |
||
| 50 | #if 0 |
||
| 51 | if ( StdCan_Ret_class(rxMsg->Header) == CAN_MODULE_CLASS_xyz && ///TODO: Change this to the actual class type |
||
| 52 | StdCan_Ret_direction(rxMsg->Header) == DIRECTIONFLAG_FROM_OWNER && |
||
| 53 | rxMsg->Header.ModuleType == CAN_MODULE_TYPE_xyz && ///TODO: Change this to the actual module type |
||
| 54 | rxMsg->Header.ModuleId == act_pcaPWM_ID) |
||
| 55 | { |
||
| 56 | switch (rxMsg->Header.Command) |
||
| 57 | { |
||
| 58 | case CAN_CMD_MODULE_DUMMY: |
||
| 59 | ///TODO: Do something dummy |
||
| 60 | break; |
||
| 61 | } |
||
| 62 | } |
||
| 63 | #endif |
||
| 64 | } |
||
| 65 | |||
| 66 | void act_pcaPWM_List(uint8_t ModuleSequenceNumber) |
||
| 67 | { |
||
| 68 | #if 0 |
||
| 69 | StdCan_Msg_t txMsg; |
||
| 70 | |||
| 71 | StdCan_Set_class(txMsg.Header, CAN_MODULE_CLASS_xyz); ///TODO: Change this to the actual class type |
||
| 72 | StdCan_Set_direction(txMsg.Header, DIRECTIONFLAG_FROM_OWNER); |
||
| 73 | txMsg.Header.ModuleType = CAN_MODULE_TYPE_xyz; ///TODO: Change this to the actual module type |
||
| 74 | txMsg.Header.ModuleId = act_pcaPWM_ID; |
||
| 75 | txMsg.Header.Command = CAN_MODULE_CMD_GLOBAL_LIST; |
||
| 76 | txMsg.Length = 6; |
||
| 77 | |||
| 78 | txMsg.Data[0] = NODE_HW_ID_BYTE0; |
||
| 79 | txMsg.Data[1] = NODE_HW_ID_BYTE1; |
||
| 80 | txMsg.Data[2] = NODE_HW_ID_BYTE2; |
||
| 81 | txMsg.Data[3] = NODE_HW_ID_BYTE3; |
||
| 82 | |||
| 83 | txMsg.Data[4] = NUMBER_OF_MODULES; |
||
| 84 | txMsg.Data[5] = ModuleSequenceNumber; |
||
| 85 | |||
| 86 | while (StdCan_Put(&txMsg) != StdCan_Ret_OK); |
||
| 87 | #endif |
||
| 88 | } |