Advertisement
xerpi

Vita UART spam

Dec 25th, 2018
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.23 KB | None | 0 0
  1. #include <psp2kern/kernel/modulemgr.h>
  2. #include <psp2kern/kernel/threadmgr.h>
  3. #include <psp2kern/kernel/sysmem.h>
  4. #include <psp2kern/lowio/pervasive.h>
  5. #include <psp2kern/uart.h>
  6.  
  7. static SceUID thid;
  8. static int run = 1;
  9.  
  10. static int thread(SceSize args, void *argp)
  11. {
  12.     int i;
  13.  
  14.     ksceKernelDelayThread(250 * 1000);
  15.  
  16.     for (i = 0; i < 7; i++) {
  17.         kscePervasiveUartClockEnable(i); // Turn on clock
  18.         kscePervasiveUartResetDisable(i); // Out of reset
  19.         kscePervasiveUartSetBaudrate(i, 9600);
  20.         ksceUartInit(i);
  21.     }
  22.  
  23.     while (run) {
  24.         for (i = 0; i < 7; i++) {
  25.             ksceUartWrite(i, '0' + i);
  26.             ksceUartWrite(i, '\n');
  27.             ksceUartWrite(i, '\r');
  28.  
  29.             ksceKernelDelayThread(50 * 1000);
  30.         }
  31.     }
  32.  
  33.     kscePervasiveUartResetEnable(0); // Reset
  34.     kscePervasiveUartClockDisable(0); // Turn off clock
  35.  
  36.     return 0;
  37. }
  38.  
  39. void _start() __attribute__ ((weak, alias ("module_start")));
  40.  
  41. int module_start(SceSize argc, const void *args)
  42. {
  43.     thid = ksceKernelCreateThread("uarttest", thread, 0x00, 0x1000, 0, 1 << 0, 0);
  44.  
  45.     ksceKernelStartThread(thid, 0, NULL);
  46.  
  47.     return SCE_KERNEL_START_SUCCESS;
  48.  
  49. }
  50.  
  51. int module_stop(SceSize argc, const void *args)
  52. {
  53.     run = 0;
  54.     ksceKernelWaitThreadEnd(thid, NULL, NULL);
  55.  
  56.     return SCE_KERNEL_STOP_SUCCESS;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement