37 #ifndef MCAL_P33SMPS_OSCILLATOR_H 38 #define MCAL_P33SMPS_OSCILLATOR_H 44 #include "p33smps_devices.h" 68 enum CPU_SPEED_DEFAULTS_e {
69 CPU_SPEED_20_MIPS = 20,
70 CPU_SPEED_30_MIPS = 30,
71 CPU_SPEED_40_MIPS = 40,
72 CPU_SPEED_50_MIPS = 50,
73 CPU_SPEED_60_MIPS = 60,
74 CPU_SPEED_70_MIPS = 70,
75 CPU_SPEED_80_MIPS = 80,
76 CPU_SPEED_90_MIPS = 90,
77 CPU_SPEED_100_MIPS = 100
79 typedef enum CPU_SPEED_DEFAULTS_e CPU_SPEED_DEFAULTS_t;
82 enum AUX_PLL_DEFAULTS_e {
92 typedef enum AUX_PLL_DEFAULTS_e AUX_PLL_DEFAULTS_t;
130 volatile uint32_t
fp;
141 #if defined (__P33SMPS_CH__) 143 #define FRCTUN_MIN -32 // minimum tuning value 144 #define FRCTUN_MAX 31 // maximum tuning value 145 #define OSC_FRC_FREQ 8000000 // Frequency of the internal oscillator in [Hz] 146 #define OSC_FRC_TUN 0 // <OSCTUN> FRC Oscillator Tuning Rregister default value 147 #define OSC_TUN_STEP_PERCENTAGE 0.00047 // Oscillator frequency step size of <OSCTUN> 149 #elif defined (__P33SMPS_CK__) 151 #define FRCTUN_MIN -32 // minimum tuning value 152 #define FRCTUN_MAX 31 // maximum tuning value 153 #define OSC_FRC_FREQ 8000000 // Frequency of the internal oscillator in [Hz] 154 #define OSC_FRC_TUN 0 // <OSCTUN> FRC Oscillator Tuning Rregister value 155 #define OSC_TUN_STEP_PERCENTAGE 0.00047 // Oscillator frequency step size of <OSCTUN> 158 #pragma message "error: === selected device family not supported by oscillator mcal driver library ===" 161 #define OSC_TUN_STEP_FREQUENCY (volatile int32_t)(OSC_FRC_FREQ * OSC_TUN_STEP_PERCENTAGE) 171 #define REG_OSCCON_VALID_DATA_WRITE_MASK 0x0789 172 #define REG_OSCCON_VALID_DATA_READ_MASK 0x77A9 174 #define REG_OSCCON_OSWEN_REQUEST_SWITCH 0b0000000000001000 175 #define REG_OSCCON_OSWEN_SWITCH_COMPLETE 0b0000000000000000 177 enum OSCCON_OSWEN_e {
178 OSCCON_OSWEN_REQUEST_SWITCH = 0b1,
179 OSCCON_OSWEN_SWITCH_COMPLETE = 0b0
181 typedef enum OSCCON_OSWEN_e OSCCON_OSWEN_t;
183 #define REG_OSCCON_CF_CLKSTAT_FAIL 0b0000000000001000 184 #define REG_OSCCON_CF_CLKSTAT_OK 0b0000000000000000 187 OSCCON_CF_CLKSTAT_FAIL = 0b1,
188 OSCCON_CF_CLKSTAT_OK = 0b0
190 typedef enum OSCCON_CF_e OSCCON_CF_t;
192 #define REG_OSCCON_LOCK_PLL_LOCKED 0b0000000000100000 193 #define REG_OSCCON_LOCK_PLL_UNLOCKED 0b0000000000000000 196 OSCCON_LOCK_PLL_LOCKED = 0b1,
197 OSCCON_LOCK_PLL_UNLOCKED = 0b0
199 typedef enum OSCCON_LOCK_e OSCCON_LOCK_t;
201 #define REG_OSCCON_CLKLOCK_LOCKED 0b0000000010000000 202 #define REG_OSCCON_CLKLOCK_UNLOCKED 0b0000000000000000 204 enum OSCCON_CLKLOCK_e{
205 OSCCON_CLKLOCK_LOCKED = 0b1,
206 OSCCON_CLKLOCK_UNLOCKED = 0b0
208 typedef enum OSCCON_CLKLOCK_e OSCCON_CLKLOCK_t;
210 #define REG_OSCCON_NOSC_FRCDIVN 0b0000011100000000 211 #define REG_OSCCON_NOSC_BFRC 0b0000011000000000 212 #define REG_OSCCON_NOSC_LPRC 0b0000010100000000 213 #define REG_OSCCON_NOSC_PRIPLL 0b0000001100000000 214 #define REG_OSCCON_NOSC_PRI 0b0000001000000000 215 #define REG_OSCCON_NOSC_FRCPLL 0b0000000100000000 216 #define REG_OSCCON_NOSC_FRC 0b0000000000000000 218 #define REG_OSCCON_COSC_FRCDIVN 0b0111000000000000 219 #define REG_OSCCON_COSC_BFRC 0b0110000000000000 220 #define REG_OSCCON_COSC_LPRC 0b0101000000000000 221 #define REG_OSCCON_COSC_PRIPLL 0b0011000000000000 222 #define REG_OSCCON_COSC_PRI 0b0010000000000000 223 #define REG_OSCCON_COSC_FRCPLL 0b0001000000000000 224 #define REG_OSCCON_COSC_FRC 0b0000000000000000 227 enum OSCCON_xOSC_TYPE_e {
228 OSCCON_xOSC_FRC = 0b000,
229 OSCCON_xOSC_FRCPLL = 0b001,
230 OSCCON_xOSC_PRI = 0b010,
231 OSCCON_xOSC_PRIPLL = 0b011,
232 OSCCON_xOSC_LPRC = 0b101,
233 OSCCON_xOSC_BFRC = 0b110,
234 OSCCON_xOSC_FRCDIVN = 0b111
236 typedef enum OSCCON_xOSC_TYPE_e OSCCON_xOSC_TYPE_t;
241 volatile enum OSCCON_OSWEN_e
OSWEN : 1;
244 volatile enum OSCCON_CF_e
CF : 1;
246 volatile enum OSCCON_LOCK_e
LOCK : 1;
249 volatile enum OSCCON_xOSC_TYPE_e
NOSC : 3;
251 volatile enum OSCCON_xOSC_TYPE_e
COSC : 3;
253 } __attribute__((packed)) bits;
264 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__) 266 #define REG_CLKDIV_VALID_DATA_WRITE_MASK 0xFF0F 267 #define REG_CLKDIV_VALID_DATA_READ_MASK 0xFF0F 269 #define REG_CLKDIV_PLLPRE_DIV_MASK 0b0000000000001111 270 #define REG_CLKDIV_PLLPRE_DIVIDER_N1(x) {(x & REG_CLKDIV_PLLPRE_DIV_MASK)} 272 enum CLKDIV_PLLPRE_e {
273 CLKDIV_PLLDIV_N1_1 = 0b000001,
274 CLKDIV_PLLDIV_N1_2 = 0b000010,
275 CLKDIV_PLLDIV_N1_3 = 0b000011,
276 CLKDIV_PLLDIV_N1_4 = 0b000100,
277 CLKDIV_PLLDIV_N1_5 = 0b000101,
278 CLKDIV_PLLDIV_N1_6 = 0b000110,
279 CLKDIV_PLLDIV_N1_7 = 0b000111,
280 CLKDIV_PLLDIV_N1_8 = 0b001000
282 typedef enum CLKDIV_PLLPRE_e CLKDIV_PLLPRE_t;
285 #pragma message "error: === selected device family is not supported by oscillator mcal library ===" 288 #define REG_CLKDIV_DOZE_DIV_1 0b0000000000000000 289 #define REG_CLKDIV_DOZE_DIV_2 0b0001000000000000 290 #define REG_CLKDIV_DOZE_DIV_4 0b0010000000000000 291 #define REG_CLKDIV_DOZE_DIV_8 0b0011000000000000 292 #define REG_CLKDIV_DOZE_DIV_16 0b0100000000000000 293 #define REG_CLKDIV_DOZE_DIV_32 0b0101000000000000 294 #define REG_CLKDIV_DOZE_DIV_64 0b0110000000000000 295 #define REG_CLKDIV_DOZE_DIV_128 0b0111000000000000 298 CLKDIV_DOZE_DIV_1 = 0b000,
299 CLKDIV_DOZE_DIV_2 = 0b001,
300 CLKDIV_DOZE_DIV_4 = 0b010,
301 CLKDIV_DOZE_DIV_8 = 0b011,
302 CLKDIV_DOZE_DIV_16 = 0b100,
303 CLKDIV_DOZE_DIV_32 = 0b101,
304 CLKDIV_DOZE_DIV_64 = 0b110,
305 CLKDIV_DOZE_DIV_128 = 0b111
307 typedef enum CLKDIV_DOZE_e CLKDIV_DOZE_t;
309 #define REG_CLKDIV_DOZEN_ENABLED 0b0000100000000000 310 #define REG_CLKDIV_DOZEN_DISABLED 0b0000000000000000 312 enum CLKDIV_DOZEN_e {
313 CLKDIV_DOZEN_ENABLED = 0b1,
314 CLKDIV_DOZEN_DISABLED = 0b0
316 typedef enum CLKDIV_DOZEN_e CLKDIV_DOZEN_t;
318 #define REG_CLKDIV_FRCDIVN_256 0b0000011100000000 319 #define REG_CLKDIV_FRCDIVN_64 0b0000011000000000 320 #define REG_CLKDIV_FRCDIVN_32 0b0000010100000000 321 #define REG_CLKDIV_FRCDIVN_16 0b0000010000000000 322 #define REG_CLKDIV_FRCDIVN_8 0b0000001100000000 323 #define REG_CLKDIV_FRCDIVN_4 0b0000001000000000 324 #define REG_CLKDIV_FRCDIVN_2 0b0000000100000000 325 #define REG_CLKDIV_FRCDIVN_1 0b0000000000000000 327 enum CLKDIV_FRCDIVN_e {
328 CLKDIV_FRCDIVN_1 = 0b000,
329 CLKDIV_FRCDIVN_2 = 0b001,
330 CLKDIV_FRCDIVN_4 = 0b010,
331 CLKDIV_FRCDIVN_8 = 0b011,
332 CLKDIV_FRCDIVN_16 = 0b100,
333 CLKDIV_FRCDIVN_32 = 0b101,
334 CLKDIV_FRCDIVN_64 = 0b110,
335 CLKDIV_FRCDIVN_256 = 0b111
337 typedef enum CLKDIV_FRCDIVN_e CLKDIV_FRCDIVN_t;
339 #define REG_CLKDIV_ROI_ENABLED 0b1000000000000000 340 #define REG_CLKDIV_ROI_DISABLED 0b0000000000000000 343 CLKDIV_ROI_ENABLED = 0b1,
344 CLKDIV_ROI_DISABLED = 0b0
346 typedef enum CLKDIV_ROI_e CLKDIV_ROI_t;
351 volatile enum CLKDIV_PLLPRE_e
PLLPRE : 4;
353 volatile enum CLKDIV_FRCDIVN_e
FRCDIV : 3;
354 volatile enum CLKDIV_DOZEN_e
DOZEN : 1;
355 volatile enum CLKDIV_DOZE_e
DOZE : 3;
356 volatile enum CLKDIV_ROI_e
ROI : 1;
357 } __attribute__((packed)) bits;
368 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__) 370 #define REG_PLLFBD_VALID_DATA_WRITE_MASK 0x00FF 371 #define REG_PLLFBD_VALID_DATA_READ_MASK 0x00FF 373 #define REG_PLLFBD_PLLFBDIV_M_MASK 0b0000000011111111 374 #define REG_PLLFBD_MULTIPLIER_M(x) {(x & REG_PLLFBD_PLLFBDIV_M_MASK)} 376 enum PLLFBD_PLLFBDIV_e {
377 PLLFBD_PLLFBDIV_M_16 = 0b00010000,
378 PLLFBD_PLLFBDIV_M_17 = 0b00010001,
379 PLLFBD_PLLFBDIV_M_18 = 0b00010010,
380 PLLFBD_PLLFBDIV_M_19 = 0b00010011,
381 PLLFBD_PLLFBDIV_M_20 = 0b00010100,
382 PLLFBD_PLLFBDIV_M_21 = 0b00010101,
383 PLLFBD_PLLFBDIV_M_22 = 0b00010110,
384 PLLFBD_PLLFBDIV_M_23 = 0b00010111,
385 PLLFBD_PLLFBDIV_M_24 = 0b00011000,
386 PLLFBD_PLLFBDIV_M_25 = 0b00011001,
387 PLLFBD_PLLFBDIV_M_26 = 0b00011010,
388 PLLFBD_PLLFBDIV_M_27 = 0b00011011,
389 PLLFBD_PLLFBDIV_M_28 = 0b00011100,
390 PLLFBD_PLLFBDIV_M_29 = 0b00011101,
391 PLLFBD_PLLFBDIV_M_30 = 0b00011110,
392 PLLFBD_PLLFBDIV_M_31 = 0b00011111,
393 PLLFBD_PLLFBDIV_M_32 = 0b00100000,
394 PLLFBD_PLLFBDIV_M_33 = 0b00100001,
395 PLLFBD_PLLFBDIV_M_34 = 0b00100010,
396 PLLFBD_PLLFBDIV_M_35 = 0b00100011,
397 PLLFBD_PLLFBDIV_M_36 = 0b00100100,
398 PLLFBD_PLLFBDIV_M_37 = 0b00100101,
399 PLLFBD_PLLFBDIV_M_38 = 0b00100110,
400 PLLFBD_PLLFBDIV_M_39 = 0b00100111,
401 PLLFBD_PLLFBDIV_M_40 = 0b00101000,
402 PLLFBD_PLLFBDIV_M_41 = 0b00101001,
403 PLLFBD_PLLFBDIV_M_42 = 0b00101010,
404 PLLFBD_PLLFBDIV_M_43 = 0b00101011,
405 PLLFBD_PLLFBDIV_M_44 = 0b00101100,
406 PLLFBD_PLLFBDIV_M_45 = 0b00101101,
407 PLLFBD_PLLFBDIV_M_46 = 0b00101110,
408 PLLFBD_PLLFBDIV_M_47 = 0b00101111,
409 PLLFBD_PLLFBDIV_M_48 = 0b00110000,
410 PLLFBD_PLLFBDIV_M_49 = 0b00110001,
411 PLLFBD_PLLFBDIV_M_50 = 0b00110010,
412 PLLFBD_PLLFBDIV_M_51 = 0b00110011,
413 PLLFBD_PLLFBDIV_M_52 = 0b00110100,
414 PLLFBD_PLLFBDIV_M_53 = 0b00110101,
415 PLLFBD_PLLFBDIV_M_54 = 0b00110110,
416 PLLFBD_PLLFBDIV_M_55 = 0b00110111,
417 PLLFBD_PLLFBDIV_M_56 = 0b00111000,
418 PLLFBD_PLLFBDIV_M_57 = 0b00111001,
419 PLLFBD_PLLFBDIV_M_58 = 0b00111010,
420 PLLFBD_PLLFBDIV_M_59 = 0b00111011,
421 PLLFBD_PLLFBDIV_M_60 = 0b00111100,
422 PLLFBD_PLLFBDIV_M_61 = 0b00111101,
423 PLLFBD_PLLFBDIV_M_62 = 0b00111110,
424 PLLFBD_PLLFBDIV_M_63 = 0b00111111,
425 PLLFBD_PLLFBDIV_M_64 = 0b01000000,
426 PLLFBD_PLLFBDIV_M_65 = 0b01000001,
427 PLLFBD_PLLFBDIV_M_66 = 0b01000010,
428 PLLFBD_PLLFBDIV_M_67 = 0b01000011,
429 PLLFBD_PLLFBDIV_M_68 = 0b01000100,
430 PLLFBD_PLLFBDIV_M_69 = 0b01000101,
431 PLLFBD_PLLFBDIV_M_70 = 0b01000110,
432 PLLFBD_PLLFBDIV_M_71 = 0b01000111,
433 PLLFBD_PLLFBDIV_M_72 = 0b01001000,
434 PLLFBD_PLLFBDIV_M_73 = 0b01001001,
435 PLLFBD_PLLFBDIV_M_74 = 0b01001010,
436 PLLFBD_PLLFBDIV_M_75 = 0b01001011,
437 PLLFBD_PLLFBDIV_M_76 = 0b01001100,
438 PLLFBD_PLLFBDIV_M_77 = 0b01001101,
439 PLLFBD_PLLFBDIV_M_78 = 0b01001110,
440 PLLFBD_PLLFBDIV_M_79 = 0b01001111,
441 PLLFBD_PLLFBDIV_M_80 = 0b01010000,
442 PLLFBD_PLLFBDIV_M_81 = 0b01010001,
443 PLLFBD_PLLFBDIV_M_82 = 0b01010010,
444 PLLFBD_PLLFBDIV_M_83 = 0b01010011,
445 PLLFBD_PLLFBDIV_M_84 = 0b01010100,
446 PLLFBD_PLLFBDIV_M_85 = 0b01010101,
447 PLLFBD_PLLFBDIV_M_86 = 0b01010110,
448 PLLFBD_PLLFBDIV_M_87 = 0b01010111,
449 PLLFBD_PLLFBDIV_M_88 = 0b01011000,
450 PLLFBD_PLLFBDIV_M_89 = 0b01011001,
451 PLLFBD_PLLFBDIV_M_90 = 0b01011010,
452 PLLFBD_PLLFBDIV_M_91 = 0b01011011,
453 PLLFBD_PLLFBDIV_M_92 = 0b01011100,
454 PLLFBD_PLLFBDIV_M_93 = 0b01011101,
455 PLLFBD_PLLFBDIV_M_94 = 0b01011110,
456 PLLFBD_PLLFBDIV_M_95 = 0b01011111,
457 PLLFBD_PLLFBDIV_M_96 = 0b01100000,
458 PLLFBD_PLLFBDIV_M_97 = 0b01100001,
459 PLLFBD_PLLFBDIV_M_98 = 0b01100010,
460 PLLFBD_PLLFBDIV_M_99 = 0b01100011,
461 PLLFBD_PLLFBDIV_M_100 = 0b01100100,
462 PLLFBD_PLLFBDIV_M_101 = 0b01100101,
463 PLLFBD_PLLFBDIV_M_102 = 0b01100110,
464 PLLFBD_PLLFBDIV_M_103 = 0b01100111,
465 PLLFBD_PLLFBDIV_M_104 = 0b01101000,
466 PLLFBD_PLLFBDIV_M_105 = 0b01101001,
467 PLLFBD_PLLFBDIV_M_106 = 0b01101010,
468 PLLFBD_PLLFBDIV_M_107 = 0b01101011,
469 PLLFBD_PLLFBDIV_M_108 = 0b01101100,
470 PLLFBD_PLLFBDIV_M_109 = 0b01101101,
471 PLLFBD_PLLFBDIV_M_110 = 0b01101110,
472 PLLFBD_PLLFBDIV_M_111 = 0b01101111,
473 PLLFBD_PLLFBDIV_M_112 = 0b01110000,
474 PLLFBD_PLLFBDIV_M_113 = 0b01110001,
475 PLLFBD_PLLFBDIV_M_114 = 0b01110010,
476 PLLFBD_PLLFBDIV_M_115 = 0b01110011,
477 PLLFBD_PLLFBDIV_M_116 = 0b01110100,
478 PLLFBD_PLLFBDIV_M_117 = 0b01110101,
479 PLLFBD_PLLFBDIV_M_118 = 0b01110110,
480 PLLFBD_PLLFBDIV_M_119 = 0b01110111,
481 PLLFBD_PLLFBDIV_M_120 = 0b01111000,
482 PLLFBD_PLLFBDIV_M_121 = 0b01111001,
483 PLLFBD_PLLFBDIV_M_122 = 0b01111010,
484 PLLFBD_PLLFBDIV_M_123 = 0b01111011,
485 PLLFBD_PLLFBDIV_M_124 = 0b01111100,
486 PLLFBD_PLLFBDIV_M_125 = 0b01111101,
487 PLLFBD_PLLFBDIV_M_126 = 0b01111110,
488 PLLFBD_PLLFBDIV_M_127 = 0b01111111,
489 PLLFBD_PLLFBDIV_M_128 = 0b10000000,
490 PLLFBD_PLLFBDIV_M_129 = 0b10000001,
491 PLLFBD_PLLFBDIV_M_130 = 0b10000010,
492 PLLFBD_PLLFBDIV_M_131 = 0b10000011,
493 PLLFBD_PLLFBDIV_M_132 = 0b10000100,
494 PLLFBD_PLLFBDIV_M_133 = 0b10000101,
495 PLLFBD_PLLFBDIV_M_134 = 0b10000110,
496 PLLFBD_PLLFBDIV_M_135 = 0b10000111,
497 PLLFBD_PLLFBDIV_M_136 = 0b10001000,
498 PLLFBD_PLLFBDIV_M_137 = 0b10001001,
499 PLLFBD_PLLFBDIV_M_138 = 0b10001010,
500 PLLFBD_PLLFBDIV_M_139 = 0b10001011,
501 PLLFBD_PLLFBDIV_M_140 = 0b10001100,
502 PLLFBD_PLLFBDIV_M_141 = 0b10001101,
503 PLLFBD_PLLFBDIV_M_142 = 0b10001110,
504 PLLFBD_PLLFBDIV_M_143 = 0b10001111,
505 PLLFBD_PLLFBDIV_M_144 = 0b10010000,
506 PLLFBD_PLLFBDIV_M_145 = 0b10010001,
507 PLLFBD_PLLFBDIV_M_146 = 0b10010010,
508 PLLFBD_PLLFBDIV_M_147 = 0b10010011,
509 PLLFBD_PLLFBDIV_M_148 = 0b10010100,
510 PLLFBD_PLLFBDIV_M_149 = 0b10010101,
511 PLLFBD_PLLFBDIV_M_150 = 0b10010110,
512 PLLFBD_PLLFBDIV_M_151 = 0b10010111,
513 PLLFBD_PLLFBDIV_M_152 = 0b10011000,
514 PLLFBD_PLLFBDIV_M_153 = 0b10011001,
515 PLLFBD_PLLFBDIV_M_154 = 0b10011010,
516 PLLFBD_PLLFBDIV_M_155 = 0b10011011,
517 PLLFBD_PLLFBDIV_M_156 = 0b10011100,
518 PLLFBD_PLLFBDIV_M_157 = 0b10011101,
519 PLLFBD_PLLFBDIV_M_158 = 0b10011110,
520 PLLFBD_PLLFBDIV_M_159 = 0b10011111,
521 PLLFBD_PLLFBDIV_M_160 = 0b10100000,
522 PLLFBD_PLLFBDIV_M_161 = 0b10100001,
523 PLLFBD_PLLFBDIV_M_162 = 0b10100010,
524 PLLFBD_PLLFBDIV_M_163 = 0b10100011,
525 PLLFBD_PLLFBDIV_M_164 = 0b10100100,
526 PLLFBD_PLLFBDIV_M_165 = 0b10100101,
527 PLLFBD_PLLFBDIV_M_166 = 0b10100110,
528 PLLFBD_PLLFBDIV_M_167 = 0b10100111,
529 PLLFBD_PLLFBDIV_M_168 = 0b10101000,
530 PLLFBD_PLLFBDIV_M_169 = 0b10101001,
531 PLLFBD_PLLFBDIV_M_170 = 0b10101010,
532 PLLFBD_PLLFBDIV_M_171 = 0b10101011,
533 PLLFBD_PLLFBDIV_M_172 = 0b10101100,
534 PLLFBD_PLLFBDIV_M_173 = 0b10101101,
535 PLLFBD_PLLFBDIV_M_174 = 0b10101110,
536 PLLFBD_PLLFBDIV_M_175 = 0b10101111,
537 PLLFBD_PLLFBDIV_M_176 = 0b10110000,
538 PLLFBD_PLLFBDIV_M_177 = 0b10110001,
539 PLLFBD_PLLFBDIV_M_178 = 0b10110010,
540 PLLFBD_PLLFBDIV_M_179 = 0b10110011,
541 PLLFBD_PLLFBDIV_M_180 = 0b10110100,
542 PLLFBD_PLLFBDIV_M_181 = 0b10110101,
543 PLLFBD_PLLFBDIV_M_182 = 0b10110110,
544 PLLFBD_PLLFBDIV_M_183 = 0b10110111,
545 PLLFBD_PLLFBDIV_M_184 = 0b10111000,
546 PLLFBD_PLLFBDIV_M_185 = 0b10111001,
547 PLLFBD_PLLFBDIV_M_186 = 0b10111010,
548 PLLFBD_PLLFBDIV_M_187 = 0b10111011,
549 PLLFBD_PLLFBDIV_M_188 = 0b10111100,
550 PLLFBD_PLLFBDIV_M_189 = 0b10111101,
551 PLLFBD_PLLFBDIV_M_190 = 0b10111110,
552 PLLFBD_PLLFBDIV_M_191 = 0b10111111,
553 PLLFBD_PLLFBDIV_M_192 = 0b11000000,
554 PLLFBD_PLLFBDIV_M_193 = 0b11000001,
555 PLLFBD_PLLFBDIV_M_194 = 0b11000010,
556 PLLFBD_PLLFBDIV_M_195 = 0b11000011,
557 PLLFBD_PLLFBDIV_M_196 = 0b11000100,
558 PLLFBD_PLLFBDIV_M_197 = 0b11000101,
559 PLLFBD_PLLFBDIV_M_198 = 0b11000110,
560 PLLFBD_PLLFBDIV_M_199 = 0b11000111,
561 PLLFBD_PLLFBDIV_M_200 = 0b11001000
563 typedef enum PLLFBD_PLLFBDIV_e PLLFBD_PLLFBDIV_t;
568 volatile enum PLLFBD_PLLFBDIV_e PLLFBDIV : 8;
569 volatile unsigned : 8;
570 } __attribute__((packed)) bits;
571 volatile uint16_t value;
574 typedef struct PLLFBD_s PLLFBD_t;
577 #pragma message "error: === selected device family is not supported by oscillator mcal library ===" 585 #define REG_OSCTUN_VALID_DATA_WRITE_MASK 0x003F 586 #define REG_OSCTUN_VALID_DATA_READ_MASK 0x003F 588 #define REG_OSCTUN_TUNE_VALUE_MASK 0b0000000000111111 589 #define REG_OSCTUN_TUNE_VALUE(x) {(x & REG_OSCTUN_TUNE_VALUE_MASK)} 591 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__) 594 OSCTUN_TUN_MINUS_31 = 0b100001,
595 OSCTUN_TUN_MINUS_30 = 0b100010,
596 OSCTUN_TUN_MINUS_29 = 0b100011,
597 OSCTUN_TUN_MINUS_28 = 0b100100,
598 OSCTUN_TUN_MINUS_27 = 0b100101,
599 OSCTUN_TUN_MINUS_26 = 0b100110,
600 OSCTUN_TUN_MINUS_25 = 0b100111,
601 OSCTUN_TUN_MINUS_24 = 0b101000,
602 OSCTUN_TUN_MINUS_23 = 0b101001,
603 OSCTUN_TUN_MINUS_22 = 0b101010,
604 OSCTUN_TUN_MINUS_21 = 0b101011,
605 OSCTUN_TUN_MINUS_20 = 0b101100,
606 OSCTUN_TUN_MINUS_19 = 0b101101,
607 OSCTUN_TUN_MINUS_18 = 0b101110,
608 OSCTUN_TUN_MINUS_17 = 0b101111,
609 OSCTUN_TUN_MINUS_16 = 0b110000,
610 OSCTUN_TUN_MINUS_15 = 0b110001,
611 OSCTUN_TUN_MINUS_14 = 0b110010,
612 OSCTUN_TUN_MINUS_13 = 0b110011,
613 OSCTUN_TUN_MINUS_12 = 0b110100,
614 OSCTUN_TUN_MINUS_11 = 0b110101,
615 OSCTUN_TUN_MINUS_10 = 0b110110,
616 OSCTUN_TUN_MINUS_9 = 0b110111,
617 OSCTUN_TUN_MINUS_8 = 0b111000,
618 OSCTUN_TUN_MINUS_7 = 0b111001,
619 OSCTUN_TUN_MINUS_6 = 0b111010,
620 OSCTUN_TUN_MINUS_5 = 0b111011,
621 OSCTUN_TUN_MINUS_4 = 0b111100,
622 OSCTUN_TUN_MINUS_3 = 0b111101,
623 OSCTUN_TUN_MINUS_2 = 0b111110,
624 OSCTUN_TUN_MINUS_1 = 0b111111,
625 OSCTUN_TUN_NOMINAL = 0b000000,
626 OSCTUN_TUN_PLUS_1 = 0b000001,
627 OSCTUN_TUN_PLUS_2 = 0b000010,
628 OSCTUN_TUN_PLUS_3 = 0b000011,
629 OSCTUN_TUN_PLUS_4 = 0b000100,
630 OSCTUN_TUN_PLUS_5 = 0b000101,
631 OSCTUN_TUN_PLUS_6 = 0b000110,
632 OSCTUN_TUN_PLUS_7 = 0b000111,
633 OSCTUN_TUN_PLUS_8 = 0b001000,
634 OSCTUN_TUN_PLUS_9 = 0b001001,
635 OSCTUN_TUN_PLUS_10 = 0b001010,
636 OSCTUN_TUN_PLUS_11 = 0b001011,
637 OSCTUN_TUN_PLUS_12 = 0b001100,
638 OSCTUN_TUN_PLUS_13 = 0b001101,
639 OSCTUN_TUN_PLUS_14 = 0b001110,
640 OSCTUN_TUN_PLUS_15 = 0b001111,
641 OSCTUN_TUN_PLUS_16 = 0b010000,
642 OSCTUN_TUN_PLUS_17 = 0b010001,
643 OSCTUN_TUN_PLUS_18 = 0b010010,
644 OSCTUN_TUN_PLUS_19 = 0b010011,
645 OSCTUN_TUN_PLUS_20 = 0b010100,
646 OSCTUN_TUN_PLUS_21 = 0b010101,
647 OSCTUN_TUN_PLUS_22 = 0b010110,
648 OSCTUN_TUN_PLUS_23 = 0b010111,
649 OSCTUN_TUN_PLUS_24 = 0b011000,
650 OSCTUN_TUN_PLUS_25 = 0b011001,
651 OSCTUN_TUN_PLUS_26 = 0b011010,
652 OSCTUN_TUN_PLUS_27 = 0b011011,
653 OSCTUN_TUN_PLUS_28 = 0b011100,
654 OSCTUN_TUN_PLUS_29 = 0b011101,
655 OSCTUN_TUN_PLUS_30 = 0b011110,
656 OSCTUN_TUN_PLUS_31 = 0b011111
658 typedef enum OSCTUN_TUN_e OSCTUN_TUN_t;
661 #pragma message "error: === selected device family is not supported by oscillator mcal library ===" 667 volatile enum OSCTUN_TUN_e
TUN : 6;
669 } __attribute__((packed)) bits;
679 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__) 681 #define REG_PLLDIV_VALID_DATA_WRITE_MASK 0x0377 682 #define REG_PLLDIV_VALID_DATA_READ_MASK 0x0377 684 #define REG_PLLDIV_POST1DIV_N2_MASK 0b0000000001110000 685 #define REG_PLLDIV_POST1DIV_N2(x) {((x << 4) & REG_PLLDIV_POST1DIV_N2_MASK)} 687 #define REG_PLLDIV_POST2DIV_N3_MASK 0b0000000000000111 688 #define REG_PLLDIV_POST2DIV_N3(x) {(x & REG_PLLDIV_POST1DIV_N3_MASK)} 690 enum PLLDIV_POSTxDIV_e {
691 PLLDIV_POST2DIV_N2N3_1 = 0b001,
692 PLLDIV_POST2DIV_N2N3_2 = 0b010,
693 PLLDIV_POST2DIV_N2N3_3 = 0b011,
694 PLLDIV_POST2DIV_N2N3_4 = 0b100,
695 PLLDIV_POST2DIV_N2N3_5 = 0b101,
696 PLLDIV_POST2DIV_N2N3_6 = 0b110,
697 PLLDIV_POST2DIV_N2N3_7 = 0b111
699 typedef enum PLLDIV_POSTxDIV_e PLLDIV_POSTxDIV_t;
701 #define REG_PLLDIV_VCODIV_FVCO_DIV_BY_1 0b0000001100000000 702 #define REG_PLLDIV_VCODIV_FVCO_DIV_BY_2 0b0000001000000000 703 #define REG_PLLDIV_VCODIV_FVCO_DIV_BY_3 0b0000000100000000 704 #define REG_PLLDIV_VCODIV_FVCO_DIV_BY_4 0b0000000000000000 706 enum PLLDIV_VCODIV_e{
707 PLLDIV_VCODIV_FVCO_DIV_BY_1 = 0b11,
708 PLLDIV_VCODIV_FVCO_DIV_BY_2 = 0b10,
709 PLLDIV_VCODIV_FVCO_DIV_BY_3 = 0b01,
710 PLLDIV_VCODIV_FVCO_DIV_BY_4 = 0b00
712 typedef enum PLLDIV_VCODIV_e PLLDIV_VCODIV_t;
717 volatile enum PLLDIV_POSTxDIV_e POST2DIV : 3;
718 volatile unsigned : 1;
719 volatile enum PLLDIV_POSTxDIV_e POST1DIV : 3;
720 volatile unsigned : 1;
721 volatile enum PLLDIV_VCODIV_e VCODIV : 2;
722 volatile unsigned : 6;
723 } __attribute__((packed)) bits;
724 volatile uint16_t value;
727 typedef struct PLLDIV_s PLLDIV_t;
736 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__) 738 #define REG_ACLKCON_VALID_DATA_WRITE_MASK 0xC10F 739 #define REG_ACLKCON_VALID_DATA_READ_MASK 0xC10F 741 #define REG_ACLKCON_APLLPRE_DIV_MASK 0b0000000000001111 742 #define REG_ACLKCON_APLLPRE_DIVIDER_N1(x) {(x & REG_ACLKCON_APLLPRE_DIV_MASK)} 744 enum ACLKCON_APLLPRE_e {
745 ACLKCON_APLLDIV_N1_1 = 0b000001,
746 ACLKCON_APLLDIV_N1_2 = 0b000010,
747 ACLKCON_APLLDIV_N1_3 = 0b000011,
748 ACLKCON_APLLDIV_N1_4 = 0b000100,
749 ACLKCON_APLLDIV_N1_5 = 0b000101,
750 ACLKCON_APLLDIV_N1_6 = 0b000110,
751 ACLKCON_APLLDIV_N1_7 = 0b000111,
752 ACLKCON_APLLDIV_N1_8 = 0b001000
754 typedef enum ACLKCON_APLLPRE_e ACLKCON_APLLPRE_t;
756 #define REG_ACLKCON_FRCSEL_FRC 0b0000000100000000 757 #define REG_ACLKCON_FRCSEL_PRI 0b0000000000000000 759 enum ACLKCON_FRCSEL_e{
760 PLLDIV_ACLKCON_FRCSEL_FRC = 0b1,
761 PLLDIV_ACLKCON_FRCSEL_PRI = 0b0
763 typedef enum ACLKCON_FRCSEL_e ACLKCON_FRCSEL_t;
765 #define REG_ACLKCON_APLLCK_STAT_LOCKED 0b0100000000000000 766 #define REG_ACLKCON_APLLCK_STAT_UNLOCKED 0b0000000000000000 768 enum ACLKCON_APLLCK_e {
769 ACLKCON_APLLCK_STAT_LOCKED = 0b1,
770 ACLKCON_APLLCK_STAT_UNLOCKED = 0b0
772 typedef enum ACLKCON_APLLCK_e ACLKCON_APLLCK_t;
774 #define REG_ACLKCON_APLLEN_ENABLED 0b1000000000000000 775 #define REG_ACLKCON_APLLEN_DISABLED 0b0000000000000000 777 enum ACLKCON_APLLEN_e {
778 ACLKCON_APLLEN_ENABLED = 0b1,
779 ACLKCON_APLLEN_DISABLED = 0b0
781 typedef enum ACLKCON_APLLEN_e ACLKCON_APLLEN_t;
786 volatile enum ACLKCON_APLLPRE_e APLLPRE : 6;
787 volatile unsigned : 2;
788 volatile enum ACLKCON_FRCSEL_e FRCSEL : 1;
789 volatile unsigned : 5;
790 volatile enum ACLKCON_APLLCK_e APLLCK : 1;
791 volatile enum ACLKCON_APLLEN_e APLLEN : 1;
792 } __attribute__((packed)) bits;
793 volatile uint16_t value;
796 typedef struct ACLKCON_s ACLKCON_t;
799 #pragma message "error: === selected device family is not supported by oscillator mcal library ===" 806 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__) 808 #define REG_APLLFBD_VALID_DATA_WRITE_MASK 0x00FF 809 #define REG_APLLFBD_VALID_DATA_READ_MASK 0x00FF 811 #define REG_APLLFBD_APLLFBDIV_M_MASK 0b0000000011111111 812 #define REG_APLLFBD_MULTIPLIER_M(x) {(x & REG_APLLFBD_APLLFBDIV_M_MASK)} 814 enum APLLFBD_APLLFBDIV_e {
815 APLLFBD_APLLFBDIV_M_16 = 0b00010000,
816 APLLFBD_APLLFBDIV_M_17 = 0b00010001,
817 APLLFBD_APLLFBDIV_M_18 = 0b00010010,
818 APLLFBD_APLLFBDIV_M_19 = 0b00010011,
819 APLLFBD_APLLFBDIV_M_20 = 0b00010100,
820 APLLFBD_APLLFBDIV_M_21 = 0b00010101,
821 APLLFBD_APLLFBDIV_M_22 = 0b00010110,
822 APLLFBD_APLLFBDIV_M_23 = 0b00010111,
823 APLLFBD_APLLFBDIV_M_24 = 0b00011000,
824 APLLFBD_APLLFBDIV_M_25 = 0b00011001,
825 APLLFBD_APLLFBDIV_M_26 = 0b00011010,
826 APLLFBD_APLLFBDIV_M_27 = 0b00011011,
827 APLLFBD_APLLFBDIV_M_28 = 0b00011100,
828 APLLFBD_APLLFBDIV_M_29 = 0b00011101,
829 APLLFBD_APLLFBDIV_M_30 = 0b00011110,
830 APLLFBD_APLLFBDIV_M_31 = 0b00011111,
831 APLLFBD_APLLFBDIV_M_32 = 0b00100000,
832 APLLFBD_APLLFBDIV_M_33 = 0b00100001,
833 APLLFBD_APLLFBDIV_M_34 = 0b00100010,
834 APLLFBD_APLLFBDIV_M_35 = 0b00100011,
835 APLLFBD_APLLFBDIV_M_36 = 0b00100100,
836 APLLFBD_APLLFBDIV_M_37 = 0b00100101,
837 APLLFBD_APLLFBDIV_M_38 = 0b00100110,
838 APLLFBD_APLLFBDIV_M_39 = 0b00100111,
839 APLLFBD_APLLFBDIV_M_40 = 0b00101000,
840 APLLFBD_APLLFBDIV_M_41 = 0b00101001,
841 APLLFBD_APLLFBDIV_M_42 = 0b00101010,
842 APLLFBD_APLLFBDIV_M_43 = 0b00101011,
843 APLLFBD_APLLFBDIV_M_44 = 0b00101100,
844 APLLFBD_APLLFBDIV_M_45 = 0b00101101,
845 APLLFBD_APLLFBDIV_M_46 = 0b00101110,
846 APLLFBD_APLLFBDIV_M_47 = 0b00101111,
847 APLLFBD_APLLFBDIV_M_48 = 0b00110000,
848 APLLFBD_APLLFBDIV_M_49 = 0b00110001,
849 APLLFBD_APLLFBDIV_M_50 = 0b00110010,
850 APLLFBD_APLLFBDIV_M_51 = 0b00110011,
851 APLLFBD_APLLFBDIV_M_52 = 0b00110100,
852 APLLFBD_APLLFBDIV_M_53 = 0b00110101,
853 APLLFBD_APLLFBDIV_M_54 = 0b00110110,
854 APLLFBD_APLLFBDIV_M_55 = 0b00110111,
855 APLLFBD_APLLFBDIV_M_56 = 0b00111000,
856 APLLFBD_APLLFBDIV_M_57 = 0b00111001,
857 APLLFBD_APLLFBDIV_M_58 = 0b00111010,
858 APLLFBD_APLLFBDIV_M_59 = 0b00111011,
859 APLLFBD_APLLFBDIV_M_60 = 0b00111100,
860 APLLFBD_APLLFBDIV_M_61 = 0b00111101,
861 APLLFBD_APLLFBDIV_M_62 = 0b00111110,
862 APLLFBD_APLLFBDIV_M_63 = 0b00111111,
863 APLLFBD_APLLFBDIV_M_64 = 0b01000000,
864 APLLFBD_APLLFBDIV_M_65 = 0b01000001,
865 APLLFBD_APLLFBDIV_M_66 = 0b01000010,
866 APLLFBD_APLLFBDIV_M_67 = 0b01000011,
867 APLLFBD_APLLFBDIV_M_68 = 0b01000100,
868 APLLFBD_APLLFBDIV_M_69 = 0b01000101,
869 APLLFBD_APLLFBDIV_M_70 = 0b01000110,
870 APLLFBD_APLLFBDIV_M_71 = 0b01000111,
871 APLLFBD_APLLFBDIV_M_72 = 0b01001000,
872 APLLFBD_APLLFBDIV_M_73 = 0b01001001,
873 APLLFBD_APLLFBDIV_M_74 = 0b01001010,
874 APLLFBD_APLLFBDIV_M_75 = 0b01001011,
875 APLLFBD_APLLFBDIV_M_76 = 0b01001100,
876 APLLFBD_APLLFBDIV_M_77 = 0b01001101,
877 APLLFBD_APLLFBDIV_M_78 = 0b01001110,
878 APLLFBD_APLLFBDIV_M_79 = 0b01001111,
879 APLLFBD_APLLFBDIV_M_80 = 0b01010000,
880 APLLFBD_APLLFBDIV_M_81 = 0b01010001,
881 APLLFBD_APLLFBDIV_M_82 = 0b01010010,
882 APLLFBD_APLLFBDIV_M_83 = 0b01010011,
883 APLLFBD_APLLFBDIV_M_84 = 0b01010100,
884 APLLFBD_APLLFBDIV_M_85 = 0b01010101,
885 APLLFBD_APLLFBDIV_M_86 = 0b01010110,
886 APLLFBD_APLLFBDIV_M_87 = 0b01010111,
887 APLLFBD_APLLFBDIV_M_88 = 0b01011000,
888 APLLFBD_APLLFBDIV_M_89 = 0b01011001,
889 APLLFBD_APLLFBDIV_M_90 = 0b01011010,
890 APLLFBD_APLLFBDIV_M_91 = 0b01011011,
891 APLLFBD_APLLFBDIV_M_92 = 0b01011100,
892 APLLFBD_APLLFBDIV_M_93 = 0b01011101,
893 APLLFBD_APLLFBDIV_M_94 = 0b01011110,
894 APLLFBD_APLLFBDIV_M_95 = 0b01011111,
895 APLLFBD_APLLFBDIV_M_96 = 0b01100000,
896 APLLFBD_APLLFBDIV_M_97 = 0b01100001,
897 APLLFBD_APLLFBDIV_M_98 = 0b01100010,
898 APLLFBD_APLLFBDIV_M_99 = 0b01100011,
899 APLLFBD_APLLFBDIV_M_100 = 0b01100100,
900 APLLFBD_APLLFBDIV_M_101 = 0b01100101,
901 APLLFBD_APLLFBDIV_M_102 = 0b01100110,
902 APLLFBD_APLLFBDIV_M_103 = 0b01100111,
903 APLLFBD_APLLFBDIV_M_104 = 0b01101000,
904 APLLFBD_APLLFBDIV_M_105 = 0b01101001,
905 APLLFBD_APLLFBDIV_M_106 = 0b01101010,
906 APLLFBD_APLLFBDIV_M_107 = 0b01101011,
907 APLLFBD_APLLFBDIV_M_108 = 0b01101100,
908 APLLFBD_APLLFBDIV_M_109 = 0b01101101,
909 APLLFBD_APLLFBDIV_M_110 = 0b01101110,
910 APLLFBD_APLLFBDIV_M_111 = 0b01101111,
911 APLLFBD_APLLFBDIV_M_112 = 0b01110000,
912 APLLFBD_APLLFBDIV_M_113 = 0b01110001,
913 APLLFBD_APLLFBDIV_M_114 = 0b01110010,
914 APLLFBD_APLLFBDIV_M_115 = 0b01110011,
915 APLLFBD_APLLFBDIV_M_116 = 0b01110100,
916 APLLFBD_APLLFBDIV_M_117 = 0b01110101,
917 APLLFBD_APLLFBDIV_M_118 = 0b01110110,
918 APLLFBD_APLLFBDIV_M_119 = 0b01110111,
919 APLLFBD_APLLFBDIV_M_120 = 0b01111000,
920 APLLFBD_APLLFBDIV_M_121 = 0b01111001,
921 APLLFBD_APLLFBDIV_M_122 = 0b01111010,
922 APLLFBD_APLLFBDIV_M_123 = 0b01111011,
923 APLLFBD_APLLFBDIV_M_124 = 0b01111100,
924 APLLFBD_APLLFBDIV_M_125 = 0b01111101,
925 APLLFBD_APLLFBDIV_M_126 = 0b01111110,
926 APLLFBD_APLLFBDIV_M_127 = 0b01111111,
927 APLLFBD_APLLFBDIV_M_128 = 0b10000000,
928 APLLFBD_APLLFBDIV_M_129 = 0b10000001,
929 APLLFBD_APLLFBDIV_M_130 = 0b10000010,
930 APLLFBD_APLLFBDIV_M_131 = 0b10000011,
931 APLLFBD_APLLFBDIV_M_132 = 0b10000100,
932 APLLFBD_APLLFBDIV_M_133 = 0b10000101,
933 APLLFBD_APLLFBDIV_M_134 = 0b10000110,
934 APLLFBD_APLLFBDIV_M_135 = 0b10000111,
935 APLLFBD_APLLFBDIV_M_136 = 0b10001000,
936 APLLFBD_APLLFBDIV_M_137 = 0b10001001,
937 APLLFBD_APLLFBDIV_M_138 = 0b10001010,
938 APLLFBD_APLLFBDIV_M_139 = 0b10001011,
939 APLLFBD_APLLFBDIV_M_140 = 0b10001100,
940 APLLFBD_APLLFBDIV_M_141 = 0b10001101,
941 APLLFBD_APLLFBDIV_M_142 = 0b10001110,
942 APLLFBD_APLLFBDIV_M_143 = 0b10001111,
943 APLLFBD_APLLFBDIV_M_144 = 0b10010000,
944 APLLFBD_APLLFBDIV_M_145 = 0b10010001,
945 APLLFBD_APLLFBDIV_M_146 = 0b10010010,
946 APLLFBD_APLLFBDIV_M_147 = 0b10010011,
947 APLLFBD_APLLFBDIV_M_148 = 0b10010100,
948 APLLFBD_APLLFBDIV_M_149 = 0b10010101,
949 APLLFBD_APLLFBDIV_M_150 = 0b10010110,
950 APLLFBD_APLLFBDIV_M_151 = 0b10010111,
951 APLLFBD_APLLFBDIV_M_152 = 0b10011000,
952 APLLFBD_APLLFBDIV_M_153 = 0b10011001,
953 APLLFBD_APLLFBDIV_M_154 = 0b10011010,
954 APLLFBD_APLLFBDIV_M_155 = 0b10011011,
955 APLLFBD_APLLFBDIV_M_156 = 0b10011100,
956 APLLFBD_APLLFBDIV_M_157 = 0b10011101,
957 APLLFBD_APLLFBDIV_M_158 = 0b10011110,
958 APLLFBD_APLLFBDIV_M_159 = 0b10011111,
959 APLLFBD_APLLFBDIV_M_160 = 0b10100000,
960 APLLFBD_APLLFBDIV_M_161 = 0b10100001,
961 APLLFBD_APLLFBDIV_M_162 = 0b10100010,
962 APLLFBD_APLLFBDIV_M_163 = 0b10100011,
963 APLLFBD_APLLFBDIV_M_164 = 0b10100100,
964 APLLFBD_APLLFBDIV_M_165 = 0b10100101,
965 APLLFBD_APLLFBDIV_M_166 = 0b10100110,
966 APLLFBD_APLLFBDIV_M_167 = 0b10100111,
967 APLLFBD_APLLFBDIV_M_168 = 0b10101000,
968 APLLFBD_APLLFBDIV_M_169 = 0b10101001,
969 APLLFBD_APLLFBDIV_M_170 = 0b10101010,
970 APLLFBD_APLLFBDIV_M_171 = 0b10101011,
971 APLLFBD_APLLFBDIV_M_172 = 0b10101100,
972 APLLFBD_APLLFBDIV_M_173 = 0b10101101,
973 APLLFBD_APLLFBDIV_M_174 = 0b10101110,
974 APLLFBD_APLLFBDIV_M_175 = 0b10101111,
975 APLLFBD_APLLFBDIV_M_176 = 0b10110000,
976 APLLFBD_APLLFBDIV_M_177 = 0b10110001,
977 APLLFBD_APLLFBDIV_M_178 = 0b10110010,
978 APLLFBD_APLLFBDIV_M_179 = 0b10110011,
979 APLLFBD_APLLFBDIV_M_180 = 0b10110100,
980 APLLFBD_APLLFBDIV_M_181 = 0b10110101,
981 APLLFBD_APLLFBDIV_M_182 = 0b10110110,
982 APLLFBD_APLLFBDIV_M_183 = 0b10110111,
983 APLLFBD_APLLFBDIV_M_184 = 0b10111000,
984 APLLFBD_APLLFBDIV_M_185 = 0b10111001,
985 APLLFBD_APLLFBDIV_M_186 = 0b10111010,
986 APLLFBD_APLLFBDIV_M_187 = 0b10111011,
987 APLLFBD_APLLFBDIV_M_188 = 0b10111100,
988 APLLFBD_APLLFBDIV_M_189 = 0b10111101,
989 APLLFBD_APLLFBDIV_M_190 = 0b10111110,
990 APLLFBD_APLLFBDIV_M_191 = 0b10111111,
991 APLLFBD_APLLFBDIV_M_192 = 0b11000000,
992 APLLFBD_APLLFBDIV_M_193 = 0b11000001,
993 APLLFBD_APLLFBDIV_M_194 = 0b11000010,
994 APLLFBD_APLLFBDIV_M_195 = 0b11000011,
995 APLLFBD_APLLFBDIV_M_196 = 0b11000100,
996 APLLFBD_APLLFBDIV_M_197 = 0b11000101,
997 APLLFBD_APLLFBDIV_M_198 = 0b11000110,
998 APLLFBD_APLLFBDIV_M_199 = 0b11000111,
999 APLLFBD_APLLFBDIV_M_200 = 0b11001000
1001 typedef enum APLLFBD_APLLFBDIV_e APLLFBD_APLLFBDIV_t;
1006 volatile enum APLLFBD_APLLFBDIV_e APLLFBDIV : 8;
1007 volatile unsigned : 8;
1008 } __attribute__((packed)) bits;
1009 volatile uint16_t value;
1012 typedef struct APLLFBD_s APLLFBD_t;
1015 #pragma message "error: === selected device family is not supported by oscillator mcal library ===" 1022 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__) 1024 #define REG_APLLDIV_VALID_DATA_WRITE_MASK 0x0377 1025 #define REG_APLLDIV_VALID_DATA_READ_MASK 0x0377 1027 #define REG_APLLDIV_POST1DIV_N2_MASK 0b0000000001110000 1028 #define REG_APLLDIV_POST1DIV_N2(x) {((x << 4) & REG_APLLDIV_POST1DIV_N2_MASK)} 1030 #define REG_APLLDIV_POST2DIV_N3_MASK 0b0000000000000111 1031 #define REG_APLLDIV_POST2DIV_N3(x) {(x & REG_APLLDIV_POST1DIV_N3_MASK)} 1033 enum APLLDIV_POSTxDIV_e {
1034 APLLDIV_POST2DIV_N2N3_1 = 0b001,
1035 APLLDIV_POST2DIV_N2N3_2 = 0b010,
1036 APLLDIV_POST2DIV_N2N3_3 = 0b011,
1037 APLLDIV_POST2DIV_N2N3_4 = 0b100,
1038 APLLDIV_POST2DIV_N2N3_5 = 0b101,
1039 APLLDIV_POST2DIV_N2N3_6 = 0b110,
1040 APLLDIV_POST2DIV_N2N3_7 = 0b111
1042 typedef enum APLLDIV_POSTxDIV_e APLLDIV_POSTxDIV_t;
1044 #define REG_APLLDIV_AVCODIV_FVCO_DIV_BY_1 0b0000001100000000 1045 #define REG_APLLDIV_AVCODIV_FVCO_DIV_BY_2 0b0000001000000000 1046 #define REG_APLLDIV_AVCODIV_FVCO_DIV_BY_3 0b0000000100000000 1047 #define REG_APLLDIV_AVCODIV_FVCO_DIV_BY_4 0b0000000000000000 1049 enum APLLDIV_AVCODIV_e {
1050 APLLDIV_AVCODIV_FVCO_DIV_BY_1 = 0b11,
1051 APLLDIV_AVCODIV_FVCO_DIV_BY_2 = 0b10,
1052 APLLDIV_AVCODIV_FVCO_DIV_BY_3 = 0b01,
1053 APLLDIV_AVCODIV_FVCO_DIV_BY_4 = 0b00
1055 typedef enum APLLDIV_AVCODIV_e APLLDIV_AVCODIV_t;
1060 volatile enum APLLDIV_POSTxDIV_e APOST2DIV : 3;
1061 volatile unsigned : 1;
1062 volatile enum APLLDIV_POSTxDIV_e APOST1DIV : 3;
1063 volatile unsigned : 1;
1064 volatile enum APLLDIV_AVCODIV_e AVCODIV : 2;
1065 volatile unsigned : 6;
1066 } __attribute__((packed)) bits;
1067 volatile uint16_t value;
1070 typedef struct APLLDIV_s APLLDIV_t;
1073 #pragma message "error: === selected device family is not supported by oscillator mcal library ===" 1080 #if defined (__P33SMPS_CH__) || defined (__P33SMPS_CK__) 1082 struct OSC_CONFIG_s {
1083 volatile enum OSCCON_xOSC_TYPE_e osc_type;
1084 volatile enum CLKDIV_FRCDIVN_e frc_div;
1085 volatile enum OSCTUN_TUN_e frc_tune;
1086 volatile enum CLKDIV_PLLPRE_e N1;
1087 volatile enum PLLFBD_PLLFBDIV_e M;
1088 volatile enum PLLDIV_POSTxDIV_e N2;
1089 volatile enum PLLDIV_POSTxDIV_e N3;
1090 volatile enum PLLDIV_VCODIV_e VCODIV;
1092 typedef struct OSC_CONFIG_s OSC_CONFIG_t;
1094 struct AUXOSC_CONFIG_s {
1095 volatile enum ACLKCON_APLLPRE_e N1;
1096 volatile enum APLLFBD_APLLFBDIV_e M;
1097 volatile enum APLLDIV_POSTxDIV_e N2;
1098 volatile enum APLLDIV_POSTxDIV_e N3;
1099 volatile enum APLLDIV_AVCODIV_e AVCODIV;
1100 volatile enum ACLKCON_FRCSEL_e FRCSEL : 1;
1101 volatile enum ACLKCON_APLLCK_e APLLCK : 1;
1102 volatile enum ACLKCON_APLLEN_e APLLEN : 1;
1104 typedef struct AUXOSC_CONFIG_s AUXOSC_CONFIG_t;
1107 #pragma message "error: === selected device family is not supported by oscillator mcal library ===" 1115 enum OSC_CFG_ERR_RESULT_e {
1116 OSCERR_FAILURE = 0x0000,
1117 OSCERR_SUCCESS = 0x0001,
1118 OSCERR_CSF = 0x0002,
1119 OSCERR_RST = 0x0004,
1120 OSCERR_CSD = 0x0008,
1121 OSCERR_PLL_LCK = 0x0010,
1122 OSCERR_APLL_LCK = 0x0020,
1124 typedef enum OSC_CFG_ERR_RESULT_e OSC_CFG_ERR_RESULT_t;
1137 extern volatile uint16_t p33c_Osc_Initialize(
volatile struct OSC_CONFIG_s osc_config);
1138 extern volatile uint16_t p33c_OscFrc_Initialize(
volatile enum CLKDIV_FRCDIVN_e frc_div,
volatile enum OSCTUN_TUN_e frc_tun);
1139 extern volatile uint16_t p33c_OscAuxClk_Initialize(
volatile struct AUXOSC_CONFIG_s aux_clock_config);
1141 extern volatile uint16_t p33c_OscFrc_DefaultInitialize(
volatile enum CPU_SPEED_DEFAULTS_e cpu_speed);
1142 extern volatile uint16_t p33c_OscAuxClk_DefaultInitialize(
volatile enum AUX_PLL_DEFAULTS_e afpllo_frequency);
1144 extern volatile uint16_t p33c_Osc_SetExtFrequency(
volatile int32_t ext_osc_frequency);
1145 extern volatile uint16_t p33c_Osc_GetFrequencies(
void);
enum CLKDIV_PLLPRE_e PLLPRE
enum CLKDIV_FRCDIVN_e FRCDIV
enum OSCCON_CLKLOCK_e CLKLOCK
enum OSCCON_xOSC_TYPE_e COSC
enum OSCCON_xOSC_TYPE_e NOSC
enum CLKDIV_DOZEN_e DOZEN
enum OSCCON_OSWEN_e OSWEN